mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
The notes file was first checked in the last step, after both images (and, for the highest stable tag, :alpha) were already pushed to GHCR, so a tag without docs/releases/vX.Y.Z.md left the images published and no GitHub release. Check it with the tag format, before anything is pushed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
4.6 KiB
YAML
124 lines
4.6 KiB
YAML
name: Publish block release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
tags:
|
|
- "seaweed-block/v*"
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
BLOCK_IMAGE: ghcr.io/seaweedfs/seaweed-block
|
|
CSI_IMAGE: ghcr.io/seaweedfs/seaweed-block-csi
|
|
|
|
jobs:
|
|
publish:
|
|
# Publish only from a version tag; a manual run from a branch must not move :alpha.
|
|
if: startsWith(github.ref, 'refs/tags/seaweed-block/v')
|
|
runs-on: ubuntu-latest
|
|
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
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Compute image tags
|
|
id: tags
|
|
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}"
|
|
version="${GITHUB_REF_NAME#seaweed-block/}"
|
|
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
|
|
notes="seaweed-block/docs/releases/${version%%-*}.md"
|
|
if [[ ! -s "${notes}" ]]; then
|
|
echo "refusing to publish: release notes ${notes} are missing or empty" >&2
|
|
exit 1
|
|
fi
|
|
echo "notes=${notes}" >> "$GITHUB_OUTPUT"
|
|
stable=false
|
|
move_alpha=false
|
|
if [[ "${version}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
stable=true
|
|
highest="$(git tag -l 'seaweed-block/v*' | sed 's|^seaweed-block/||' | 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
|
|
id: block
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: .github/dockerfiles/block-sw-block.Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.tags.outputs.block_tags }}
|
|
|
|
- name: Build and push CSI image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: .github/dockerfiles/block-blockcsi.Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.tags.outputs.csi_tags }}
|
|
|
|
- name: Publish matching binary tarball
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
BLOCK_DIGEST: ${{ steps.block.outputs.digest }}
|
|
NOTES: ${{ steps.tags.outputs.notes }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
version="${GITHUB_REF_NAME#seaweed-block/}"
|
|
out="$RUNNER_TEMP/block-release"
|
|
mkdir -p "$out/bin"
|
|
docker pull "${BLOCK_IMAGE}@${BLOCK_DIGEST}"
|
|
container=$(docker create "${BLOCK_IMAGE}@${BLOCK_DIGEST}")
|
|
trap 'docker rm "$container" >/dev/null' EXIT
|
|
for binary in blockmaster blockvolume sw-block; do
|
|
docker cp "$container:/usr/local/bin/$binary" "$out/bin/$binary"
|
|
done
|
|
bash seaweed-block/scripts/refuse-lab-binary.sh "$out/bin/"*
|
|
asset="sw-block-${version}-linux-amd64.tar.gz"
|
|
tar -C "$out/bin" -czf "$out/$asset" blockmaster blockvolume sw-block
|
|
(cd "$out" && sha256sum "$asset" >SHA256SUMS)
|
|
args=(--repo "$GITHUB_REPOSITORY" --verify-tag --latest=false --title "Seaweed Block $version" --notes-file "$NOTES")
|
|
if [[ "$version" == *-* ]]; then args+=(--prerelease); fi
|
|
gh release create "$GITHUB_REF_NAME" "$out/$asset" "$out/SHA256SUMS" "${args[@]}"
|