Files
Willie 1fe668ec54 ci(release): add reviewed version PRs and manual publication
Create Release Please PRs, synchronize release metadata, and test the exact merge commit before tagging and building an unpublished draft.

Verify release artifacts before manual publication and keep Homebrew and Docker distribution tied to the approved version. Document explicit version overrides and squash-merge behavior in the release skills and runbook.

Validation: make check, 12 release helper tests, actionlint, and an isolated six-platform GoReleaser build with artifact verification.
2026-10-02 01:53:47 +08:00

102 lines
3.1 KiB
YAML

name: Docker Publish
on:
release:
types: [published]
workflow_call:
inputs:
tag:
type: string
required: true
sha:
type: string
required: true
workflow_dispatch:
inputs:
tag:
description: Published release tag to redistribute (e.g. v0.24.0)
type: string
required: true
concurrency:
group: docker-publish
cancel-in-progress: false
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- dockerfile: docker/production/Dockerfile
image_suffix: ""
- dockerfile: docker/ci/Dockerfile
image_suffix: "-ci"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: refs/tags/${{ inputs.tag || github.event.release.tag_name }}
- name: Verify the published version and exact commit
id: version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag || github.event.release.tag_name }}
APPROVED_SHA: ${{ inputs.sha }}
run: |
CURRENT_SHA=$(git rev-parse HEAD)
VERSION=$(python3 scripts/release/release.py check --tag "$TAG" --sha "${APPROVED_SHA:-$CURRENT_SHA}")
test "$(gh release view "$TAG" --json isDraft --jq .isDraft)" = false
test "$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name)" = "$TAG"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "sha=$CURRENT_SHA" >> "$GITHUB_OUTPUT"
echo "short_sha=${CURRENT_SHA:0:7}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}${{ matrix.image_suffix }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.tag || github.event.release.tag_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ inputs.tag || github.event.release.tag_name }}
type=raw,value=sha-${{ steps.version.outputs.short_sha }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ steps.version.outputs.version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
${{ steps.meta.outputs.labels }}
org.opencontainers.image.version=${{ steps.version.outputs.version }}
org.opencontainers.image.revision=${{ steps.version.outputs.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max