Nuget update/upgrade #7
Workflow file for this run
This file contains 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**.**.**" # Semantic Versioning like "v1.22.3" | |
- "v**.**.**-**" # Prerelease Semantic Versioning like "v1.22.3-rc0004" | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 8.0.x | |
- name: Generate version | |
id: gen_version | |
# because tags in GITHUB cannot be something like "1.22.3" we have to prepend a "v" for version tags | |
# but because a "v" is prepended, we have to remove that again to be able to use the version tag as the version for packaging and pushing the NuGet-package | |
# the "//v/" basically tells that every "v" is replaced by an empty string. c.f.: https://stackoverflow.com/a/67290085/8242470 | |
# using the approach to generate the version in another job for others to use works better than doing that in a global variable, c.f.: https://github.com/orgs/community/discussions/45488 | |
run: echo "VERSION=${GITHUB_REF_NAME//v/}" >> $GITHUB_OUTPUT | |
- name: Pack | |
env: | |
VERSION: ${{ steps.gen_version.outputs.VERSION }} | |
run: dotnet pack ./SlnEditor/SlnEditor.csproj --configuration Release /p:Version=${{ env.VERSION }} | |
- name: Push to Nuget.org | |
env: | |
VERSION: ${{ steps.gen_version.outputs.VERSION }} | |
run: dotnet nuget push ./SlnEditor/bin/Release/SlnEditor.${{ env.VERSION }}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} |