diff --git a/seaweed-block/.github/workflows/publish-alpha-images.yml b/seaweed-block/.github/workflows/publish-alpha-images.yml index de5c8f308c..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,33 +41,36 @@ jobs: shell: bash run: | set -euo pipefail + # 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}" - if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then - version="${GITHUB_REF_NAME}" - { - echo "block_tags<> "$GITHUB_OUTPUT" - else - { - echo "block_tags<> "$GITHUB_OUTPUT" + 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" - name: Build and push block image uses: docker/build-push-action@v6