release: reproducible builds, and sign every asset
All checks were successful
android-ci / android (pull_request) Successful in 12m34s
ci / test (pull_request) Successful in 13m28s
ci / sdk (pull_request) Successful in 1m13s

"The source is public" is not a check anyone can run, and against a Tor +
Monero tool the surviving objection is that the released binary might not be
that source. This makes the build checkable instead of trusted.

- scripts/reproducible-build.sh is the single definition of a release build:
  digest-pinned builder image, fixed in-container paths, SOURCE_DATE_EPOCH
  from the released commit, --locked, its own apt build deps, and RUSTFLAGS
  replaced rather than extended. The fixed paths are load-bearing: rustc's
  --remap-path-prefix cannot reach absolute paths compiled in by a C
  toolchain, and this graph always has one (rusqlite compiles OpenSSL from
  vendored sources; the default cuprate-daemon adds RandomX and cmake). It
  also records toolchain versions in build-info, because the apt build deps
  are not digest-pinned the way the image is.
- release.yml pins the image by digest, resolves SOURCE_DATE_EPOCH from the
  tag's commit, runs that recipe, and uploads build-info-<target>.txt beside
  the binary. The cargo target volume is created per run and removed, so the
  published artifact cannot come out of a cache that a verifier does not have.
- scripts/verify-reproducible.sh rebuilds a tag in the same pinned image and
  compares bytes against the release asset. Two fresh builds of the same tree
  in that image produce identical sha256.
- scripts/sign-release.sh signs with minisign and verifies its own signature
  against the committed public key. The publish job signs BEFORE publishing
  and fails closed without MINISIGN_SECRET_KEY, so nothing unsigned reaches
  the release page: an unsigned release is indistinguishable from a signed
  one to anyone who is not checking. Checked: signature accepted by an
  independent minisign -V, a tampered file rejected, a missing key refused,
  a missing public key refused.
- build-release-local.sh runs the same container and the same recipe. A host
  cargo build would publish a hash nobody could reproduce, which is worse
  than having no fallback at all.
- docs/VERIFY.md is the verifier-facing walkthrough: the dependency graph and
  where its HTTP actually comes from, the wallet's real seed-read exposure,
  the rebuild check, the signature check, and an explicit list of what none
  of it proves.
- Cargo.toml repository: point at the Forgejo instance that hosts this and
  builds its releases.

Needs a MINISIGN_SECRET_KEY secret before the next release; without it the
publish job stops by design. docs/RELEASING.md has the keygen procedure.
This commit is contained in:
agent 2026-10-11 12:20:08 -04:00
commit 601f640f78
No known key found for this signature in database
11 changed files with 962 additions and 76 deletions

View file

@ -1,10 +1,14 @@
#!/usr/bin/env bash
# Offline fallback: build the x86_64 release asset on this host and publish it
# to the Forgejo release for <tag>. CI (.forgejo/workflows/release.yml) now
# builds both aarch64 (Pi runner) and x86_64 (amd64 runner). Use this script
# when you cannot wait for CI or the amd64 runner is down.
# Offline fallback: build and publish the x86_64 release asset from this host
# when CI (.forgejo/workflows/release.yml) cannot be used.
#
# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.0
# Usage: MINISIGN_SECRET_KEY=... FORGEJO_TOKEN=... scripts/build-release-local.sh v0.14.0
#
# It runs the SAME recipe CI runs, inside the same digest-pinned builder image,
# so the asset it publishes is one a verifier can reproduce. A plain host
# `cargo build` would not be: different rustc, different build paths, different
# bytes — and the published hash would then match nothing anyone could rebuild,
# which is worse than having no fallback at all.
#
# Does not create or push the tag: the release workflow owns tagging. Idempotent
# (same-named assets are replaced). Never moves an existing tag.
@ -15,22 +19,62 @@ target=x86_64-unknown-linux-gnu
root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$root"
# Must equal RUST_IMAGE in .forgejo/workflows/release.yml and BUILDER_IMAGE in
# scripts/verify-reproducible.sh. Three copies, one digest — see docs/VERIFY.md.
BUILDER_IMAGE="rust@sha256:93ce27a88655056a51dbdd8f5f2d7ddc071c7b0070fb288a37b5a285fc83971e"
command -v docker >/dev/null 2>&1 || {
echo "build-release-local: docker is required (the build runs in the pinned image)" >&2
exit 1
}
expected="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
if [ "$tag" != "v$expected" ]; then
echo "warn: tag $tag does not match Cargo.toml version $expected (--version will report $expected)"
fi
echo "==> cargo build --release --locked"
cargo build --release --locked
sha="$(git rev-parse --verify "$tag^{commit}" 2>/dev/null)" || {
echo "build-release-local: tag $tag not found — run: git fetch --tags" >&2
exit 1
}
sde="$(git log -1 --format=%ct "$sha")"
echo "==> $tag at $sha, SOURCE_DATE_EPOCH=$sde"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
mkdir -p "$work/src" "$work/out" "$work/target"
git archive "$sha" | tar -x -C "$work/src"
docker volume create onionwire-local-registry >/dev/null
docker run --rm \
-v "$work/src:/src:ro" \
-v onionwire-local-registry:/usr/local/cargo/registry \
-v "$work/target:/target" \
-v "$work/out:/out" \
-e SOURCE_DATE_EPOCH="$sde" \
-e BUILDER_IMAGE="$BUILDER_IMAGE" \
-e TARGET_TRIPLE="$target" \
-e GIT_SHA="$sha" \
-w /src \
"$BUILDER_IMAGE" \
bash scripts/reproducible-build.sh
mkdir -p dist
asset="onionwire-$target"
cp "target/release/onionwire" "dist/$asset"
strip "dist/$asset"
(cd dist && sha256sum "$asset" > "$asset.sha256" && sha256sum -c "$asset.sha256")
file "dist/$asset"
"dist/$asset" --version
cp "$work/out/onionwire-$target" \
"$work/out/onionwire-$target.sha256" \
"$work/out/build-info-$target.txt" \
dist/
file "dist/onionwire-$target"
"dist/onionwire-$target" --version
echo "==> signing (needs minisign on PATH and the committed public key)"
RELEASE_TAG="$tag" scripts/sign-release.sh \
"dist/onionwire-$target" "dist/onionwire-$target.sha256"
echo "==> publishing to the release for $tag"
scripts/publish-release.sh "$tag" "OnionWire $tag" scripts/release-body.md \
"dist/$asset" "dist/$asset.sha256"
"dist/onionwire-$target" \
"dist/onionwire-$target.sha256" \
"dist/onionwire-$target.minisig" \
"dist/onionwire-$target.sha256.minisig" \
"dist/build-info-$target.txt"