Skip to content

Commit ef40f7d

Browse files
authored
Merge pull request #8 from TheJoeIaut/claude/release-workflow-on-tag
Build and draft a release from a version tag
2 parents 02caaca + c6fcb9d commit ef40f7d

2 files changed

Lines changed: 136 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Release
2+
3+
# Packaging a release by hand means a self-contained publish, a run through Elgato's
4+
# packer and an upload, with the version living in two files that have to agree with
5+
# the tag. Pushing a tag does all of it here instead.
6+
#
7+
# The release is left as a draft: the notes come from the README and usually want a
8+
# read before anyone outside sees them.
9+
on:
10+
push:
11+
tags: ["v*"]
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
release:
18+
name: Package and draft the release
19+
# The shipped package is Windows only, and this is the runner the win-x64 build
20+
# already uses in CI.
21+
runs-on: windows-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
# A tag that disagrees with the manifest ships a package Stream Deck either
26+
# refuses as an update or installs under the wrong version. Cheaper to catch
27+
# here than after the release is out.
28+
- name: Check the tag matches the plugin version
29+
id: version
30+
shell: bash
31+
run: |
32+
tag="${GITHUB_REF_NAME#v}"
33+
manifest=$(jq -r '.Version' BitwardenCLI/manifest.json)
34+
csproj=$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' BitwardenCLI/BitwardenStreamdeckPlugin.csproj)
35+
36+
# The manifest carries a fourth, build field that the tag does not.
37+
if [[ ! "$manifest" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
38+
echo "::error::manifest.json Version '$manifest' is not four dot separated numbers"
39+
exit 1
40+
fi
41+
42+
disagrees=
43+
[[ "${manifest%.*}" == "$tag" ]] || disagrees="manifest.json says $manifest"
44+
[[ "$csproj" == "$tag" ]] || disagrees="${disagrees:+$disagrees, }csproj says $csproj"
45+
46+
if [[ -n "$disagrees" ]]; then
47+
echo "::error::tag $GITHUB_REF_NAME expects version $tag, but $disagrees"
48+
exit 1
49+
fi
50+
51+
echo "version=$tag" >> "$GITHUB_OUTPUT"
52+
53+
- uses: actions/setup-dotnet@v4
54+
with:
55+
dotnet-version: "10.0.x"
56+
57+
- uses: actions/setup-node@v4
58+
with:
59+
node-version: "22"
60+
61+
# Self-contained, so nobody needs a .NET install. A plain build would carry every
62+
# platform's SkiaSharp natives and come to roughly 180 MB - see BUILDING.md.
63+
- name: Publish self-contained
64+
run: >
65+
dotnet publish BitwardenCLI/BitwardenStreamdeckPlugin.csproj
66+
-c Release -r win-x64 --self-contained true
67+
-o out/com.thejoeiaut.bitwarden.sdPlugin
68+
69+
# Elgato's own packer, which is what turns a .sdPlugin folder into the single file
70+
# people double-click. It validates the manifest on the way through, so a plugin
71+
# the Marketplace would reject fails here instead.
72+
- name: Pack the .streamDeckPlugin
73+
shell: bash
74+
run: >
75+
npx --yes --package=@elgato/cli@1
76+
streamdeck pack out/com.thejoeiaut.bitwarden.sdPlugin --output dist
77+
78+
# The changelog is already written in the README; taking the notes from there is
79+
# easier than keeping two copies of it in step.
80+
- name: Take the release notes from the README
81+
shell: bash
82+
run: |
83+
# Any heading ends the section: the next version below it, or - for the oldest
84+
# entry in the list - whatever section follows the changelog.
85+
awk -v want="### ${{ steps.version.outputs.version }}" '
86+
$0 == want { found = 1; next }
87+
found && /^#+ / { exit }
88+
found { print }
89+
' README.md | awk 'NF { started = 1 } started' > notes.md
90+
91+
if [[ ! -s notes.md ]]; then
92+
echo "::error::README.md has no '### ${{ steps.version.outputs.version }}' section under 'What has changed'"
93+
exit 1
94+
fi
95+
96+
cat >> notes.md <<'EOF'
97+
98+
See the [README](https://github.com/TheJoeIaut/Bitwarden-Streamdeck-Plugin#readme) for installation and usage.
99+
100+
Icons used in this application are provided by Font Awesome (https://fontawesome.com), licensed under the Font Awesome Free License.
101+
EOF
102+
103+
- name: Draft the release
104+
shell: bash
105+
env:
106+
GH_TOKEN: ${{ github.token }}
107+
run: >
108+
gh release create "$GITHUB_REF_NAME"
109+
--draft
110+
--title "${{ steps.version.outputs.version }}"
111+
--notes-file notes.md
112+
dist/*.streamDeckPlugin

‎BUILDING.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ otherwise the script asks you to quit it from its tray icon and waits (`-WaitMin
4949
10 by default). Pass `-SkipBuild` to install the last publish again, or `-NoRelaunch` to
5050
leave Stream Deck closed.
5151

52+
## Releasing
53+
54+
Pushing a `v*` tag runs [the release workflow](.github/workflows/release.yml): it publishes
55+
a self-contained win-x64 build, packs it into a `.streamDeckPlugin` with Elgato's own
56+
packer, and opens a **draft** release with the package attached. Nothing is public until
57+
you press Publish.
58+
59+
Two things have to be in place first, and the workflow stops rather than releasing if
60+
either is missing:
61+
62+
1. The version, in **both** `BitwardenCLI/manifest.json` (`Version`, four numbers) and
63+
`BitwardenCLI/BitwardenStreamdeckPlugin.csproj` (`<Version>`, three). The tag has to
64+
agree with them - `v2.0.1` wants `2.0.1.0` and `2.0.1`.
65+
2. A `### <version>` section in the README's *What has changed*. The release notes are
66+
taken from it.
67+
68+
```bash
69+
git tag v2.0.1
70+
git push origin v2.0.1
71+
```
72+
73+
Then read the draft and publish it. The Elgato Marketplace listing is a separate upload,
74+
through the Maker portal.
75+
5276
## See also
5377

5478
- [TESTING.md](TESTING.md) - running the unit and integration suites

0 commit comments

Comments
 (0)