release: reproducible builds, and sign every asset
"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:
parent
1031092192
commit
601f640f78
11 changed files with 962 additions and 76 deletions
|
|
@ -47,7 +47,18 @@ env:
|
|||
CARGO_TERM_COLOR: never
|
||||
# Same floor as ci.yml: the release binary has `cuprate-daemon` on by default,
|
||||
# and `tapes` does not build on 1.91 (`VecDeque::pop_front_if`, stable in 1.93).
|
||||
RUST_IMAGE: rust:1.98-bookworm
|
||||
# Pinned by DIGEST, not by tag. `rust:1.98-bookworm` floats: a rustc patch
|
||||
# release changes codegen and therefore every published hash — which turns a
|
||||
# routine toolchain bump into an unexplainable reproducibility mismatch for
|
||||
# anyone verifying an old release. rustc in this digest is 1.98.1
|
||||
# (48a229cea), LLVM 21.1.2, host x86_64-unknown-linux-gnu. 1.98 is the floor
|
||||
# for the default feature set (see Cargo.toml rust-version).
|
||||
#
|
||||
# This digest IS the release recipe, and it must match BUILDER_IMAGE in
|
||||
# scripts/verify-reproducible.sh and scripts/build-release-local.sh. If they
|
||||
# disagree, a verifier rebuilds with a different toolchain than CI shipped and
|
||||
# reports a false mismatch. Bump all of them in one commit — docs/VERIFY.md.
|
||||
RUST_IMAGE: rust@sha256:93ce27a88655056a51dbdd8f5f2d7ddc071c7b0070fb288a37b5a285fc83971e
|
||||
# Not baking pkg-config/libssl-dev into a custom image on this card —
|
||||
# dind PVC would make that the durable fix for the apt loop. Filed separately.
|
||||
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
||||
|
|
@ -191,7 +202,10 @@ jobs:
|
|||
timeout-minutes: 120
|
||||
env:
|
||||
TARGET: aarch64-unknown-linux-gnu
|
||||
CARGO_TARGET_VOLUME: onionwire-target-aarch64
|
||||
# Per-run, and removed at the end of the job: a reused target dir lets the
|
||||
# published binary come out of cached artifacts, which is precisely what a
|
||||
# verifier rebuilding from an empty directory cannot reproduce.
|
||||
CARGO_TARGET_VOLUME: onionwire-target-release-${{ github.run_id }}-aarch64
|
||||
BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-aarch64
|
||||
steps:
|
||||
- name: Checkout source
|
||||
|
|
@ -202,48 +216,76 @@ jobs:
|
|||
- name: Show runner arch
|
||||
run: uname -m && echo "target=$TARGET"
|
||||
|
||||
- name: Build ${{ env.TARGET }} in a rust container
|
||||
- name: Resolve SOURCE_DATE_EPOCH from the released commit
|
||||
id: epoch
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
# The released commit's committer time, not "now". A rebuild of this
|
||||
# tag in six months has to hand the compiler the same epoch CI handed
|
||||
# it, or the two builds cannot match and every verification is noise.
|
||||
epoch=$(git log -1 --format=%ct "${{ needs.version.outputs.sha }}")
|
||||
case "$epoch" in
|
||||
''|*[!0-9]*) echo "could not read a commit time for ${{ needs.version.outputs.sha }}" >&2; exit 1 ;;
|
||||
esac
|
||||
echo "epoch=$epoch" >> "$GITHUB_OUTPUT"
|
||||
echo "SOURCE_DATE_EPOCH=$epoch"
|
||||
|
||||
- name: Build ${{ env.TARGET }} in the pinned rust container
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ steps.epoch.outputs.epoch }}
|
||||
RELEASE_SHA: ${{ needs.version.outputs.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
echo "workspace: $GITHUB_WORKSPACE"
|
||||
docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null
|
||||
# Fresh per run (see the job env): the published artifact has to be
|
||||
# reproducible from an empty target dir, so it is not allowed to come
|
||||
# out of a cache that a verifier does not have.
|
||||
docker volume create "$CARGO_TARGET_VOLUME" > /dev/null
|
||||
docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true
|
||||
docker create --name "$BUILD_CONTAINER" -i \
|
||||
-e CARGO_TARGET_DIR=/target \
|
||||
-e CARGO_BUILD_JOBS=2 \
|
||||
-e CARGO_TERM_COLOR=never \
|
||||
-e SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
|
||||
-e BUILDER_IMAGE="$RUST_IMAGE" \
|
||||
-e TARGET_TRIPLE="$TARGET" \
|
||||
-e GIT_SHA="$RELEASE_SHA" \
|
||||
-e OUT=/out \
|
||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||
-v "$CARGO_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true update \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev cmake build-essential \
|
||||
&& cargo build --release --locked \
|
||||
&& strip /target/release/onionwire \
|
||||
&& ls -l /target/release/onionwire'
|
||||
sh -euxc 'mkdir -p /src /out && tar xzf - -C /src && cd /src && bash /src/scripts/reproducible-build.sh'
|
||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \
|
||||
--exclude=./.ci-tools . \
|
||||
| docker start -a -i "$BUILD_CONTAINER"
|
||||
mkdir -p dist
|
||||
docker cp "$BUILD_CONTAINER:/target/release/onionwire" "dist/onionwire-$TARGET"
|
||||
# The recipe writes the stripped binary, its .sha256 and the build-info
|
||||
# record into /out, and installs its own apt build deps — the caller
|
||||
# supplies only the source tree and the pinned epoch.
|
||||
docker cp "$BUILD_CONTAINER:/out/." dist/
|
||||
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
||||
docker volume rm "$CARGO_TARGET_VOLUME" > /dev/null
|
||||
|
||||
- name: Pack and checksum
|
||||
- name: Verify the recipe's dist output
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}/dist"
|
||||
bytes=$(wc -c < "onionwire-$TARGET")
|
||||
if [ "$bytes" -eq 0 ]; then
|
||||
echo "refusing empty binary onionwire-$TARGET" >&2
|
||||
exit 1
|
||||
fi
|
||||
file "onionwire-$TARGET"
|
||||
sha256sum "onionwire-$TARGET" > "onionwire-$TARGET.sha256"
|
||||
sha256sum -c "onionwire-$TARGET.sha256"
|
||||
ls -l
|
||||
# scripts/reproducible-build.sh owns the checksum and the build-info
|
||||
# record. This step only refuses to hand a half-made dist to publish.
|
||||
for f in "onionwire-$TARGET" "onionwire-$TARGET.sha256" "build-info-$TARGET.txt"; do
|
||||
if [ ! -s "$f" ]; then
|
||||
echo "missing or empty dist asset: $f" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
sha256sum -c "onionwire-$TARGET.sha256"
|
||||
file "onionwire-$TARGET"
|
||||
cat "build-info-$TARGET.txt"
|
||||
|
||||
- name: Upload dist artifact
|
||||
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
||||
|
|
@ -259,7 +301,10 @@ jobs:
|
|||
timeout-minutes: 120
|
||||
env:
|
||||
TARGET: x86_64-unknown-linux-gnu
|
||||
CARGO_TARGET_VOLUME: onionwire-target-x86_64
|
||||
# Per-run, and removed at the end of the job: a reused target dir lets the
|
||||
# published binary come out of cached artifacts, which is precisely what a
|
||||
# verifier rebuilding from an empty directory cannot reproduce.
|
||||
CARGO_TARGET_VOLUME: onionwire-target-release-${{ github.run_id }}-x86_64
|
||||
BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-x86_64
|
||||
steps:
|
||||
- name: Checkout source
|
||||
|
|
@ -285,48 +330,76 @@ jobs:
|
|||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build ${{ env.TARGET }} in a rust container
|
||||
- name: Resolve SOURCE_DATE_EPOCH from the released commit
|
||||
id: epoch
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
# The released commit's committer time, not "now". A rebuild of this
|
||||
# tag in six months has to hand the compiler the same epoch CI handed
|
||||
# it, or the two builds cannot match and every verification is noise.
|
||||
epoch=$(git log -1 --format=%ct "${{ needs.version.outputs.sha }}")
|
||||
case "$epoch" in
|
||||
''|*[!0-9]*) echo "could not read a commit time for ${{ needs.version.outputs.sha }}" >&2; exit 1 ;;
|
||||
esac
|
||||
echo "epoch=$epoch" >> "$GITHUB_OUTPUT"
|
||||
echo "SOURCE_DATE_EPOCH=$epoch"
|
||||
|
||||
- name: Build ${{ env.TARGET }} in the pinned rust container
|
||||
env:
|
||||
SOURCE_DATE_EPOCH: ${{ steps.epoch.outputs.epoch }}
|
||||
RELEASE_SHA: ${{ needs.version.outputs.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
echo "workspace: $GITHUB_WORKSPACE"
|
||||
docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null
|
||||
# Fresh per run (see the job env): the published artifact has to be
|
||||
# reproducible from an empty target dir, so it is not allowed to come
|
||||
# out of a cache that a verifier does not have.
|
||||
docker volume create "$CARGO_TARGET_VOLUME" > /dev/null
|
||||
docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true
|
||||
docker create --name "$BUILD_CONTAINER" -i \
|
||||
-e CARGO_TARGET_DIR=/target \
|
||||
-e CARGO_BUILD_JOBS=2 \
|
||||
-e CARGO_TERM_COLOR=never \
|
||||
-e SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
|
||||
-e BUILDER_IMAGE="$RUST_IMAGE" \
|
||||
-e TARGET_TRIPLE="$TARGET" \
|
||||
-e GIT_SHA="$RELEASE_SHA" \
|
||||
-e OUT=/out \
|
||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||
-v "$CARGO_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true update \
|
||||
&& apt-get -o Acquire::Retries=5 -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::ForceIPv4=true install -y --no-install-recommends pkg-config libssl-dev cmake build-essential \
|
||||
&& cargo build --release --locked \
|
||||
&& strip /target/release/onionwire \
|
||||
&& ls -l /target/release/onionwire'
|
||||
sh -euxc 'mkdir -p /src /out && tar xzf - -C /src && cd /src && bash /src/scripts/reproducible-build.sh'
|
||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees \
|
||||
--exclude=./.ci-tools . \
|
||||
| docker start -a -i "$BUILD_CONTAINER"
|
||||
mkdir -p dist
|
||||
docker cp "$BUILD_CONTAINER:/target/release/onionwire" "dist/onionwire-$TARGET"
|
||||
# The recipe writes the stripped binary, its .sha256 and the build-info
|
||||
# record into /out, and installs its own apt build deps — the caller
|
||||
# supplies only the source tree and the pinned epoch.
|
||||
docker cp "$BUILD_CONTAINER:/out/." dist/
|
||||
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
||||
docker volume rm "$CARGO_TARGET_VOLUME" > /dev/null
|
||||
|
||||
- name: Pack and checksum
|
||||
- name: Verify the recipe's dist output
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}/dist"
|
||||
bytes=$(wc -c < "onionwire-$TARGET")
|
||||
if [ "$bytes" -eq 0 ]; then
|
||||
echo "refusing empty binary onionwire-$TARGET" >&2
|
||||
exit 1
|
||||
fi
|
||||
file "onionwire-$TARGET"
|
||||
sha256sum "onionwire-$TARGET" > "onionwire-$TARGET.sha256"
|
||||
sha256sum -c "onionwire-$TARGET.sha256"
|
||||
ls -l
|
||||
# scripts/reproducible-build.sh owns the checksum and the build-info
|
||||
# record. This step only refuses to hand a half-made dist to publish.
|
||||
for f in "onionwire-$TARGET" "onionwire-$TARGET.sha256" "build-info-$TARGET.txt"; do
|
||||
if [ ! -s "$f" ]; then
|
||||
echo "missing or empty dist asset: $f" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
sha256sum -c "onionwire-$TARGET.sha256"
|
||||
file "onionwire-$TARGET"
|
||||
cat "build-info-$TARGET.txt"
|
||||
|
||||
- name: Upload dist artifact
|
||||
uses: https://code.forgejo.org/actions/upload-artifact@v3
|
||||
|
|
@ -373,6 +446,41 @@ jobs:
|
|||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Sign the release assets (minisign, fail closed)
|
||||
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
|
||||
env:
|
||||
MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }}
|
||||
RELEASE_TAG: ${{ needs.version.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Signing runs BEFORE publish on purpose. A run without the key stops
|
||||
# here, so nothing unsigned ever reaches the release page: an unsigned
|
||||
# release is indistinguishable from a signed one to anyone who is not
|
||||
# checking, which makes it worse than no release at all.
|
||||
if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then
|
||||
echo "MINISIGN_SECRET_KEY is not set — add it in Settings -> Actions -> Secrets." >&2
|
||||
echo "See docs/VERIFY.md, \"Maintainer: the signing key\"." >&2
|
||||
exit 1
|
||||
fi
|
||||
# minisign comes from the same pinned image the builds used, so our
|
||||
# signature and the verifier's check are the same implementation.
|
||||
docker run --rm \
|
||||
-v "${GITHUB_WORKSPACE}:/work" \
|
||||
-e MINISIGN_SECRET_KEY \
|
||||
-e RELEASE_TAG \
|
||||
-w /work \
|
||||
"$RUST_IMAGE" \
|
||||
bash -c 'apt-get update -qq && apt-get install -y -qq --no-install-recommends minisign >/dev/null \
|
||||
&& bash .ci-tools/scripts/sign-release.sh \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256'
|
||||
# The public key ships as an asset too, so a verifier can get it from
|
||||
# the release; getting it from the repo instead is stronger, and
|
||||
# docs/VERIFY.md says so.
|
||||
cp .ci-tools/scripts/onionwire-signing.pub dist/onionwire-signing.pub
|
||||
|
||||
- name: Publish both binaries to one release
|
||||
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
|
||||
env:
|
||||
|
|
@ -384,29 +492,37 @@ jobs:
|
|||
mkdir -p dist
|
||||
find artifacts -type f -print
|
||||
for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
|
||||
src=$(find artifacts -type f -name "onionwire-$target" -print -quit)
|
||||
sum=$(find artifacts -type f -name "onionwire-$target.sha256" -print -quit)
|
||||
if [ -z "$src" ] || [ -z "$sum" ]; then
|
||||
echo "missing artifact for $target" >&2
|
||||
find artifacts -type f >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
cp "$src" "dist/onionwire-$target"
|
||||
cp "$sum" "dist/onionwire-$target.sha256"
|
||||
for name in "onionwire-$target" "onionwire-$target.sha256" "build-info-$target.txt"; do
|
||||
src=$(find artifacts -type f -name "$name" -print -quit)
|
||||
if [ -z "$src" ]; then
|
||||
echo "missing artifact: $name" >&2
|
||||
find artifacts -type f >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
cp "$src" "dist/$name"
|
||||
done
|
||||
done
|
||||
missing=0
|
||||
for f in \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.minisig \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \
|
||||
dist/build-info-aarch64-unknown-linux-gnu.txt \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256 \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.minisig \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig \
|
||||
dist/build-info-x86_64-unknown-linux-gnu.txt \
|
||||
dist/onionwire-signing.pub
|
||||
do
|
||||
if [ ! -s "$f" ]; then
|
||||
echo "refusing to publish missing or empty asset $f" >&2
|
||||
missing=1
|
||||
continue
|
||||
fi
|
||||
bytes=$(wc -c < "$f")
|
||||
echo "on disk: $f $bytes bytes"
|
||||
if [ "$bytes" -eq 0 ]; then
|
||||
echo "refusing empty asset $f" >&2
|
||||
missing=1
|
||||
fi
|
||||
file "$f" || true
|
||||
done
|
||||
if [ "$missing" -ne 0 ]; then
|
||||
|
|
@ -418,8 +534,15 @@ jobs:
|
|||
.ci-tools/scripts/release-body.md \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.minisig \
|
||||
dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \
|
||||
dist/build-info-aarch64-unknown-linux-gnu.txt \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256 \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.minisig \
|
||||
dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig \
|
||||
dist/build-info-x86_64-unknown-linux-gnu.txt \
|
||||
dist/onionwire-signing.pub
|
||||
|
||||
- name: Delete tag we created if this job failed
|
||||
if: failure() && needs.version.outputs.created_tag == 'true' && needs.version.outputs.dry_run != 'true'
|
||||
|
|
|
|||
Loading…
Reference in a new issue