ci(release): publish from the Pi; surface API 422s
Run 116 built both arches then POST /releases returned 422 six times (--retry-all-errors) with no body, while sitting on docker-amd64 behind android. Move publish to the Pi runner (same path as tag create) and print the Forgejo error instead of retrying 4xx. README now matches the core-only path filter and onionwire-ci-pi concurrency.
This commit is contained in:
parent
fecec6c29a
commit
9b7e72b257
3 changed files with 69 additions and 31 deletions
|
|
@ -294,8 +294,12 @@ jobs:
|
||||||
needs: [version, aarch64, x86_64]
|
needs: [version, aarch64, x86_64]
|
||||||
# Always run after version so cleanup can need this job without Forgejo
|
# Always run after version so cleanup can need this job without Forgejo
|
||||||
# act dying on "'runs-on' key not defined" for a skipped publish.
|
# act dying on "'runs-on' key not defined" for a skipped publish.
|
||||||
|
# Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and
|
||||||
|
# android-release sat in front of run 116's publish for ~1h; the Pi
|
||||||
|
# already created the tag over the public API (version job), so publish
|
||||||
|
# uses that same path. This job only curls the Forgejo API — no docker CLI.
|
||||||
if: always() && needs.version.result == 'success'
|
if: always() && needs.version.result == 'success'
|
||||||
runs-on: docker-amd64
|
runs-on: docker
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
steps:
|
steps:
|
||||||
- name: Skip publish on dry_run
|
- name: Skip publish on dry_run
|
||||||
|
|
|
||||||
13
README.md
13
README.md
|
|
@ -25,13 +25,13 @@ Arti onion services are still **experimental**. If the hidden service cannot com
|
||||||
|
|
||||||
### Option A — download a release binary
|
### Option A — download a release binary
|
||||||
|
|
||||||
CI (`.forgejo/workflows/release.yml`) tags and publishes both Linux binaries on every `main` push that touches the core (`src/`, `crates/`, `Cargo.toml`, `Cargo.lock`, or the release workflow/scripts). aarch64 builds on the Pi runner; x86_64 builds on the amd64 runner. Both attach to the same [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). `scripts/build-release-local.sh` remains the offline x86_64 fallback.
|
CI (`.forgejo/workflows/release.yml`) tags and publishes both Linux binaries on every `main` push that touches the core (`src/`, `crates/`, `Cargo.toml`, `Cargo.lock`, or `scripts/release-body.md`). Workflow-only edits do not mint a release — validate those with Actions → release → `dry_run=true`. aarch64 builds on the Pi runner; x86_64 builds on the amd64 runner. Both attach to the same [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). `scripts/build-release-local.sh` remains the offline x86_64 fallback. This Forgejo does not serve `/releases/latest/download/…` (404); pin the tag.
|
||||||
|
|
||||||
**x86_64 (most PCs / VMs):**
|
**x86_64 (most PCs / VMs):**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-x86_64-unknown-linux-gnu
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.1.0/onionwire-x86_64-unknown-linux-gnu
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-x86_64-unknown-linux-gnu.sha256
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.1.0/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||||
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
|
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
|
||||||
chmod +x onionwire-x86_64-unknown-linux-gnu
|
chmod +x onionwire-x86_64-unknown-linux-gnu
|
||||||
./onionwire-x86_64-unknown-linux-gnu --version
|
./onionwire-x86_64-unknown-linux-gnu --version
|
||||||
|
|
@ -40,8 +40,8 @@ chmod +x onionwire-x86_64-unknown-linux-gnu
|
||||||
**aarch64 (Raspberry Pi, ARM servers):**
|
**aarch64 (Raspberry Pi, ARM servers):**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-aarch64-unknown-linux-gnu
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.1.0/onionwire-aarch64-unknown-linux-gnu
|
||||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/latest/download/onionwire-aarch64-unknown-linux-gnu.sha256
|
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.1.0/onionwire-aarch64-unknown-linux-gnu.sha256
|
||||||
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
|
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
|
||||||
chmod +x onionwire-aarch64-unknown-linux-gnu
|
chmod +x onionwire-aarch64-unknown-linux-gnu
|
||||||
./onionwire-aarch64-unknown-linux-gnu --version
|
./onionwire-aarch64-unknown-linux-gnu --version
|
||||||
|
|
@ -274,6 +274,7 @@ Do not push tags by hand — a tag-push trigger would start a second run.
|
||||||
|
|
||||||
# rebuild / re-publish an existing tag, or dry-run a build with no tag:
|
# rebuild / re-publish an existing tag, or dry-run a build with no tag:
|
||||||
# Actions → release → Run workflow → tag=vX.Y.Z and/or dry_run=true
|
# Actions → release → Run workflow → tag=vX.Y.Z and/or dry_run=true
|
||||||
|
# (dry_run is how you test release.yml without cutting a user-facing release)
|
||||||
|
|
||||||
# offline x86_64 fallback (idempotent — safe to re-run)
|
# offline x86_64 fallback (idempotent — safe to re-run)
|
||||||
FORGEJO_TOKEN=<pat> scripts/build-release-local.sh vX.Y.Z
|
FORGEJO_TOKEN=<pat> scripts/build-release-local.sh vX.Y.Z
|
||||||
|
|
@ -282,7 +283,7 @@ FORGEJO_TOKEN=<pat> scripts/build-release-local.sh vX.Y.Z
|
||||||
Workflows (Forgejo Actions, `.forgejo/workflows/`):
|
Workflows (Forgejo Actions, `.forgejo/workflows/`):
|
||||||
|
|
||||||
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite. Pi runner, `docker` label.
|
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite. Pi runner, `docker` label.
|
||||||
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — on core paths to `main`: next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release. `workflow_dispatch` rebuilds a tag or `dry_run`s. Concurrency group `onionwire-release` (separate from CI).
|
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — on core paths to `main` (`src/`, `crates/`, `Cargo.toml`, `Cargo.lock`, `scripts/release-body.md`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release. `workflow_dispatch` rebuilds a tag or `dry_run`s. Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`.
|
||||||
|
|
||||||
Scripts:
|
Scripts:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,26 +12,38 @@
|
||||||
# same-named assets instead of failing with 409.
|
# same-named assets instead of failing with 409.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Every API call goes through here. Publishing runs from CI containers that
|
# HTTP/1.1: Cloudflare resets HTTP/2 mid-POST (curl 92). Do NOT use
|
||||||
# reach Forgejo through Cloudflare, where a bare HTTP/2 request intermittently
|
# --retry-all-errors: that retries 422 Unprocessable Entity five times
|
||||||
# dies with curl exit 92 (stream error) — retries plus forcing HTTP/1.1 make
|
# and hides the response body (run 116). Connection failures still retry.
|
||||||
# that a non-event.
|
|
||||||
api_curl() {
|
api_curl() {
|
||||||
curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \
|
curl -sS --http1.1 --retry 5 --retry-connrefused --retry-delay 3 \
|
||||||
--connect-timeout 20 --max-time 300 "$@"
|
--connect-timeout 20 --max-time 300 "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auth_json() {
|
||||||
|
api_curl -H "Authorization: Bearer ${FORGEJO_TOKEN}" -H "Content-Type: application/json" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
tag="${1:?usage: publish-release.sh <tag> <name> <body-file> <asset>...}"
|
tag="${1:?usage: publish-release.sh <tag> <name> <body-file> <asset>...}"
|
||||||
name="${2:?missing release name}"
|
name="${2:?missing release name}"
|
||||||
body_file="${3:?missing body file}"
|
body_file="${3:?missing body file}"
|
||||||
shift 3
|
shift 3
|
||||||
|
|
||||||
: "${FORGEJO_TOKEN:?FORGEJO_TOKEN is not set}"
|
: "${FORGEJO_TOKEN:?FORGEJO_TOKEN is not set}"
|
||||||
|
FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n')
|
||||||
api="${REPO_API:-https://forgejo.siriusdevops.com/api/v1/repos/sirius/onionwire}"
|
api="${REPO_API:-https://forgejo.siriusdevops.com/api/v1/repos/sirius/onionwire}"
|
||||||
target="${TARGET_COMMITISH:-}"
|
target="${TARGET_COMMITISH:-}"
|
||||||
|
|
||||||
jqp() { python3 -c "import json,sys; d=json.load(sys.stdin); print($1)"; }
|
jqp() { python3 -c "import json,sys; d=json.load(sys.stdin); print($1)"; }
|
||||||
|
|
||||||
|
die_http() {
|
||||||
|
local what="$1" code="$2" file="$3"
|
||||||
|
echo "publish: $what HTTP $code" >&2
|
||||||
|
cat "$file" >&2 || true
|
||||||
|
echo >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Body with @TAG@ substituted, JSON-encoded by python (handles newlines/quotes).
|
# Body with @TAG@ substituted, JSON-encoded by python (handles newlines/quotes).
|
||||||
python3 - "$body_file" "$tag" "$target" "$name" > /tmp/release-body.json <<'PY'
|
python3 - "$body_file" "$tag" "$target" "$name" > /tmp/release-body.json <<'PY'
|
||||||
import json, sys
|
import json, sys
|
||||||
|
|
@ -50,24 +62,37 @@ if sys.argv[3]:
|
||||||
print(json.dumps(payload))
|
print(json.dumps(payload))
|
||||||
PY
|
PY
|
||||||
|
|
||||||
code=$(api_curl -o /tmp/release-rel.json -w '%{http_code}' \
|
code=$(auth_json -o /tmp/release-rel.json -w '%{http_code}' \
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/tags/$tag")
|
"$api/releases/tags/$tag")
|
||||||
if [ "$code" = "404" ]; then
|
if [ "$code" = "404" ]; then
|
||||||
echo "publish: creating release $tag"
|
echo "publish: creating release $tag"
|
||||||
api_curl -sf -X POST "$api/releases" \
|
create=$(auth_json -o /tmp/release-rel.json -w '%{http_code}' \
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
-X POST --data-binary @/tmp/release-body.json "$api/releases")
|
||||||
-H 'Content-Type: application/json' \
|
if [ "$create" = "201" ]; then
|
||||||
--data @/tmp/release-body.json -o /tmp/release-rel.json
|
:
|
||||||
|
elif [ "$create" = "409" ] || [ "$create" = "422" ]; then
|
||||||
|
echo "publish: POST releases HTTP $create — joining if the release exists"
|
||||||
|
cat /tmp/release-rel.json >&2 || true
|
||||||
|
echo >&2
|
||||||
|
code=$(auth_json -o /tmp/release-rel.json -w '%{http_code}' \
|
||||||
|
"$api/releases/tags/$tag")
|
||||||
|
if [ "$code" != "200" ]; then
|
||||||
|
die_http "create release $tag (then GET)" "$code" /tmp/release-rel.json
|
||||||
|
fi
|
||||||
|
echo "publish: release $tag exists, joining"
|
||||||
|
else
|
||||||
|
die_http "create release $tag" "$create" /tmp/release-rel.json
|
||||||
|
fi
|
||||||
elif [ "$code" = "200" ]; then
|
elif [ "$code" = "200" ]; then
|
||||||
echo "publish: release $tag exists, updating"
|
echo "publish: release $tag exists, updating"
|
||||||
rid=$(jqp "d['id']" < /tmp/release-rel.json)
|
rid=$(jqp "d['id']" < /tmp/release-rel.json)
|
||||||
api_curl -sf -X PATCH "$api/releases/$rid" \
|
patch=$(auth_json -o /tmp/release-rel.json -w '%{http_code}' \
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
-X PATCH --data-binary @/tmp/release-body.json "$api/releases/$rid")
|
||||||
-H 'Content-Type: application/json' \
|
if [ "$patch" != "200" ]; then
|
||||||
--data @/tmp/release-body.json -o /tmp/release-rel.json
|
die_http "PATCH release $rid" "$patch" /tmp/release-rel.json
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "publish: unexpected status $code from GET releases/tags/$tag" >&2
|
die_http "GET releases/tags/$tag" "$code" /tmp/release-rel.json
|
||||||
cat /tmp/release-rel.json >&2; exit 1
|
|
||||||
fi
|
fi
|
||||||
rid=$(jqp "d['id']" < /tmp/release-rel.json)
|
rid=$(jqp "d['id']" < /tmp/release-rel.json)
|
||||||
echo "publish: release id $rid ($tag)"
|
echo "publish: release id $rid ($tag)"
|
||||||
|
|
@ -84,7 +109,7 @@ for f in "$@"; do
|
||||||
fi
|
fi
|
||||||
asset=$(basename "$f")
|
asset=$(basename "$f")
|
||||||
echo "publish: asset $asset is $bytes bytes on disk"
|
echo "publish: asset $asset is $bytes bytes on disk"
|
||||||
api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
api_curl -H "Authorization: Bearer ${FORGEJO_TOKEN}" "$api/releases/$rid/assets" \
|
||||||
| python3 -c "
|
| python3 -c "
|
||||||
import json,sys
|
import json,sys
|
||||||
for a in json.load(sys.stdin):
|
for a in json.load(sys.stdin):
|
||||||
|
|
@ -92,13 +117,21 @@ for a in json.load(sys.stdin):
|
||||||
" | while read -r aid aname; do
|
" | while read -r aid aname; do
|
||||||
if [ "$aname" = "$asset" ]; then
|
if [ "$aname" = "$asset" ]; then
|
||||||
echo "publish: deleting stale asset $aname ($aid)"
|
echo "publish: deleting stale asset $aname ($aid)"
|
||||||
api_curl -sf -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \
|
del=$(api_curl -o /tmp/release-adel.json -w '%{http_code}' \
|
||||||
"$api/releases/$rid/assets/$aid" > /dev/null
|
-X DELETE -H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||||
|
"$api/releases/$rid/assets/$aid")
|
||||||
|
if [ "$del" != "204" ] && [ "$del" != "404" ]; then
|
||||||
|
die_http "DELETE asset $aid" "$del" /tmp/release-adel.json
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
api_curl -sf -X POST "$api/releases/$rid/assets?name=$asset" \
|
up=$(api_curl -o /tmp/release-asset.json -w '%{http_code}' \
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
-X POST "$api/releases/$rid/assets?name=$asset" \
|
||||||
-F "attachment=@$f" -o /tmp/release-asset.json
|
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \
|
||||||
|
-F "attachment=@$f")
|
||||||
|
if [ "$up" != "201" ]; then
|
||||||
|
die_http "upload $asset" "$up" /tmp/release-asset.json
|
||||||
|
fi
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import json,sys
|
import json,sys
|
||||||
d=json.load(open('/tmp/release-asset.json'))
|
d=json.load(open('/tmp/release-asset.json'))
|
||||||
|
|
@ -109,7 +142,7 @@ if not size:
|
||||||
"
|
"
|
||||||
done
|
done
|
||||||
|
|
||||||
api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
api_curl -H "Authorization: Bearer ${FORGEJO_TOKEN}" "$api/releases/$rid/assets" \
|
||||||
| python3 -c "
|
| python3 -c "
|
||||||
import json,sys
|
import json,sys
|
||||||
for a in json.load(sys.stdin):
|
for a in json.load(sys.stdin):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue