From 9833576d8fb254abd2b773a64b2181f9fbbf6a1c Mon Sep 17 00:00:00 2001 From: Coko <91132775+coko7@users.noreply.github.com> Date: Mon, 16 Nov 2026 10:31:39 +0100 Subject: [PATCH] ci(docker): publish image from the release-please workflow docker-publish.yml listened for `release: published`, but release-please creates releases with the default GITHUB_TOKEN, and events from that token don't trigger other workflows, so the image was never built. Move the build into release-please.yml as a job gated on the release-please job's `release_created` output, and check out the release tag. Use the bare `version` output for the image tags: the `watari-v` prefixed tag name isn't valid semver, so metadata-action would have dropped the version tags and pushed only `latest`. Co-Authored-By: lazytrek <352825308+lazytrek@users.noreply.github.com> --- .github/workflows/docker-publish.yml | 51 ---------------------- .github/workflows/release-please.yml | 63 ++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 0809ccd..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Docker Publish - -on: - release: - types: [published] - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v4 - - - 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 }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},value=${{ github.event.release.tag_name }} - type=semver,pattern={{major}}.{{minor}},value=${{ github.event.release.tag_name }} - type=raw,value=latest - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 58d6a3a..d1fc973 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -5,15 +5,72 @@ on: branches: - main -permissions: - contents: write - pull-requests: write +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: release-please: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + version: ${{ steps.release.outputs.version }} steps: - uses: googleapis/release-please-action@v4 + id: release with: config-file: release-please-config.json manifest-file: .release-please-manifest.json + + # Runs in the same workflow instead of on `release: published`, because + # releases created with the default GITHUB_TOKEN don't trigger other workflows. + docker-publish: + needs: release-please + if: ${{ needs.release-please.outputs.release_created == 'true' }} + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.release-please.outputs.tag_name }} + + - 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 }} + + # `version` is the bare semver (e.g. 1.1.0); the tag name carries a + # `watari-v` prefix that metadata-action's semver parser rejects. + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}},value=${{ needs.release-please.outputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.release-please.outputs.version }} + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}