-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (31 loc) · 1.58 KB
/
publish.yml
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
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 }}