Repository navigation
63 lines (61 loc) · 2.21 KB
/
Copy pathrelease.yml
File metadata and controls
63 lines (61 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- run: dotnet restore
- run: dotnet build -c Release --no-restore
- run: dotnet test -c Release --no-build
working-directory: tests/Banking.NET.Tests
- name: Extract version from tag
run: |
if [[ ! "$GITHUB_REF_NAME" =~ ^v ]]; then
echo "::error::This workflow must be triggered by a tag matching 'v*', got: $GITHUB_REF_NAME"
exit 1
fi
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Find previous release tag
id: prev-tag
run: |
PREV_TAG=$(git tag -l "v*" --sort=-v:refname | grep -v "^${GITHUB_REF_NAME}$" | head -n 1)
if [ -n "$PREV_TAG" ]; then
echo "NOTES_START_TAG=--notes-start-tag $PREV_TAG" >> $GITHUB_OUTPUT
else
echo "NOTES_START_TAG=" >> $GITHUB_OUTPUT
fi
- name: Pack
run: dotnet pack src/Banking.NET/Banking.NET.csproj -c Release --no-build -p:Version=$VERSION -o ./artifacts
- name: NuGet login
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to NuGet
run: |
dotnet nuget push ./artifacts/*.nupkg --skip-duplicate -s https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }}
dotnet nuget push ./artifacts/*.snupkg --skip-duplicate -s https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }}
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
PRERELEASE_FLAG=""
if [[ "$VERSION" == *"-"* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create ${{ github.ref_name }} ./artifacts/*.nupkg \
--generate-notes ${{ steps.prev-tag.outputs.NOTES_START_TAG }} \
$PRERELEASE_FLAG \
--title "Banking.NET v$VERSION"