From e5ccc5cdb27802c21e3cfa2940e87bc0c89735bc Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Tue, 24 Nov 2026 04:04:02 -0500 Subject: [PATCH] fix(ci): keep CalVer releases and the sync push gate correct on edge cases Signed-off-by: Yordis Prieto --- .config/mise/lib/calver.sh | 13 ++++++++++--- .../workflows/trogonstack-release/add-calver-tag | 4 +++- .../github/workflows/trogonstack-sync/push-main | 11 ++++++----- .github/workflows/trogonstack-sync.yml | 4 ++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.config/mise/lib/calver.sh b/.config/mise/lib/calver.sh index 1d4aeecad9e..0cd86254f40 100644 --- a/.config/mise/lib/calver.sh +++ b/.config/mise/lib/calver.sh @@ -1,16 +1,23 @@ # shellcheck shell=bash # decide reads " " lines of the # existing version tags on stdin. It prints "released " when a -# tag already points at , otherwise "next ". +# tag already points at , otherwise "next ", where N is one +# more than the largest suffix of today (a count would reuse a taken N when a +# tag is missing from the sequence). decide() { - local digest="$1" today="$2" tag tagdigest n=0 + local digest="$1" today="$2" tag tagdigest n=0 suffix while read -r tag tagdigest; do [ -n "$tag" ] || continue if [ "$tagdigest" = "$digest" ]; then echo "released $tag" return 0 fi - case "$tag" in "$today".*) n=$((n + 1)) ;; esac + case "$tag" in + "$today".*) + suffix="${tag#"$today".}" + if [ "$suffix" -ge "$n" ]; then n=$((suffix + 1)); fi + ;; + esac done echo "next $today.$n" } diff --git a/.config/mise/tasks/github/workflows/trogonstack-release/add-calver-tag b/.config/mise/tasks/github/workflows/trogonstack-release/add-calver-tag index 64ee2b4cc20..2e974135185 100755 --- a/.config/mise/tasks/github/workflows/trogonstack-release/add-calver-tag +++ b/.config/mise/tasks/github/workflows/trogonstack-release/add-calver-tag @@ -32,7 +32,9 @@ case "$result" in esac version="${result#next }" -crane tag "$IMAGE:$COMMIT" "$version" +# Tag the digest recorded above: the commit tag is mutable, and a rebuild of +# the same commit could repoint it before this runs. +crane tag "$IMAGE@$digest" "$version" tagged="$(crane digest "$IMAGE:$version")" if [ "$tagged" != "$digest" ]; then diff --git a/.config/mise/tasks/github/workflows/trogonstack-sync/push-main b/.config/mise/tasks/github/workflows/trogonstack-sync/push-main index 5188bdbfe45..364cc539012 100755 --- a/.config/mise/tasks/github/workflows/trogonstack-sync/push-main +++ b/.config/mise/tasks/github/workflows/trogonstack-sync/push-main @@ -5,12 +5,13 @@ set -euo pipefail # a merge that changes them, mise configuration or a local action must land # through a reviewed pull request, never this push. GITHUB_TOKEN already may # not push .github/workflows. -trusted='^(\.github/|\.config/|\.?mise/|\.?mise(\.[^/]+)?\.toml$|\.tool-versions$)' +trusted='^(\.github/|\.config/|\.?mise/|\.?mise(\.[^/]+)?\.(toml|lock)$|\.tool-versions$)' reason="" -# Captured first so a failing diff stops the script instead of reading as no -# match, and so grep -q cannot cut the pipe short under pipefail. -changed="$(git diff --name-only --no-renames HEAD "$MERGE_SHA")" -if grep -Eq "$trusted" <<<"$changed"; then +# Written to a file first so a failing diff stops the script instead of reading +# as no match. NUL-delimited so git does not quote unusual path names, which +# would hide a trusted prefix from the match. +git diff -z --name-only --no-renames HEAD "$MERGE_SHA" > "$RUNNER_TEMP/changed.txt" +if grep -Ezq "$trusted" "$RUNNER_TEMP/changed.txt"; then reason="the merge changes .github, .config or mise configuration, which the publish job runs." elif git push origin "$MERGE_SHA:refs/heads/main"; then # Pushes made with GITHUB_TOKEN do not trigger workflows, but diff --git a/.github/workflows/trogonstack-sync.yml b/.github/workflows/trogonstack-sync.yml index 7091425f2f9..160c15fb136 100644 --- a/.github/workflows/trogonstack-sync.yml +++ b/.github/workflows/trogonstack-sync.yml @@ -79,6 +79,10 @@ jobs: id: verify if: steps.tag.outputs.up_to_date == 'false' && steps.merge.outputs.conflict == 'false' continue-on-error: true + # Shorter than the job's timeout: a hung test then fails this step, + # which still lets publish open the draft pull request. The job timeout + # would cancel the job and skip publish. + timeout-minutes: 45 run: mise run github:workflows:trogonstack-sync:verify # The only job that can read the Barnacle key: the environment admits it