Skip to content

chore(go): pin toolchain go1.26.11 for GO-2026-6859 #539

chore(go): pin toolchain go1.26.11 for GO-2026-6859

chore(go): pin toolchain go1.26.11 for GO-2026-6859 #539

name: Docker publish
# Builds the multi-arch (amd64 + arm64) image from the repo Dockerfile.
# * PR → build only (catches cross-arch build breaks early, e.g. an
# amd64-only step slipping back in). Nothing is pushed.
# * push to dev → push `:dev` + `:sha-<short>`. Pre-release, for deploying a
# branch to a real instance to test it before it reaches main.
# Deliberately does NOT move `:edge` or `:latest`.
# * push to main → push `:edge` + `:sha-<short>` (bleeding edge).
# * push a `vX.Y.Z` tag → push `:X.Y.Z`, `:X.Y`, and `:latest`, then cut a GitHub
# Release with standalone binaries and checksums.
# So `:latest` always tracks the newest *release*,
# never raw main.
#
# Pin a deployment to `:sha-<short>`, never to `:dev` or `:edge` — those move under
# you, and then nothing records which commit an instance is actually running.
on:
push:
branches: [main, dev]
tags: ['v*.*.*']
pull_request:
# A rehearsal: build everything and run the release job's packaging and download
# steps, then stop before publishing a GitHub Release. It exists so the release
# path can be executed without cutting a tag, which is otherwise the only way to
# find out whether it still works.
workflow_dispatch:
inputs:
dry_run:
description: 'Exercise the release job without creating a GitHub Release'
type: boolean
default: true
concurrency:
group: docker-publish-${{ github.ref }}
cancel-in-progress: true
# Read-only by default. Each job below asks for what it needs on top: build
# pushes to GHCR (packages: write), release creates the GitHub Release
# (contents: write).
permissions:
contents: read
env:
REGISTRY: ghcr.io
# Hardcoded lowercase — GHCR tags reject the repo's actual "Calnode/calnode"
# casing (${{ github.repository }} would break the push).
IMAGE_NAME: calnode/calnode
BUILD_PLATFORMS: linux/amd64,linux/arm64
jobs:
build:
runs-on: ubuntu-latest
outputs:
# Digest of the multi-arch index this job pushed. The arm64 smoke test
# pulls exactly this image, so it cannot test a stale tag and cannot race
# the publish: it runs after this job, against the bytes just published.
digest: ${{ steps.build.outputs.digest }}
# Without this the job inherits GitHub's 360-minute default, so a hung
# multi-arch build sits for six hours before being cancelled (observed on
# one branch, cancelled at exactly 6h0m44s). Normal duration is 11-13
# minutes, so an hour is a generous ceiling that fails visibly instead.
timeout-minutes: 60
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to GHCR
if: github.event_name == 'push'
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Computes the tag set from the git ref:
# main → edge, sha-<short>
# dev → dev, sha-<short>
# vX.Y.Z tag → X.Y.Z, X.Y, and latest (latest=auto only fires on a semver tag)
#
# sha- is emitted for every branch build, not just the default one, so a
# pre-release deploy can be pinned to an immutable tag that names its commit.
- name: Docker metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=edge,branch=main
type=ref,event=branch,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build (push on branch pushes and on tags)
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
platforms: ${{ env.BUILD_PLATFORMS }}
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
COMMIT=${{ github.sha }}
- name: Export standalone binaries
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
target: standalone
platforms: ${{ env.BUILD_PLATFORMS }}
outputs: type=local,dest=dist/binaries,platform-split=true
build-args: |
VERSION=${{ steps.meta.outputs.version }}
COMMIT=${{ github.sha }}
- name: Package standalone binaries
env:
VERSION: ${{ steps.meta.outputs.version }}
run: |
mkdir -p dist/release
for platform_dir in dist/binaries/linux_*; do
platform="${platform_dir##*/}"
tar -czf "dist/release/calnode_${VERSION#v}_${platform}.tar.gz" \
-C "$platform_dir" calnode LICENSE
done
cd dist/release
sha256sum ./*.tar.gz > checksums.txt
# Only upload when a release job will consume the artifact. Exporting and
# packaging above stay ungated on purpose: they prove the `standalone` stage
# still builds on every PR, so a break is caught there rather than during a
# release. This step is the one that costs storage for nothing on PRs and
# branch pushes.
#
# The condition must match the `release` job exactly, including the
# workflow_dispatch dry run, or the rehearsal finds no artifact to download.
- name: Upload standalone binaries
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.dry_run)
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: standalone-binaries
path: dist/release/
if-no-files-found: error
arm64-smoke:
# Proves the arm64 half of the multi-arch image actually runs on an ARM CPU,
# not under QEMU. The build job cross-builds both arches under emulation,
# which cannot demonstrate native execution.
#
# Two paths, because the image is not always in the registry:
# push (main/dev/tag) -> pull the exact digest the build job just pushed
# pull request -> build the image natively here, so a PR is checked
# too and this job is proven BEFORE it reaches main
# The pull-request path matters as much as the assertion itself: a gate that
# cannot run until it is merged has not been tested at all.
#
# Free and unmetered: standard arm64 runners cost nothing on public repos.
needs: build
runs-on: ubuntu-24.04-arm
timeout-minutes: 30
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Prove this runner is genuinely arm64
run: |
set -euo pipefail
echo "uname -m: $(uname -m)"
echo "nproc: $(nproc)"
test "$(uname -m)" = "aarch64"
- name: Pull the image this build just published
if: github.event_name == 'push'
env:
IMAGE_REF: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}"
run: |
set -euo pipefail
if [ -z "${{ needs.build.outputs.digest }}" ]; then
echo "::error::build produced no digest, so there is nothing to verify"
exit 1
fi
docker pull "$IMAGE_REF"
- name: Build for arm64 natively (anything that did not publish an image)
if: github.event_name != 'push'
run: docker build --platform linux/arm64 -t calnode-pr:arm64 .
- name: Resolve the image under test
id: img
run: |
set -euo pipefail
# A push published an image, so verify that exact digest. Anything else
# (pull request, dry-run dispatch) built locally and is verified as-is.
if [ "${{ github.event_name }}" = "push" ]; then
echo "ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build.outputs.digest }}" >> "$GITHUB_OUTPUT"
else
echo "ref=calnode-pr:arm64" >> "$GITHUB_OUTPUT"
fi
- name: Confirm the image is arm64
env:
IMAGE_REF: ${{ steps.img.outputs.ref }}
run: |
docker image inspect "$IMAGE_REF" --format 'image arch: {{.Architecture}} / {{.Os}}'
- name: Run it natively, as a deployment would
env:
IMAGE_REF: ${{ steps.img.outputs.ref }}
run: |
set -euo pipefail
docker run -d --name calnode \
-p 127.0.0.1:3000:3000 \
-e PORT=3000 \
-e DATABASE_URL=sqlite:///data/calnode.db \
-e BASE_URL=http://127.0.0.1:3000 \
-v calnode-data:/data \
"$IMAGE_REF"
echo "container arch: $(docker exec calnode uname -m)"
- name: Wait for HTTP and assert the app serves
run: |
set -euo pipefail
for i in $(seq 1 60); do
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/ || true)
if [ "$code" = "200" ] || [ "$code" = "302" ] || [ "$code" = "307" ]; then
echo "app answered on native arm64 (attempt $i, HTTP $code)"
exit 0
fi
sleep 2
done
echo "::error::app did not answer within 120s on arm64"
exit 1
- name: Assert the admin UI loads
run: |
set -euo pipefail
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/admin/)
echo "/admin/ -> HTTP $code"
test "$code" = "200"
- name: Assert the encryption key was persisted, not ephemeral
# Regression guard for the quick-start trap: a first start with no
# CALNODE_ENCRYPTION_KEY must write a key beside the database, so stored
# credentials survive a restart instead of becoming unreadable.
# The helper image is pinned by digest (the multi-arch alpine:3 index).
# Dependabot does not read `docker run` lines, so bump it by hand.
run: |
set -euo pipefail
docker run --rm -v calnode-data:/data alpine:3@sha256:be2656061b536c1883c4034790e21d0a09c5aaaf51968b89368a3c0371ea2c9a sh -c 'test -s /data/calnode.key' \
&& echo "key persisted beside the database"
- name: Assert a restart still finds the key
run: |
set -euo pipefail
docker restart calnode
for i in $(seq 1 60); do
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/ || true)
if [ "$code" = "200" ] || [ "$code" = "302" ] || [ "$code" = "307" ]; then
echo "still serving after restart (HTTP $code)"
# Read the logs into a file before searching them. `docker logs | grep -q`
# fails under `set -o pipefail` as soon as grep matches: grep exits, docker
# logs takes SIGPIPE, and the pipeline returns non-zero even though the line
# was found. It is timing dependent, which is why this assertion failed
# intermittently while the log dump below clearly contained the line.
# The retry also covers Docker's log flush lagging the first HTTP response.
for attempt in $(seq 1 20); do
docker logs calnode > /tmp/restart.log 2>&1 || true
if grep -q "DEK unwrapped from keystore" /tmp/restart.log; then
echo "restart reused the persisted key"
exit 0
fi
sleep 1
done
echo "::error::restart did not reuse the persisted key"
tail -20 /tmp/restart.log
exit 1
fi
sleep 2
done
echo "::error::app did not come back after restart"
exit 1
- name: Show app logs
if: always()
run: docker logs calnode 2>&1 | tail -30
release:
# On a version tag, and on a dry-run dispatch, where it stops before publishing.
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.dry_run)
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: standalone-binaries
path: dist/release
# Pull the matching version's section out of CHANGELOG.md for the release body,
# so the GitHub Release and the CHANGELOG stay identical. Index-based (not a `\[`
# regex) so it's portable across awk flavours. Falls back to GitHub's
# auto-generated notes if there's no CHANGELOG entry for the tag.
- name: Extract release notes from CHANGELOG
id: notes
run: |
version="${GITHUB_REF_NAME#v}"
awk -v tag="## [${version}]" '
index($0, tag)==1 {cap=1; next}
index($0, "## [")==1 && cap==1 {cap=0}
substr($0,1,1)=="[" && cap==1 {exit}
cap {print}
' CHANGELOG.md > release-notes.md
if [ -s release-notes.md ]; then
echo "have_notes=true" >> "$GITHUB_OUTPUT"
else
echo "have_notes=false" >> "$GITHUB_OUTPUT"
fi
# Preinstalled gh CLI + GITHUB_TOKEN (no third-party action — keeps the
# supply-chain surface small).
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ steps.notes.outputs.have_notes }}" = "true" ]; then
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \
--notes-file release-notes.md --verify-tag dist/release/*
else
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \
--generate-notes --verify-tag dist/release/*
fi