Skip to content

Commit 1169f39

Browse files
authored
Merge pull request #10 from artiz/claude/inspiring-ptolemy-gnsawf
ci: publish a GitHub Release with a commit list on each crate release
2 parents 9b03562 + 8893047 commit 1169f39

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,26 @@ jobs:
9494
# it satisfies the master ruleset) and carries [skip ci], so it does not
9595
# re-trigger CI.
9696
- name: Release & publish
97+
id: release
9798
env:
9899
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
99100
FORCE_VERSION: ${{ github.event.inputs.force_version }}
100101
run: bash scripts/release.sh
102+
103+
# Cut a GitHub Release for the tag release.sh just pushed, using the commit
104+
# list it assembled as the description. Skipped when the release step was a
105+
# no-op (no release-worthy commits). Idempotent: if a release for the tag
106+
# already exists (e.g. a forced re-publish), refresh its notes instead of
107+
# failing.
108+
- name: Create GitHub Release
109+
if: steps.release.outputs.released == 'true'
110+
env:
111+
GH_TOKEN: ${{ secrets.RELEASE_PAT }}
112+
run: |
113+
tag="v${{ steps.release.outputs.version }}"
114+
notes="${{ steps.release.outputs.notes_file }}"
115+
if gh release view "$tag" >/dev/null 2>&1; then
116+
gh release edit "$tag" --title "$tag" --notes-file "$notes"
117+
else
118+
gh release create "$tag" --title "$tag" --notes-file "$notes" --verify-tag
119+
fi

scripts/release.sh

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#
33
# Master-only release step (run by .github/workflows/ci.yml after the lint/test
44
# gates pass). Computes the next version from conventional commits; if there is
5-
# one, it bumps the workspace version, commits + tags it, pushes to master, and
6-
# publishes the changed crates. A clean no-op when no release-worthy commit
7-
# landed since the last tag.
5+
# one, it bumps the workspace version, commits + tags it, pushes to master,
6+
# publishes the changed crates, and assembles the GitHub Release notes (a commit
7+
# list since the previous tag) for the workflow to publish. A clean no-op when no
8+
# release-worthy commit landed since the last tag.
89
#
910
# The release commit is pushed with RELEASE_PAT (an admin token, so it satisfies
1011
# the master branch ruleset) and carries `[skip ci]`, so it does not re-trigger CI.
@@ -27,6 +28,24 @@ fi
2728
current="$(grep -m1 '^version = ' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')"
2829
echo ">> releasing v$new (was v$current)"
2930

31+
# Assemble the GitHub Release notes BEFORE the version-bump commit lands, so the
32+
# range is exactly the feature commits going into this release (everything since
33+
# the previous tag, the release chore commit excluded). The workflow turns this
34+
# into the Release description.
35+
prev_tag="$(git tag --list 'v*' --sort=-version:refname | head -n1)"
36+
notes_range="${prev_tag:+$prev_tag..}HEAD"
37+
notes_file="$(pwd)/release-notes.md"
38+
repo="${GITHUB_REPOSITORY:-artiz/fleischwolf}"
39+
{
40+
echo "## What's changed"
41+
echo
42+
git log "$notes_range" --no-merges --format='- %s (%h)'
43+
if [[ -n "$prev_tag" ]]; then
44+
echo
45+
echo "**Full changelog**: https://github.com/$repo/compare/$prev_tag...v$new"
46+
fi
47+
} >"$notes_file"
48+
3049
# Bump the single version key in the root manifest's [workspace.package].
3150
sed -i -E "0,/^version = \"[^\"]+\"/ s//version = \"$new\"/" Cargo.toml
3251

@@ -58,4 +77,15 @@ git push origin "v$new"
5877
# crates.io), in dependency order.
5978
scripts/ci_publish.sh
6079

80+
# Hand the released version + notes file to the workflow, which cuts the GitHub
81+
# Release for the tag we just pushed. Guarded so the script still runs locally
82+
# (where $GITHUB_OUTPUT is unset).
83+
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
84+
{
85+
echo "released=true"
86+
echo "version=$new"
87+
echo "notes_file=$notes_file"
88+
} >>"$GITHUB_OUTPUT"
89+
fi
90+
6191
echo ">> released v$new"

0 commit comments

Comments
 (0)