Skip to content

Commit db2af9a

Browse files
committed
ci(release): auto-publish releases with CHANGELOG-driven notes
Restructures release.yml so a pushed v* tag produces a published release with notes lifted straight from CHANGELOG.md, not a draft sitting forever. notes Extracts the '## [X.Y.Z]' section from CHANGELOG.md and exposes it as a step output. Fails loudly with an ::error:: directive when the section is missing, so a tag push with no CHANGELOG update no longer produces a release with a generic placeholder body. build-* macOS / Linux / Windows builds, now reading needs.notes.outputs.body for the release body instead of a hardcoded 'See the assets below' string. publish New job, depends on all three builds. Runs 'gh release edit --draft=false --latest', flipping the draft that tauri-action created into a public release marked as latest. Adds workflow_dispatch with a 'version' input for dry-running just the notes job (build matrix + publish are gated by github.event_name == 'push'). Lets maintainers validate CHANGELOG slicing without doing a real release.
1 parent 276f438 commit db2af9a

1 file changed

Lines changed: 75 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,60 @@ on:
44
push:
55
tags:
66
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Version to dry-run, e.g. 0.5.1 (no v prefix). Only the notes job runs; nothing is built or published."
11+
required: true
12+
type: string
713

814
jobs:
15+
notes:
16+
name: Extract release notes from CHANGELOG
17+
runs-on: ubuntu-latest
18+
outputs:
19+
body: ${{ steps.extract.outputs.body }}
20+
version: ${{ steps.extract.outputs.version }}
21+
steps:
22+
- uses: actions/checkout@v5
23+
24+
- id: extract
25+
shell: bash
26+
env:
27+
INPUT_VERSION: ${{ github.event.inputs.version }}
28+
run: |
29+
if [ -n "$INPUT_VERSION" ]; then
30+
VERSION="$INPUT_VERSION"
31+
else
32+
VERSION="${GITHUB_REF_NAME#v}"
33+
fi
34+
echo "Resolving CHANGELOG section for v$VERSION"
35+
BODY=$(awk -v ver="$VERSION" '
36+
$0 ~ "^## \\[" ver "\\]" { inside=1; print; next }
37+
inside && /^## \[/ { exit }
38+
inside { print }
39+
' CHANGELOG.md 2>/dev/null || true)
40+
if [ -z "$BODY" ]; then
41+
echo "::error file=CHANGELOG.md::No CHANGELOG section found for version $VERSION. Add a '## [$VERSION] — YYYY-MM-DD' heading before tagging."
42+
exit 1
43+
fi
44+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
45+
{
46+
echo 'body<<RELEASE_NOTES_EOF'
47+
printf '%s\n' "$BODY"
48+
echo RELEASE_NOTES_EOF
49+
} >> "$GITHUB_OUTPUT"
50+
{
51+
echo "## Release notes preview for v$VERSION"
52+
echo
53+
echo '```markdown'
54+
printf '%s\n' "$BODY"
55+
echo '```'
56+
} >> "$GITHUB_STEP_SUMMARY"
57+
958
build-macos:
59+
needs: notes
60+
if: github.event_name == 'push'
1061
runs-on: macos-latest
1162
permissions:
1263
contents: write
@@ -37,11 +88,13 @@ jobs:
3788
with:
3889
tagName: ${{ github.ref_name }}
3990
releaseName: ${{ github.ref_name }}
40-
releaseBody: "See the assets below to download the app."
91+
releaseBody: ${{ needs.notes.outputs.body }}
4192
releaseDraft: true
4293
prerelease: false
4394

4495
build-linux:
96+
needs: notes
97+
if: github.event_name == 'push'
4598
runs-on: ubuntu-22.04
4699
permissions:
47100
contents: write
@@ -77,11 +130,13 @@ jobs:
77130
with:
78131
tagName: ${{ github.ref_name }}
79132
releaseName: ${{ github.ref_name }}
80-
releaseBody: "See the assets below to download the app."
133+
releaseBody: ${{ needs.notes.outputs.body }}
81134
releaseDraft: true
82135
prerelease: false
83136

84137
build-windows:
138+
needs: notes
139+
if: github.event_name == 'push'
85140
runs-on: windows-latest
86141
permissions:
87142
contents: write
@@ -112,6 +167,23 @@ jobs:
112167
with:
113168
tagName: ${{ github.ref_name }}
114169
releaseName: ${{ github.ref_name }}
115-
releaseBody: "See the assets below to download the app."
170+
releaseBody: ${{ needs.notes.outputs.body }}
116171
releaseDraft: true
117172
prerelease: false
173+
174+
publish:
175+
name: Publish release (flip draft → public)
176+
needs: [build-macos, build-linux, build-windows]
177+
if: github.event_name == 'push'
178+
runs-on: ubuntu-latest
179+
permissions:
180+
contents: write
181+
steps:
182+
- name: Publish release
183+
env:
184+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185+
run: |
186+
gh release edit "${{ github.ref_name }}" \
187+
--repo "${{ github.repository }}" \
188+
--draft=false \
189+
--latest

0 commit comments

Comments
 (0)