From e3aaea4becbb2fdfb52b82682a22a56385a9ef68 Mon Sep 17 00:00:00 2001 From: keithlostracco Date: Sun, 26 Jul 2026 11:18:08 -0700 Subject: [PATCH 1/2] ci: reject tags that are not on main, and fix changelog extraction under gawk A tag pushed to a pull request's pre-merge branch tip builds and tests green, but squash-merging rewrites the commit, so the tag ends up on a commit reachable only from the tag itself. v0.3.0 was pushed that way. Check that the tagged commit is an ancestor of main before publishing. The release-notes extraction interpolated the version into an awk regex, where "[0.3.0]" is a character class rather than a literal. Whether the escaping survived depended on the awk in use: mawk keeps the backslash, so it worked on the runner, while gawk drops it and matches nothing. Match the heading by prefix with index() instead, so no awk flavour can turn a released version into an empty description. --- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fca8353..956cfc4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,6 +70,22 @@ jobs: contents: write steps: - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + # Squash-merging a pull request rewrites the commit, so a tag pushed to the + # pre-merge branch tip builds and tests green while pointing at a commit + # reachable only from the tag. Publishing that produces a release whose + # history is not on main, which is only noticed much later by whoever pins + # it. Refuse the tag instead. + - name: Verify the tag is on main + run: | + git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main + if ! git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main; then + echo "::error::$GITHUB_REF_NAME ($GITHUB_SHA) is not an ancestor of main. Delete the tag, then re-tag the merged commit on main." >&2 + exit 1 + fi + echo "$GITHUB_REF_NAME is on main." # One platform-independent, buildable source archive (headers + sources + # CMake config). GitHub also attaches auto-generated "Source code" archives. @@ -81,12 +97,16 @@ jobs: - name: Extract release notes from CHANGELOG run: | version="${GITHUB_REF_NAME#v}" - awk -v v="$version" ' - $0 ~ "^## \\[" v "\\]" { found = 1; next } # heading for this version - found && /^## \[/ { exit } # next version heading - found && /^\[.*\]: / { exit } # link reference block - found && /^ -[Unreleased]: https://github.com/Actualize-Interactive/anim/compare/v0.2.0...HEAD +[Unreleased]: https://github.com/Actualize-Interactive/anim/compare/v0.3.0...HEAD +[0.3.0]: https://github.com/Actualize-Interactive/anim/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/Actualize-Interactive/anim/compare/v0.1.2...v0.2.0 [0.1.2]: https://github.com/Actualize-Interactive/anim/releases/tag/v0.1.2 [0.1.1]: https://github.com/Actualize-Interactive/anim/releases/tag/v0.1.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 28059a4..4d7640e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(anim VERSION 0.2.0 LANGUAGES CXX) +project(anim VERSION 0.3.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON)