Release on a v* tag: static binaries and SHA256SUMS on a Gitea Release #8
No files matched your search
@@ -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 }}
|
||||
@@ -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<year>.<month>.<day>[.<n>]
|
||||
# (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 }}
|
||||
@@ -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<year>.<month>.<day>` 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
|
||||
|
||||
Executable
+30
@@ -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<year>.<month>.<day>[.<n>]" >&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"
|
||||
Reference in new issue
Block a user