The GitHub workflows could never run on this instance: jobs asked for ubuntu-24.04 runners (the Pi runner only registers the 'docker' label, so every job sat in waiting), and release.yml published to github.com, which is not a remote of this repo. - .forgejo/workflows/ci.yml — cargo test + clippy on the 'docker' label, Rust work in a rust:1.87-bookworm sibling container (aarch64 native) - .forgejo/workflows/release.yml — on v*.*.* tags, build aarch64, strip, sha256, publish to the Forgejo release; workflow_dispatch takes a tag to re-publish - scripts/publish-release.sh — idempotent create-or-update release + asset upload via the Forgejo API (replaces same-named assets) - scripts/build-release-local.sh — x86_64 path (no x86_64 runner exists) - scripts/release-body.md — release notes template (@TAG@ substituted) - README: install URLs -> Forgejo, accurate maintainer release procedure - remove .github/workflows/*
This commit is contained in:
parent
b9f2dc3806
commit
91fd9601b8
11 changed files with 318 additions and 139 deletions
35
scripts/build-release-local.sh
Executable file
35
scripts/build-release-local.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# Build the x86_64 release asset on this host and publish it to the Forgejo
|
||||
# release for <tag>. CI (.forgejo/workflows/release.yml) only covers aarch64 —
|
||||
# there is no x86_64 runner on the instance, so this is the x86_64 path.
|
||||
#
|
||||
# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.2
|
||||
#
|
||||
# Does not create or push the tag: tag and push first, then run this so the
|
||||
# release body/asset set matches a real tag. Idempotent (assets are replaced).
|
||||
set -euo pipefail
|
||||
|
||||
tag="${1:?usage: build-release-local.sh <tag>}"
|
||||
target=x86_64-unknown-linux-gnu
|
||||
root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$root"
|
||||
|
||||
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 "==> publishing to the release for $tag"
|
||||
scripts/publish-release.sh "$tag" "OnionWire $tag" scripts/release-body.md \
|
||||
"dist/$asset" "dist/$asset.sha256"
|
||||
88
scripts/publish-release.sh
Executable file
88
scripts/publish-release.sh
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env bash
|
||||
# Create-or-update a Forgejo release and (re)upload its assets.
|
||||
#
|
||||
# Usage: publish-release.sh <tag> <release-name> <body-file> <asset> [<asset>...]
|
||||
# Env: FORGEJO_TOKEN user PAT with repo write (required)
|
||||
# REPO_API default https://forgejo.siriusdevops.com/api/v1/repos/sirius/onionwire
|
||||
# TARGET_COMMITISH default: push-triggered commit (CI) else "main"
|
||||
#
|
||||
# Idempotent: re-running for the same tag reuses the release and replaces
|
||||
# same-named assets instead of failing with 409.
|
||||
set -euo pipefail
|
||||
|
||||
tag="${1:?usage: publish-release.sh <tag> <name> <body-file> <asset>...}"
|
||||
name="${2:?missing release name}"
|
||||
body_file="${3:?missing body file}"
|
||||
shift 3
|
||||
|
||||
: "${FORGEJO_TOKEN:?FORGEJO_TOKEN is not set}"
|
||||
api="${REPO_API:-https://forgejo.siriusdevops.com/api/v1/repos/sirius/onionwire}"
|
||||
target="${TARGET_COMMITISH:-main}"
|
||||
|
||||
jqp() { python3 -c "import json,sys; d=json.load(sys.stdin); print($1)"; }
|
||||
|
||||
# Body with @TAG@ substituted, JSON-encoded by python (handles newlines/quotes).
|
||||
python3 - "$body_file" "$tag" "$target" "$name" > /tmp/release-body.json <<'PY'
|
||||
import json, sys
|
||||
body = open(sys.argv[1]).read().replace("@TAG@", sys.argv[2])
|
||||
print(json.dumps({
|
||||
"tag_name": sys.argv[2],
|
||||
"target_commitish": sys.argv[3],
|
||||
"name": sys.argv[4],
|
||||
"body": body,
|
||||
"draft": False,
|
||||
"prerelease": False,
|
||||
}))
|
||||
PY
|
||||
|
||||
code=$(curl -s -o /tmp/release-rel.json -w '%{http_code}' \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/tags/$tag")
|
||||
if [ "$code" = "404" ]; then
|
||||
echo "publish: creating release $tag"
|
||||
curl -sf -X POST "$api/releases" \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data @/tmp/release-body.json -o /tmp/release-rel.json
|
||||
elif [ "$code" = "200" ]; then
|
||||
echo "publish: release $tag exists, updating"
|
||||
rid=$(jqp "d['id']" < /tmp/release-rel.json)
|
||||
curl -sf -X PATCH "$api/releases/$rid" \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data @/tmp/release-body.json -o /tmp/release-rel.json
|
||||
else
|
||||
echo "publish: unexpected status $code from GET releases/tags/$tag" >&2
|
||||
cat /tmp/release-rel.json >&2; exit 1
|
||||
fi
|
||||
rid=$(jqp "d['id']" < /tmp/release-rel.json)
|
||||
echo "publish: release id $rid ($tag)"
|
||||
|
||||
# Replace same-named assets so re-runs are clean.
|
||||
for f in "$@"; do
|
||||
[ -f "$f" ] || { echo "publish: missing asset $f" >&2; exit 1; }
|
||||
asset=$(basename "$f")
|
||||
curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
||||
| python3 -c "
|
||||
import json,sys
|
||||
for a in json.load(sys.stdin):
|
||||
print(a['id'], a.get('name',''))
|
||||
" | while read -r aid aname; do
|
||||
if [ "$aname" = "$asset" ]; then
|
||||
echo "publish: deleting stale asset $aname ($aid)"
|
||||
curl -sf -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
"$api/releases/$rid/assets/$aid" > /dev/null
|
||||
fi
|
||||
done
|
||||
curl -sf -X POST "$api/releases/$rid/assets?name=$asset" \
|
||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||
-F "attachment=@$f" -o /tmp/release-asset.json
|
||||
python3 -c "
|
||||
import json;d=json.load(open('/tmp/release-asset.json'))
|
||||
print('publish: uploaded', d['name'], d['size'], 'bytes')"
|
||||
done
|
||||
|
||||
curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
||||
| python3 -c "
|
||||
import json,sys
|
||||
for a in json.load(sys.stdin):
|
||||
print('publish: asset ', a['name'], a['size'])"
|
||||
24
scripts/release-body.md
Normal file
24
scripts/release-body.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# OnionWire @TAG@
|
||||
|
||||
Prebuilt Linux binaries. No `tor` package required — Arti runs in-process.
|
||||
|
||||
```bash
|
||||
# aarch64 (Raspberry Pi, ARM servers) — CI builds this one on the Pi runner
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu.sha256
|
||||
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
|
||||
chmod +x onionwire-aarch64-unknown-linux-gnu
|
||||
|
||||
# x86_64 (most PCs / VMs) — built locally with scripts/build-release-local.sh
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
chmod +x onionwire-x86_64-unknown-linux-gnu
|
||||
|
||||
./onionwire-<target> --version
|
||||
```
|
||||
|
||||
Keep the asset filenames so `sha256sum -c` matches. Both binaries link OpenSSL 3
|
||||
dynamically (`libssl.so.3`), which is standard on Debian 12+/Ubuntu 24.04+.
|
||||
|
||||
Building from source is covered in the README install guide.
|
||||
Loading…
Reference in a new issue