From dff0b5346478b3c561fff25ebc0d101fb9d04098 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sun, 4 Oct 2026 23:12:46 -0700 Subject: [PATCH] Release on a v* tag: static binaries and SHA256SUMS on a Gitea Release The installer had no release build: `inbuxa version` said "dev" because nothing stamped it. scripts/build-release.sh builds static linux/amd64 and linux/arm64 binaries with the tag stamped in, plus SHA256SUMS, and is what .gitea/workflows/release.yml runs on a v..[.] tag. The workflow checks the tag is annotated and on main, runs the tests, builds, and attaches the files to a draft Release it publishes only once all three are there; the tag's annotation is the notes. It is built here rather than on GitHub: static Go cross-compiles both architectures on this runner, so BUILD_ON has nothing to offload. A Release made with the job's token starts no other workflow, so this one announces it. announce.yml moves to the same discourse-release pin, 9282c6f. The README says where the binaries are and how to check them. --- .gitea/workflows/announce.yml | 2 +- .gitea/workflows/release.yml | 96 +++++++++++++++++++++++++++++++++++ README.md | 15 ++++++ scripts/build-release.sh | 30 +++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/release.yml create mode 100755 scripts/build-release.sh diff --git a/.gitea/workflows/announce.yml b/.gitea/workflows/announce.yml index 2ec29cd..c53f53d 100644 --- a/.gitea/workflows/announce.yml +++ b/.gitea/workflows/announce.yml @@ -11,7 +11,7 @@ jobs: announce: runs-on: light steps: - - uses: coffey-labs/actions/discourse-release@e9293996e2efa770839121fa8f8da93083f216be + - uses: coffey-labs/actions/discourse-release@9282c6f27303f4eb9d61d6aee6daa444c11d7268 with: api-key: ${{ secrets.DISCOURSE_RELEASE_KEY }} discord-webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..b2e1314 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,96 @@ +# SPDX-FileCopyrightText: 2026 Coffey Labs +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# A v* tag is a release: the binaries for linux/amd64 and linux/arm64, with +# SHA256SUMS, attached to a Gitea Release, then announced. +# +# Built here, not on GitHub like the Rust and image builds: the installer is +# static Go, so both architectures cross-compile on this runner in under a +# minute, and the BUILD_ON switch has nothing to offload. GitHub's copy of the +# Release is made with ~/.config/gitea-mirror/release-sync.py. +# +# The tag must be annotated and on main, and named v..[.] +# (scripts/build-release.sh checks the name). Its annotation is the release +# notes. The Release is a draft until every file is attached, so it is never +# visible half-filled; a draft this run made is deleted if an upload fails. +# +# The job image is pinned by digest, and the only actions are coffey-labs/actions +# ones pinned by SHA. +name: release + +on: + push: + tags: ["v*"] + +defaults: + run: + shell: bash + +jobs: + release: + runs-on: light + container: + image: golang:1.26-bookworm@sha256:a688600ca24f8a4d3ca77f95b0dd40704a9fc787c826660eb7ba0b641b8b175d # 1.26-bookworm + env: + TAG: ${{ github.ref_name }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + # Full history and tags: the ancestry check and the tag's annotation + # both need them. + - uses: coffey-labs/actions/checkout@fab0c4d45e0162963965f1555df27b7bed5e20ec + with: + fetch-depth: 0 + - name: The tag is annotated and on main + run: | + set -eu + git merge-base --is-ancestor "$(git rev-parse "$TAG^{commit}")" origin/main \ + || { echo "$TAG is not on main" >&2; exit 1; } + [ "$(git cat-file -t "refs/tags/$TAG")" = tag ] \ + || { echo "$TAG is a lightweight tag; its annotation is the release notes" >&2; exit 1; } + - run: go test -count=1 ./... + - run: scripts/build-release.sh "$TAG" dist + - name: Release on Gitea + run: | + set -euo pipefail + apt-get -qq update >/dev/null && apt-get -qq install -y --no-install-recommends jq >/dev/null + API="$CI_SERVER_INTERNAL/api/v1/repos/$GITHUB_REPOSITORY" + auth=(-H "Authorization: token $TOKEN") + notes="$(git for-each-ref "refs/tags/$TAG" --format='%(contents)' | sed -e '/-----BEGIN PGP SIGNATURE-----/,$d')" + notes="$notes"$'\n\n'"Static binaries for linux/amd64 and linux/arm64. Verify with SHA256SUMS." + created=0 + id="$(curl -fsS "${auth[@]}" "$API/releases/tags/$TAG" 2>/dev/null | jq -r '.id // empty' || true)" + if [ -z "$id" ]; then + id="$(curl -fsS "${auth[@]}" -H 'Content-Type: application/json' \ + -d "$(jq -n --arg t "$TAG" --arg b "$notes" '{tag_name:$t, name:$t, draft:true, body:$b}')" \ + "$API/releases" | jq -r '.id // empty')" + [ -n "$id" ] || { echo "could not create the release" >&2; exit 1; } + created=1 + fi + have="$(curl -fsS "${auth[@]}" "$API/releases/$id/assets" | jq -r '.[].name')" + for f in dist/inbuxa-linux-amd64 dist/inbuxa-linux-arm64 dist/SHA256SUMS; do + n="$(basename "$f")" + if grep -qxF "$n" <<<"$have"; then echo "already attached: $n"; continue; fi + echo "uploading $n" + curl -fsS --retry 3 --retry-all-errors -o /dev/null "${auth[@]}" --form "attachment=@$f" "$API/releases/$id/assets?name=$n" || { + [ "$created" = 1 ] && curl -sS -o /dev/null "${auth[@]}" -X DELETE "$API/releases/$id" + exit 1 + } + done + if [ "$created" = 1 ]; then + curl -fsS -o /dev/null "${auth[@]}" -H 'Content-Type: application/json' -X PATCH \ + -d '{"draft":false}' "$API/releases/$id" + fi + echo "released $TAG" + + # The Release above is made with the job's own token, and Gitea starts no + # workflow for what the Actions bot does, so announce.yml never sees it. + # The action makes one topic per tag, so a re-run cannot post twice. + announce: + needs: [release] + runs-on: light + steps: + - uses: coffey-labs/actions/discourse-release@9282c6f27303f4eb9d61d6aee6daa444c11d7268 + with: + api-key: ${{ secrets.DISCOURSE_RELEASE_KEY }} + discord-webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} + tag: ${{ github.ref_name }} diff --git a/README.md b/README.md index d64f0c8..9f07a4d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,21 @@ DNS and no certificates, on a machine that starts with nothing. Without certificates -- which `e2e/cases/install-public.sh` proves against a private CA, with no internet and no public name involved. +## Download + +Each release has static binaries for linux/amd64 and linux/arm64, and a +SHA256SUMS to check them against: + + V=v2026.10.5 # the newest: https://git.coffeylabs.org/inbuxa/inbuxa-installer/releases/latest + curl -fLO https://git.coffeylabs.org/inbuxa/inbuxa-installer/releases/download/$V/inbuxa-linux-amd64 + curl -fLO https://git.coffeylabs.org/inbuxa/inbuxa-installer/releases/download/$V/SHA256SUMS + sha256sum --check --ignore-missing SHA256SUMS + install -m 755 inbuxa-linux-amd64 /usr/local/bin/inbuxa + +A release is a `v..` tag on main; `.gitea/workflows/release.yml` +builds it with `scripts/build-release.sh`, which builds the same thing +locally. + ## Building and testing go build ./cmd/inbuxa diff --git a/scripts/build-release.sh b/scripts/build-release.sh new file mode 100755 index 0000000..d7bb2bf --- /dev/null +++ b/scripts/build-release.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2026 Coffey Labs +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# Build the release binaries. +# +# Usage: scripts/build-release.sh TAG OUTDIR +# scripts/build-release.sh v2026.10.5 dist +# +# CI runs exactly this on a v* tag (.gitea/workflows/release.yml), so a +# release can be built and checked on any machine with Go before tagging. +# +# Static (CGO off), so one binary runs on every distribution the installer +# supports, glibc or not, and both architectures cross-compile on one +# machine. The file names carry no version (the release's tag is in its URL); +# the tag is stamped in, so `inbuxa version` and the release cannot disagree. +set -euo pipefail + +TAG="${1:?usage: build-release.sh TAG OUTDIR}" +OUT="${2:?usage: build-release.sh TAG OUTDIR}" +[[ "$TAG" =~ ^v[0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}(\.[0-9]+)?$ ]] \ + || { echo "tag $TAG is not v..[.]" >&2; exit 1; } + +mkdir -p "$OUT" +for arch in amd64 arm64; do + CGO_ENABLED=0 GOOS=linux GOARCH="$arch" go build -trimpath -buildvcs=false \ + -ldflags "-s -w -X main.version=${TAG#v}" -o "$OUT/inbuxa-linux-$arch" ./cmd/inbuxa +done +(cd "$OUT" && sha256sum inbuxa-linux-amd64 inbuxa-linux-arm64 > SHA256SUMS) +cat "$OUT/SHA256SUMS" -- 2.54.0