feat: publish multi-arch Docker release image to GitHub Container Registry

In `.github/workflows/release.yml`, the `docker` job removes the
`DOCKERHUB_ENABLED` condition, adds `packages: write` permission, logs
in to `ghcr.io` with `GITHUB_TOKEN` on `push` events, and targets
`ghcr.io/${{ github.repository }}` while keeping Docker Hub publishing
optional when `DOCKERHUB_ENABLED` is `'true'`. Image metadata adds
`type=semver,pattern={{version}}` alongside `:latest` and the git tag,
and `docker/build-push-action` passes `ARTEX_VERSION=${{ github.ref_name
}}` for `linux/amd64` and `linux/arm64` while pushing only on `push`
events so `workflow_dispatch` runs build without pushing. Because the
image builds from the repository context without prebuilt binary
artifacts, `docker` removes the `bin-linux-*` artifact downloads and
`binaries` uploads only `bin-linux-amd64` for the `release` job's Syft
SBOM scan. `README.md` documents pulling, running, and updating
`ghcr.io/baarai/artex` alongside the checkout-based Docker Compose
setup.

Fixes #466
This commit is contained in:
Matt Van Horn
2026-11-21 21:11:56 -08:00
parent 5bed53b6ae
commit d86b22719a
2 changed files with 72 additions and 31 deletions
+28 -23
View File
@@ -73,12 +73,12 @@ jobs:
with:
name: pkg-${{ matrix.goos }}-${{ matrix.goarch }}
path: "dist/*.zip"
# Upload raw Linux binaries separately for reuse by the docker job (avoids rebuilding the frontend + Go inside the image)
- if: matrix.goos == 'linux'
# Upload the raw linux/amd64 binary separately for the release job's Syft SBOM scan
- if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
uses: actions/upload-artifact@v4
with:
name: bin-linux-${{ matrix.goarch }}
path: dist/artex-linux-${{ matrix.goarch }}/artex
name: bin-linux-amd64
path: dist/artex-linux-amd64/artex
# ③ Collect all zips → create the GitHub Release
release:
@@ -152,45 +152,50 @@ jobs:
generate_release_notes: false
body_path: ${{ runner.temp }}/release-body.md
# ④ Multi-arch image → push to Docker Hub (reuses the Linux binaries built by the
# binaries job; the image only installs tools + ships the binary; arm64 only needs
# to emulate the apt layer, so builds are much faster)
# Publishing the image needs Docker Hub credentials and a namespace we own, so the
# job stays skipped unless the repository defines DOCKERHUB_ENABLED (set it to true
# and provide DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets plus DOCKERHUB_IMAGE).
# ④ Multi-arch image → push to GitHub Container Registry (and optionally Docker Hub
# when DOCKERHUB_ENABLED is set to 'true' alongside DOCKERHUB_IMAGE and
# DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets). Dry runs (workflow_dispatch)
# build both platforms without logging in or pushing.
docker:
needs: binaries
if: ${{ vars.DOCKERHUB_ENABLED == 'true' && github.event_name == 'push' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4 # fetch the Dockerfile and skills/
- uses: actions/download-artifact@v4
with:
name: bin-linux-amd64
path: dist/amd64
- uses: actions/download-artifact@v4
with:
name: bin-linux-arm64
path: dist/arm64
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
if: github.event_name == 'push' && vars.DOCKERHUB_ENABLED == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ vars.DOCKERHUB_IMAGE }}
images: |
ghcr.io/${{ github.repository }}
${{ vars.DOCKERHUB_ENABLED == 'true' && vars.DOCKERHUB_IMAGE || '' }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ARTEX_VERSION=${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max