Skip to content

Commit 5f666ae

Browse files
committed
add publish workflow
1 parent 0022e39 commit 5f666ae

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
env:
8+
DOTNET_NOLOGO: true
9+
DOTNET_CLI_TELEMETRY_OPTOUT: true
10+
MSBUILDSINGLELOADCONTEXT: 1
11+
12+
jobs:
13+
build:
14+
name: Build and Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Check github.ref starts with 'refs/tags/'
22+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
23+
run: |
24+
echo Error! github.ref does not start with 'refs/tags'
25+
echo github.ref: ${{ github.ref }}
26+
exit 1
27+
- name: Setup .NET Core SDK
28+
uses: actions/setup-dotnet@v2
29+
with:
30+
dotnet-version: "6.0.x"
31+
source-url: https://api.nuget.org/v3/index.json
32+
env:
33+
NUGET_AUTH_TOKEN: ${{secrets.NUGET_API_KEY}}
34+
- name: Restore dotnet tools
35+
run: dotnet tool restore
36+
- name: Fetch complete repository including tags
37+
run: git fetch --tags --force --prune && git describe
38+
- name: Generate version info from git history
39+
run: dotnet gitversion /output json | jq -r 'to_entries|map("GitVersion_\(.key)=\(.value|tostring)")|.[]' >> $GITHUB_ENV
40+
- name: Fail if the version number has not been resolved
41+
if: ${{ !env.GitVersion_SemVer }}
42+
run: |
43+
echo Error! Version number not resolved!
44+
exit 1
45+
- name: Print current version
46+
run: echo "Current version is \"$GitVersion_SemVer\""
47+
- name: Install dependencies
48+
run: dotnet restore
49+
- name: Build solution
50+
run: dotnet build --no-restore -c Release
51+
- name: Create NuGet packages
52+
run: dotnet pack -c Release --no-restore --no-build -o nupkg
53+
- name: Upload nuget packages as artifacts
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: nupkg
57+
path: nupkg
58+
- name: Publish Nuget packages to GitHub registry
59+
run: dotnet nuget push "nupkg/*" -k ${{secrets.NUGET_API_KEY}}

0 commit comments

Comments
 (0)