# SPDX-FileCopyrightText: 2026 Coffey Labs LLC # 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 with the suite's release # number: v27.1, v27.1.3, or v27.1-rc.1 for a release candidate # (scripts/build-release.sh checks the name). Its annotation is the release # notes. A release candidate is published as a pre-release, so the releases/latest # link, and the README's download, keep pointing at the last final release. 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:dc40a13b61304647ed7e5d581d246b86413dfc29d63c6d018310feb93cd98fc0 # 1.26-bookworm (1.26.11) 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: Sign SHA256SUMS with minisign env: MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }} run: | set -euo pipefail if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then echo "MINISIGN_SECRET_KEY is not set; this release will be unsigned" >&2 exit 0 fi apt-get -qq update >/dev/null && apt-get -qq install -y --no-install-recommends minisign >/dev/null umask 077 key="$(mktemp)"; printf '%s\n' "$MINISIGN_SECRET_KEY" > "$key" minisign -S -s "$key" -m dist/SHA256SUMS -t "inbuxa $TAG" rm -f "$key" echo "signed dist/SHA256SUMS -> dist/SHA256SUMS.minisig" - 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 [A-Z ]*SIGNATURE-----$/,$d')" # PGP or SSH notes="$notes"$'\n\n'"Static binaries for linux/amd64 and linux/arm64. Verify with SHA256SUMS (signed as SHA256SUMS.minisig; minisign public key in the README)." pre=false; [[ "$TAG" == *-rc.* ]] && pre=true 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" --argjson p "$pre" '{tag_name:$t, name:$t, draft:true, prerelease:$p, 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 dist/SHA256SUMS.minisig; do [ -e "$f" ] || continue # .minisig is absent only on an unsigned release 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@ba4cde7c3b47cc9f93c0080da8ba838a1ef1845b with: api-key: ${{ secrets.DISCOURSE_RELEASE_KEY }} discord-webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }} tag: ${{ github.ref_name }}