|
2 | 2 | # |
3 | 3 | # Master-only release step (run by .github/workflows/ci.yml after the lint/test |
4 | 4 | # 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. |
8 | 9 | # |
9 | 10 | # The release commit is pushed with RELEASE_PAT (an admin token, so it satisfies |
10 | 11 | # the master branch ruleset) and carries `[skip ci]`, so it does not re-trigger CI. |
|
27 | 28 | current="$(grep -m1 '^version = ' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')" |
28 | 29 | echo ">> releasing v$new (was v$current)" |
29 | 30 |
|
| 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 | + |
30 | 49 | # Bump the single version key in the root manifest's [workspace.package]. |
31 | 50 | sed -i -E "0,/^version = \"[^\"]+\"/ s//version = \"$new\"/" Cargo.toml |
32 | 51 |
|
@@ -58,4 +77,15 @@ git push origin "v$new" |
58 | 77 | # crates.io), in dependency order. |
59 | 78 | scripts/ci_publish.sh |
60 | 79 |
|
| 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 | + |
61 | 91 | echo ">> released v$new" |
0 commit comments