onionwire/scripts/build-release-local.sh

63 lines
No EOL
2.9 KiB
Shell
Executable file

#!/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.
#
# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.0
#
# Does not create or push the tag: the release workflow owns tagging. Idempotent
# (same-named assets are replaced). Never moves an existing tag.
set -euo pipefail
tag="${1:?usage: build-release-local.sh <tag>}"
target=x86_64-unknown-linux-gnu
root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$root"
# The bundled wallet RPC — the official Monero release binary for this target,
# not something built here (Monero's C++ tree is not part of this build). Both
# values are pinned and both are re-checked on every run: the tarball against
# getmonero's signed hashes.txt, then the extracted binary against its own
# sha256. Bump all four together with the workflow's pins; docs/WALLET.md is the
# provenance record.
monero_tarball=monero-linux-x64-v0.18.5.1.tar.bz2
monero_tarball_sha256=22a7dda7b0cb699fdd6b7674c3b4a4465b337cc98a54983523b759e1e7cc9958
monero_archive_dir=monero-x86_64-linux-gnu-v0.18.5.1
wallet_rpc_sha256=c1e3aff7c72837e6f29045c439b772a82b5cd7324c8b831fa825a6ce2019a656
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
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
echo "==> fetching $monero_tarball"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
curl -fsSL -o "$work/hashes.txt" https://www.getmonero.org/downloads/hashes.txt
grep -E "^$monero_tarball_sha256[[:space:]]+$monero_tarball$" "$work/hashes.txt" > /dev/null
echo "hashes.txt confirms $monero_tarball"
curl -fsSL -o "$work/monero.tar.bz2" "https://downloads.getmonero.org/cli/$monero_tarball"
echo "$monero_tarball_sha256 $work/monero.tar.bz2" | sha256sum -c -
tar xjf "$work/monero.tar.bz2" -C "$work" "$monero_archive_dir/monero-wallet-rpc"
mv "$work/$monero_archive_dir/monero-wallet-rpc" "$work/monero-wallet-rpc"
echo "$wallet_rpc_sha256 $work/monero-wallet-rpc" | sha256sum -c -
wasset="monero-wallet-rpc-$target"
cp "$work/monero-wallet-rpc" "dist/$wasset"
(cd dist && sha256sum "$wasset" > "$wasset.sha256" && sha256sum -c "$wasset.sha256")
file "dist/$wasset"
echo "==> publishing to the release for $tag"
scripts/publish-release.sh "$tag" "OnionWire $tag" scripts/release-body.md \
"dist/$asset" "dist/$asset.sha256" "dist/$wasset" "dist/$wasset.sha256"