diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index fa6d05a..aea2cce 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -9,9 +9,11 @@ # 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..[.] +# 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. The Release is a draft until every file is attached, so it is never +# 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 @@ -57,11 +59,12 @@ jobs: 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." + 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" '{tag_name:$t, name:$t, draft:true, body:$b}')" \ + -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 diff --git a/README.md b/README.md index 508e248..22a7d8b 100644 --- a/README.md +++ b/README.md @@ -185,9 +185,12 @@ SHA256SUMS to check them against: 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. +A release is a tag on main named with the INBUXA suite's release number: +`v27.1` for a series, `v27.1.3` for a patch, `v27.1-rc.1` for a release +candidate (before 27.1 the tags were dated, `v2026.10.15.2`). +`.gitea/workflows/release.yml` builds it with `scripts/build-release.sh`, which +builds the same thing locally. A release candidate is published as a +pre-release, so `releases/latest` stays on the last final release. ## Building and testing diff --git a/e2e/cases/install-host.sh b/e2e/cases/install-host.sh index 5a7d397..f161195 100644 --- a/e2e/cases/install-host.sh +++ b/e2e/cases/install-host.sh @@ -45,7 +45,7 @@ echo "$OUT" | grep -v '^ |' | tail -30 | sed 's/^/ /' echo echo "==> the server is a host install" -/usr/local/bin/inbuxa-server --version 2>&1 | grep -q '[0-9]\{4\}\.[0-9]' && ok "the release binary runs: $(/usr/local/bin/inbuxa-server --version 2>&1 | head -1)" || bad "no runnable /usr/local/bin/inbuxa-server" +/usr/local/bin/inbuxa-server --version 2>&1 | grep -q '^[0-9]\{2,4\}\.[0-9]' && ok "the release binary runs: $(/usr/local/bin/inbuxa-server --version 2>&1 | head -1)" || bad "no runnable /usr/local/bin/inbuxa-server" systemctl is-active --quiet $UNIT && ok "$UNIT is running" || { bad "$UNIT is not running"; journalctl -u $UNIT -n 20 --no-pager | sed 's/^/ /'; } systemctl is-enabled --quiet $UNIT && ok "and enabled, so it comes back after a reboot" || bad "$UNIT is not enabled" PID=$(systemctl show -p MainPID --value $UNIT) diff --git a/internal/apply/hostserver.go b/internal/apply/hostserver.go index 93222ac..8345b61 100644 --- a/internal/apply/hostserver.go +++ b/internal/apply/hostserver.go @@ -96,7 +96,7 @@ func (h hostServer) Install(ctx context.Context) (replaced bool, err error) { return false, err } replaced = true - } else if v := binaryVersion(ctx, HostServerBinary); strings.Contains(v, release.ServerVersion) { + } else if v := binaryVersion(ctx, HostServerBinary); isVersion(v, release.ServerVersion) { h.log.Info("%s is already %s", HostServerBinary, release.ServerVersion) } else { if err := h.fetchBinary(ctx); err != nil { @@ -155,7 +155,7 @@ func (h hostServer) fetchBinary(ctx context.Context) error { // Run before it is put in place: a binary this machine's C library // cannot load is caught here, not by a unit that restarts forever. got := binaryVersion(ctx, filepath.Join(work, "inbuxa")) - if !strings.Contains(got, release.ServerVersion) { + if !isVersion(got, release.ServerVersion) { return fmt.Errorf("the release binary does not run here (it said %q); run the server as a container on this machine", got) } if err := runQuiet(ctx, "install", "-m", "0755", filepath.Join(work, "inbuxa"), HostServerBinary); err != nil { @@ -307,6 +307,14 @@ func binaryVersion(ctx context.Context, path string) string { return strings.TrimSpace(string(out)) } +// isVersion says whether what a binary said --version is names exactly the +// release want. The server prints its version as the first word; a match +// anywhere in the output would take 27.1-rc.1, 27.1.3 or 27.10.2 for 27.1. +func isVersion(out, want string) bool { + f := strings.Fields(out) + return len(f) > 0 && f[0] == want +} + func nologin() string { for _, p := range []string{"/usr/sbin/nologin", "/sbin/nologin", "/usr/bin/nologin"} { if _, err := os.Stat(p); err == nil { diff --git a/internal/apply/hostserver_test.go b/internal/apply/hostserver_test.go new file mode 100644 index 0000000..965b14e --- /dev/null +++ b/internal/apply/hostserver_test.go @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: 2026 Coffey Labs LLC +// SPDX-License-Identifier: AGPL-3.0-or-later + +package apply + +import "testing" + +// A binary is the pinned release only when its version is exactly the pin. +// A substring match took 27.1-rc.1 and 27.10.2 for 27.1. +func TestIsVersion(t *testing.T) { + for _, c := range []struct { + out, want string + is bool + }{ + {"2026.10.15", "2026.10.15", true}, + {"27.1\n", "27.1", true}, + {"27.1-rc.1", "27.1-rc.1", true}, + {"27.1-rc.1", "27.1", false}, + {"27.10.2", "27.1", false}, + {"27.1.3", "27.1", false}, + {"2026.10.15", "2026.10.1", false}, + {"", "27.1", false}, + {"exec format error: 27.1", "27.1", false}, + } { + if got := isVersion(c.out, c.want); got != c.is { + t.Errorf("isVersion(%q, %q) = %v, want %v", c.out, c.want, got, c.is) + } + } +} diff --git a/internal/apply/upgrade.go b/internal/apply/upgrade.go index c92bce5..b2f38e5 100644 --- a/internal/apply/upgrade.go +++ b/internal/apply/upgrade.go @@ -113,8 +113,9 @@ func installedVersion(dir string, c plan.Component, s plan.Shape, compose string return "an earlier release" } case plan.Webmail: - // Its own VERSION says 2026.10.12+g6e1a1cb; its release tag, and - // so the pin, the same with a hyphen. + // Its own VERSION says 27.1-rc.1, the pin as it is; a release from + // before 27.1 said 2026.10.12+g6e1a1cb, and its pin was the same + // with a hyphen. if b, err := os.ReadFile(filepath.Join(dir, "webmail", "VERSION")); err == nil { return strings.ReplaceAll(strings.TrimSpace(string(b)), "+", "-") } diff --git a/internal/release/release.go b/internal/release/release.go index b3ae1f7..f61f5b4 100644 --- a/internal/release/release.go +++ b/internal/release/release.go @@ -7,6 +7,11 @@ // One version for both shapes, so a server moved from a container to the host // is the same program, and the plan, the image tag and the download cannot // name three different releases. +// +// A release candidate of the installer (v27.1-rc.1) pins the suite's release +// candidates; a final release pins final releases only. Downloading an RC +// installer is the opt-in: it is published as a pre-release, so +// releases/latest, and so a plain install, never reaches one. package release import "fmt" diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 8fe2000..c03fb6b 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -5,7 +5,7 @@ # Build the release binaries. # # Usage: scripts/build-release.sh TAG OUTDIR -# scripts/build-release.sh v2026.10.5 dist +# scripts/build-release.sh v27.1-rc.1 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. @@ -18,8 +18,10 @@ 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; } +# The suite's release numbers (v27.1, v27.1.3, v27.1-rc.1), or the dated +# ones the installer had before 27.1 (v2026.10.15.2), for a rebuild of one. +[[ "$TAG" =~ ^v([1-9][0-9]\.([1-9]|1[0-2])(\.[1-9][0-9]*|-rc\.[1-9][0-9]*)?|[0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}(\.[0-9]+)?)$ ]] \ + || { echo "tag $TAG is not vYY.M, vYY.M.N or vYY.M-rc.N (or a dated v..[.])" >&2; exit 1; } mkdir -p "$OUT" for arch in amd64 arm64; do