|
| 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 |
0 commit comments