Skip to content

Commit 9e6eb6c

Browse files
committed
Extended release action
1 parent da387a2 commit 9e6eb6c

3 files changed

Lines changed: 82 additions & 20 deletions

File tree

.config/dotnet-tools.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-validate": {
6-
"version": "0.0.1-preview.304",
6+
"version": "0.0.1-preview.537",
77
"commands": [
88
"dotnet-validate"
99
],
10-
"rollForward": false
10+
"rollForward": true
1111
},
1212
"docfx": {
1313
"version": "2.78.5",
1414
"commands": [
1515
"docfx"
1616
],
17-
"rollForward": false
17+
"rollForward": true
1818
}
1919
}
2020
}

.github/workflows/release.yml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: Publish to NuGet
2121
environment: nuget
2222
permissions:
23-
contents: read
23+
contents: write
2424
id-token: write
2525
steps:
2626
- name: Checkout git repository
@@ -47,10 +47,20 @@ jobs:
4747
- name: Run tests
4848
run: dotnet test --verbosity normal
4949

50+
- name: Restore .NET tools
51+
run: dotnet tool restore
52+
5053
- name: Create and validate NuGet package
54+
run: dotnet pack QrCodeGenerator/QrCodeGenerator.csproj --verbosity normal
55+
56+
- name: Create API documentation
57+
run: dotnet docfx docfx/docfx.json --warningsAsErrors
58+
working-directory: QrCodeGenerator
59+
60+
- name: Zip API documentation
61+
shell: pwsh
5162
run: |
52-
dotnet tool restore
53-
dotnet pack QrCodeGenerator/QrCodeGenerator.csproj --verbosity normal
63+
Compress-Archive -Path QrCodeGenerator/bin/_site/* -DestinationPath API.Documentation.zip -Force
5464
5565
- name: NuGet login (OIDC to temporary API key)
5666
uses: NuGet/login@v1
@@ -65,3 +75,35 @@ jobs:
6575
--source https://api.nuget.org/v3/index.json
6676
--api-key ${{ steps.login.outputs.NUGET_API_KEY }}
6777
--skip-duplicate
78+
79+
- name: Create and push release tag
80+
shell: pwsh
81+
run: |
82+
$tag = "v${{ steps.version.outputs.version }}"
83+
if (git ls-remote --tags origin "refs/tags/$tag") {
84+
Write-Host "Tag $tag already exists - skipping"
85+
exit 0
86+
}
87+
git config user.name "github-actions[bot]"
88+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
89+
git tag -a $tag -m "Release $tag"
90+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
91+
git push origin "refs/tags/$tag"
92+
93+
- name: Create draft GitHub release
94+
shell: pwsh
95+
env:
96+
GH_TOKEN: ${{ github.token }}
97+
run: |
98+
$version = "${{ steps.version.outputs.version }}"
99+
$tag = "v$version"
100+
$assets = @(
101+
"QrCodeGenerator/bin/Release/Net.Codecrete.QrCodeGenerator.$version.nupkg",
102+
"API.Documentation.zip"
103+
)
104+
if (gh release view $tag 2>$null) {
105+
gh release upload $tag $assets --clobber
106+
} else {
107+
gh release create $tag $assets --draft --title "$tag" --generate-notes
108+
}
109+
if ($LASTEXITCODE) { exit $LASTEXITCODE }

RELEASING.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,47 @@
22

33
The library's version lives in three properties in
44
[QrCodeGenerator/QrCodeGenerator.csproj](QrCodeGenerator/QrCodeGenerator.csproj):
5-
`Version`, `PackageVersion`, `FileVersion`. Between releases it
6-
carries a `-dev` prerelease suffix (e.g. `3.1.0-dev`) so it's always ordered above the
5+
`Version`, `PackageVersion`, `FileVersion`. Between releases `Version` and `PackageVersion`
6+
carry a `-dev` prerelease suffix (e.g. `3.1.0-dev`) so they're always ordered above the
77
last release but never resolved by a floating `3.*` `PackageReference` (NuGet excludes
8-
prereleases from floating ranges by default). `README.md`, `QrCodeGenerator/docs/README.md`,
9-
and the demo projects' `PackageReference` versions stay pinned to the last published
10-
release at all times — they're only updated as part of a release, never in between.
8+
prereleases from floating ranges by default). `FileVersion` stays a plain four-part number
9+
(e.g. `3.1.0.0`) — it cannot hold a prerelease suffix. `AssemblyVersion` is only bumped on
10+
breaking changes and is not touched by a release.
11+
12+
`README.md`, `QrCodeGenerator/docs/README.md` and `QrCodeGenerator/docfx/api/index.md` stay
13+
pinned to the last published release at all times — they're only updated as part of a
14+
release, never in between. This way everyone cloning the repository reads instructions for a
15+
package actually available on nuget.org. The demo projects need no such updating: they use a
16+
floating `Version="3.*"` `PackageReference`, which the `-dev` suffix keeps resolving to the
17+
last published release.
1118

1219
## Steps
1320

14-
1. Update `QrCodeGenerator/QrCodeGenerator.csproj`: set `Version`, `PackageVersion`,
15-
`FileVersion` (but not `AssemblyVersion`) to the release version `X.Y.Z` (drop the `-dev`
16-
suffix), and update `PackageReleaseNotes`.
21+
1. Update `QrCodeGenerator/QrCodeGenerator.csproj`: set `Version` and `PackageVersion` to the
22+
release version `X.Y.Z` (drop the `-dev` suffix), set `FileVersion` to `X.Y.Z.0` (but leave
23+
`AssemblyVersion` alone), and update `PackageReleaseNotes`.
1724
2. Update `README.md`: install command and any prose version references → `X.Y.Z`.
1825
3. Update `QrCodeGenerator/docs/README.md` the same way, including its
1926
`.../blob/vX.Y.Z/...` tag-pinned links.
20-
5. Commit as `Release vX.Y.Z`, tag the commit `vX.Y.Z`, push commit and tag.
21-
6. `dotnet pack -c Release` and publish the resulting nupkg to nuget.org (manual today).
22-
7. Bump `QrCodeGenerator/QrCodeGenerator.csproj` to the next planned version with a
27+
4. Update `QrCodeGenerator/docfx/api/index.md`, which carries the same tag-pinned
28+
`.../blob/vX.Y.Z/...` links.
29+
5. Commit as `Release vX.Y.Z` and push.
30+
6. Run the [*Publish Release to NuGet*](https://github.com/manuelbl/QrCodeGenerator/actions/workflows/release.yml)
31+
workflow. It reads the version from `QrCodeGenerator/QrCodeGenerator.csproj`, runs the
32+
tests, packs and publishes the package, generates the API documentation with docfx, and —
33+
after a successful publish — creates and pushes the `vX.Y.Z` tag and creates a *draft*
34+
GitHub release with the nupkg and `API.Documentation.zip` attached. The job only runs if
35+
the deployment review is approved.
36+
7. Review the draft release on GitHub — edit the auto-generated notes, mark it as a
37+
pre-release if applicable — and publish it.
38+
8. Bump `QrCodeGenerator/QrCodeGenerator.csproj` to the next planned version with a
2339
`-dev` suffix (e.g. `3.2.0-dev`), commit as `Bump version to 3.2.0-dev for development`.
24-
Leave `README.md`, `QrCodeGenerator/docs/README.md`, and the demo projects untouched —
25-
they keep pointing at `X.Y.Z` until the next release.
40+
Leave `README.md`, `QrCodeGenerator/docs/README.md` and `QrCodeGenerator/docfx/api/index.md`
41+
untouched — they keep pointing at `X.Y.Z` until the next release.
42+
43+
The tag and draft-release steps are idempotent: re-running the workflow for a version that
44+
was already tagged skips the tag, and an existing release has its assets re-uploaded rather
45+
than being recreated.
2646

2747
## Why examples still build against HEAD
2848

@@ -31,4 +51,4 @@ before building each demo, overrides that demo's resolved package version for th
3151
run only (`dotnet add package ... --source Local`, which rewrites the checked-out
3252
`.csproj` in the runner's workspace — nothing is committed). This means CI always
3353
validates the examples against the in-progress library code, even though the
34-
`PackageReference` version committed to the repo stays pinned to the last release.
54+
`PackageReference` version committed to the repo resolves to the last release.

0 commit comments

Comments
 (0)