Skip to content

Commit 22d7f32

Browse files
committed
GitHub action for releasing
1 parent 96260a6 commit 22d7f32

4 files changed

Lines changed: 130 additions & 3 deletions

File tree

.config/dotnet-tools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"dotnet-validate"
99
],
1010
"rollForward": true
11+
},
12+
"docfx": {
13+
"version": "2.78.5",
14+
"commands": [
15+
"docfx"
16+
],
17+
"rollForward": true
1118
}
1219
}
1320
}

.github/workflows/continuous-integration.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ jobs:
3939
run: dotnet test --no-build --verbosity normal
4040

4141
- name: Upload received files from failing tests
42-
uses: actions/upload-artifact@v6
42+
uses: actions/upload-artifact@v7
4343
if: failure()
4444
with:
4545
name: Received-${{ runner.os }}
4646
path: "**/*.received.*"
4747
- name: Upload test results
48-
uses: actions/upload-artifact@v6
48+
uses: actions/upload-artifact@v7
4949
if: always()
5050
with:
5151
name: TestResults-${{ runner.os }}
@@ -57,6 +57,12 @@ jobs:
5757
dotnet pack --no-build --verbosity normal
5858
if: startsWith(matrix.os,'windows')
5959

60+
- name: Generate API documentation
61+
run: |
62+
dotnet tool restore
63+
dotnet docfx docfx/docfx.json --warningsAsErrors
64+
if: startsWith(matrix.os,'windows')
65+
6066
- name: Cache SonarCloud packages
6167
if: startsWith(matrix.os,'windows')
6268
uses: actions/cache@v5

.github/workflows/release.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Publish Release to NuGet
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
Configuration: Release
8+
DOTNET_CLI_TELEMETRY_OPTOUT: true
9+
DOTNET_NOLOGO: true
10+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
11+
TERM: xterm-256color
12+
13+
concurrency:
14+
group: nuget-publish
15+
cancel-in-progress: false
16+
17+
jobs:
18+
publish:
19+
runs-on: windows-latest
20+
name: Publish to NuGet
21+
environment: nuget
22+
permissions:
23+
contents: write
24+
id-token: write
25+
steps:
26+
- name: Checkout git repository
27+
uses: actions/checkout@v6
28+
with:
29+
fetch-depth: 0
30+
31+
- uses: actions/setup-dotnet@v5
32+
with:
33+
dotnet-version: |
34+
6.x
35+
8.x
36+
37+
- name: Determine package version
38+
id: version
39+
shell: pwsh
40+
run: |
41+
$v = (dotnet msbuild Core/Core.csproj -getProperty:PackageVersion).Trim()
42+
if (-not $v) { throw "PackageVersion could not be determined" }
43+
"version=$v" >> $env:GITHUB_OUTPUT
44+
Write-Host "Publishing version $v"
45+
46+
- name: Run tests
47+
run: dotnet test --verbosity normal
48+
49+
- name: Restore .NET tools
50+
run: dotnet tool restore
51+
52+
- name: Create and validate Codecrete.SwissQRBill.Core package
53+
run: dotnet pack Core/Core.csproj --verbosity normal
54+
55+
- name: Create and validate Codecrete.SwissQRBill.Generator package
56+
run: dotnet pack PixelCanvas/PixelCanvas.csproj --verbosity normal
57+
58+
- name: Create and validate Codecrete.SwissQRBill.Windows package
59+
run: dotnet pack Windows/Windows.csproj --verbosity normal
60+
61+
- name: Create API documentation
62+
run: dotnet docfx docfx/docfx.json
63+
64+
- name: Zip API documentation
65+
shell: pwsh
66+
run: |
67+
Compress-Archive -Path docfx/bin/_site/* -DestinationPath API.Documentation.zip -Force
68+
69+
- name: NuGet login (OIDC to temporary API key)
70+
uses: NuGet/login@v1
71+
id: login
72+
with:
73+
user: ${{ secrets.NUGET_USER }}
74+
75+
- name: Publish Codecrete.SwissQRBill.Core to NuGet
76+
run: >
77+
dotnet nuget push
78+
Core/bin/Release/Codecrete.SwissQRBill.Core.${{ steps.version.outputs.version }}.nupkg
79+
--source https://api.nuget.org/v3/index.json
80+
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}
81+
--skip-duplicate
82+
83+
- name: Publish Codecrete.SwissQRBill.Generator to NuGet
84+
run: >
85+
dotnet nuget push
86+
PixelCanvas/bin/Release/Codecrete.SwissQRBill.Generator.${{ steps.version.outputs.version }}.nupkg
87+
--source https://api.nuget.org/v3/index.json
88+
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}
89+
--skip-duplicate
90+
91+
- name: Publish Codecrete.SwissQRBill.Windows to NuGet
92+
run: >
93+
dotnet nuget push
94+
Windows/bin/Release/Codecrete.SwissQRBill.Windows.${{ steps.version.outputs.version }}.nupkg
95+
--source https://api.nuget.org/v3/index.json
96+
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}
97+
--skip-duplicate
98+
99+
- name: Create and push release tag
100+
shell: pwsh
101+
run: |
102+
$tag = "v${{ steps.version.outputs.version }}"
103+
if (git ls-remote --tags origin "refs/tags/$tag") {
104+
Write-Host "Tag $tag already exists - skipping"
105+
exit 0
106+
}
107+
git config user.name "github-actions[bot]"
108+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
109+
git tag -a $tag -m "Release $tag"
110+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
111+
git push origin "refs/tags/$tag"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,7 @@ paket-files/
269269

270270
# Python Tools for Visual Studio (PTVS)
271271
__pycache__/
272-
*.pyc
272+
*.pyc
273+
274+
# API documentation archive (built by the release workflow)
275+
API.Documentation.zip

0 commit comments

Comments
 (0)