1- name : Release NuGet package
1+ name : Publish NuGet package
22
33on :
4- push :
5- tags :
6- - " v[0-9]+.[0-9]+.[0-9]+"
4+ workflow_dispatch :
5+ inputs :
6+ publishPreRelease :
7+ description : ' Publish pre-release'
8+ type : boolean
9+
710jobs :
811 build :
912 runs-on : ubuntu-latest
1013 steps :
1114 - name : Checkout
1215 uses : actions/checkout@v4
16+ with :
17+ fetch-depth : 0
1318
14- - name : Verify commit exists in origin/main
15- run : |
16- git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
17- git branch --remote --contains | grep origin/main
19+ - name : Install GitVersion
20+ uses : gittools/actions/gitversion/setup@v3.1.11
21+ with :
22+ versionSpec : ' 6.0.x '
1823
19- - name : Set VERSION variable from tag
20- run : echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
24+ - name : Determine version
25+ id : version_step
26+ uses : gittools/actions/gitversion/execute@v3.1.11
2127
22- - name : Restore dependencies
28+ - name : Set package version
29+ run : |
30+ version=${{ steps.version_step.outputs.majorMinorPatch }}
31+ preRelease=${{ steps.version_step.outputs.preReleaseTag }}
32+
33+ if [ "${{ inputs.publishPreRelease }}" == "true" ]; then
34+ echo "PACKAGE_VERSION=$version-pre.${{ steps.version_step.outputs.preReleaseNumber }}" >> $GITHUB_ENV
35+ else
36+ echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV
37+ fi
38+
39+ - name : Restore
2340 run : dotnet restore
2441
2542 - name : Build
26- run : dotnet build -c Release /p:Version=${VERSION }
43+ run : dotnet build -c Release /p:Version=${PACKAGE_VERSION }
2744
2845 - name : Test
29- run : dotnet test -c Release /p:Version=${VERSION } --no-restore --verbosity normal
46+ run : dotnet test -c Release /p:Version=${PACKAGE_VERSION } --no-restore --verbosity normal
3047
3148 - name : Pack
32- run : dotnet pack -c Release /p:Version=${VERSION } --no-restore --output .
49+ run : dotnet pack -c Release /p:Version=${PACKAGE_VERSION } --no-restore --output .
3350
3451 - name : Push
35- run : dotnet nuget push OldBit.Spectron.Files.${VERSION }.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
52+ run : dotnet nuget push OldBit.Spectron.Files.${PACKAGE_VERSION }.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
0 commit comments