Files
inbuxa-migrate/scripts/build-release.sh
T
jcoffey-dev 3a6848680f
ci / test (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 5m53s
ci / announce (pull_request) Skipped
Version 27.1.0-rc.1: the suite's series versions
inbuxa-migrate moves to the inbuxa suite's versions with the server: a series
(27.1), its patches (27.1.3) and release candidates (27.1-rc.1). Cargo
says 27.1.0-rc.1; --version and the User-Agent show 27.1-rc.1, as the
tag names it (src/version.rs).

The release workflow and scripts/build-release.sh check the tag against
that shown form, and a release candidate's Release is a pre-release, so
it never becomes Gitea's or GitHub's latest.
2026-10-28 09:39:08 -07:00

48 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# Build one release archive for the machine this runs on.
#
# Usage: scripts/build-release.sh VERSION OUTDIR
# scripts/build-release.sh v2026.9.30 dist
#
# CI runs exactly this on one native runner per architecture (amd64 and
# arm64) and joins the results with SHA256SUMS, so a release can be checked
# before tagging on any Linux machine with cargo. The archive name carries no
# version, so .../releases/latest/download/<name> always means the newest.
set -euo pipefail
VERSION="${1:?usage: $0 VERSION OUTDIR}"
OUT="${2:?usage: $0 VERSION OUTDIR}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
case "$(uname -m)" in
x86_64) arch=amd64 ;;
aarch64 | arm64) arch=arm64 ;;
*) echo "unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
# The tag names the version the binary reports, so the two cannot disagree.
# Cargo's 27.1.0 is tagged v27.1, and 27.1.0-rc.1 v27.1-rc.1 (src/version.rs).
want="v$(cd "$ROOT" && cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version' \
| sed -E 's/^([0-9]+[.][0-9]+)[.]0(-|$)/\1\2/')"
[ "$VERSION" = "$want" ] || { echo "tag $VERSION does not match Cargo.toml ($want)" >&2; exit 1; }
name="inbuxa-migrate-linux-$arch"
mkdir -p "$OUT"
OUT="$(cd "$OUT" && pwd)"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
echo "==> building $name ($VERSION)"
(cd "$ROOT" && cargo build --release --locked)
mkdir -p "$STAGE/$name"
cp "$ROOT/target/release/inbuxa-migrate" "$ROOT/README.md" "$STAGE/$name/"
cp -r "$ROOT/LICENSES" "$STAGE/$name/"
# Fixed owner, order and time, so the archive's layout and metadata do not
# change from one build of a tag to the next.
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime="@${SOURCE_DATE_EPOCH:-0}" \
-C "$STAGE/$name" -czf "$OUT/$name.tar.gz" inbuxa-migrate LICENSES README.md
echo "==> $OUT/$name.tar.gz"