Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ jobs:
if gh release view "$TAG" > /dev/null 2>&1; then
echo "Release $TAG already exists; reusing it."
else
gh release create "$TAG" --draft --generate-notes --title "$TAG" --verify-tag
source "$RUNNER_TEMP/release-scripts/common.sh"
NOTES_ARGS=()
PREVIOUS_TAG=$(get_previous_final_tag "${TAG#v}")
if [[ -n "$PREVIOUS_TAG" ]]; then
NOTES_ARGS=(--notes-start-tag "$PREVIOUS_TAG")
fi
gh release create "$TAG" --draft --generate-notes "${NOTES_ARGS[@]}" --title "$TAG" --verify-tag
fi

- name: Summary
Expand Down
18 changes: 18 additions & 0 deletions scripts/release/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ get_latest_final_version() {
return 1
}

# Release notes need this explicitly: final tags live on release branches, so the
# previous one is often missing from the new tag's history and GitHub falls back further.
get_previous_final_tag() {
local version="$1" tag major minor patch t_major t_minor t_patch
IFS='.' read -r major minor patch <<< "$version"
while IFS= read -r tag; do
if [[ "$tag" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
t_major=$((10#${BASH_REMATCH[1]})); t_minor=$((10#${BASH_REMATCH[2]})); t_patch=$((10#${BASH_REMATCH[3]}))
if (( t_major < 10#$major
|| (t_major == 10#$major && t_minor < 10#$minor)
|| (t_major == 10#$major && t_minor == 10#$minor && t_patch < 10#$patch) )); then
echo "$tag"
return 0
fi
fi
done < <(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname)
}

get_next_version() {
local bump_type="$1" current_version major minor patch
if [[ "$bump_type" != major && "$bump_type" != minor && "$bump_type" != patch ]]; then
Expand Down
4 changes: 4 additions & 0 deletions scripts/release/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ test_version_bumps() {
assert_equal 8.11.0 "$(get_next_version minor)" 'minor bumps reset a nonzero patch'
assert_equal 8.10.5 "$(get_next_version patch)" 'patch bumps retain major and minor'
assert_rejected 'bump_type must be' get_next_version invalid
assert_equal v8.10.4 "$(get_previous_final_tag 8.11.0)" 'previous final tag skips RCs and uses version order'
assert_equal v8.10.0 "$(get_previous_final_tag 8.10.4)" 'previous final tag excludes the version being released'
assert_equal v8.9.0 "$(get_previous_final_tag 8.9.1)" 'a patch on an older line ignores newer releases'
assert_equal '' "$(get_previous_final_tag 8.9.0)" 'the first release has no previous final tag'

git tag -d v8.9.0 v8.10.0 v8.10.4 >/dev/null
assert_rejected 'No final release tags found' get_latest_final_version
Expand Down
Loading