From 15129d39c0ffff901d5764e2c4df49d78e34fca8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 30 Nov 2026 10:51:47 -0800 Subject: [PATCH] ci: move :alpha only for the highest stable version; refuse odd tags A stable tag moves :alpha only when it is the highest vX.Y.Z tag, so a later patch on an older line never moves :alpha back. A tag that is not vX.Y.Z or vX.Y.Z-pre fails the run instead of publishing. The checkout fetches tags so the comparison sees them. Co-Authored-By: Claude Opus 5.5 --- .../workflows/publish-alpha-images.yml | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/seaweed-block/.github/workflows/publish-alpha-images.yml b/seaweed-block/.github/workflows/publish-alpha-images.yml index 3ec262165e..0a1564e5ca 100644 --- a/seaweed-block/.github/workflows/publish-alpha-images.yml +++ b/seaweed-block/.github/workflows/publish-alpha-images.yml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 # the tag list decides whether :alpha moves - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -39,24 +41,34 @@ jobs: shell: bash run: | set -euo pipefail - # A release candidate (a version with a pre-release suffix, e.g. v1.0.1-rc.2) publishes only - # its own version tag. Only a stable-line release (e.g. v1.0.1) also moves :alpha and sha-*. + # vX.Y.Z-pre (a release candidate) publishes only its own version tag. A stable vX.Y.Z also + # publishes sha-*, and moves :alpha only when it is the highest stable version tag, so a later + # patch on an older line never moves :alpha back. short_sha="${GITHUB_SHA::12}" version="${GITHUB_REF_NAME}" + if [[ ! "${version}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then + echo "refusing to publish: tag ${version} is not vX.Y.Z or vX.Y.Z-pre" >&2 + exit 1 + fi + stable=false + move_alpha=false + if [[ "${version}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + stable=true + highest="$(git tag -l 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)" + if [[ "${version}" == "${highest}" ]]; then + move_alpha=true + fi + fi { echo "block_tags<> "$GITHUB_OUTPUT"