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"