Replace GitVersion with tag-driven versioning #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: publish | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Determine version from tag | |
| id: version | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| echo "version=${TAG}" >> "$GITHUB_OUTPUT" | |
| # AssemblyVersion must stay numeric, so strip any prerelease suffix. | |
| echo "assembly=${TAG%%-*}" >> "$GITHUB_OUTPUT" | |
| - name: Setup dotnet | |
| uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: > | |
| dotnet build --configuration Release --no-restore | |
| -p:Version=${{ steps.version.outputs.version }} | |
| -p:AssemblyVersion=${{ steps.version.outputs.assembly }} | |
| -p:FileVersion=${{ steps.version.outputs.assembly }} | |
| -p:InformationalVersion=${{ steps.version.outputs.version }} | |
| - name: Test | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack | |
| run: > | |
| dotnet pack --configuration Release --no-build | |
| -o ${{ runner.temp }}/nupkgs | |
| -p:Version=${{ steps.version.outputs.version }} | |
| - name: NuGet login (trusted publishing) | |
| id: nuget_login | |
| uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0 | |
| with: | |
| user: ${{ vars.NUGET_USER }} | |
| - name: Push to NuGet | |
| run: > | |
| dotnet nuget push "${{ runner.temp }}/nupkgs/*.nupkg" | |
| --source https://api.nuget.org/v3/index.json | |
| --api-key ${{ steps.nuget_login.outputs.NUGET_API_KEY }} | |
| --skip-duplicate |