Merge pull request #839 from seaweedfs/ci/pub-rc-own-tag-main

ci: a release candidate publishes only its own version tag
This commit is contained in:
Ping Qiu authored and GitHub committed 2026-11-30 11:16:08 -08:00
commit a4415e9767
1 file changed
+30 -25
+30 -25
View File
@@ -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<<EOF"
echo "${BLOCK_IMAGE}:${version}"
echo "${BLOCK_IMAGE}:alpha"
echo "${BLOCK_IMAGE}:sha-${short_sha}"
echo "EOF"
echo "csi_tags<<EOF"
echo "${CSI_IMAGE}:${version}"
echo "${CSI_IMAGE}:alpha"
echo "${CSI_IMAGE}:sha-${short_sha}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
else
{
echo "block_tags<<EOF"
echo "${BLOCK_IMAGE}:alpha"
echo "${BLOCK_IMAGE}:sha-${short_sha}"
echo "EOF"
echo "csi_tags<<EOF"
echo "${CSI_IMAGE}:alpha"
echo "${CSI_IMAGE}:sha-${short_sha}"
echo "EOF"
} >> "$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<<EOF"
echo "${BLOCK_IMAGE}:${version}"
if [[ "${stable}" == true ]]; then echo "${BLOCK_IMAGE}:sha-${short_sha}"; fi
if [[ "${move_alpha}" == true ]]; then echo "${BLOCK_IMAGE}:alpha"; fi
echo "EOF"
echo "csi_tags<<EOF"
echo "${CSI_IMAGE}:${version}"
if [[ "${stable}" == true ]]; then echo "${CSI_IMAGE}:sha-${short_sha}"; fi
if [[ "${move_alpha}" == true ]]; then echo "${CSI_IMAGE}:alpha"; fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push block image
uses: docker/build-push-action@v6