From 111b95c3ae5aed64d36d862c467b89f84529915f Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Sat, 12 Sep 2026 00:52:46 -0400 Subject: [PATCH 1/2] ci(release): auto-tag and publish aarch64+x86_64 on main Drop the tag-push trigger so API-created tags cannot start a second run. Core paths on main (or workflow_dispatch) mint the next v*.*.* tag (v0.1.0 when none exist), build both arches in CI, and publish one release. dry_run builds without tagging. Fail closed on empty assets. --- .forgejo/workflows/release.yml | 345 ++++++++++++++++++++++++++++----- README.md | 30 ++- scripts/build-release-local.sh | 13 +- scripts/publish-release.sh | 9 +- scripts/release-body.md | 4 +- 5 files changed, 329 insertions(+), 72 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 881c867..17975ca 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -1,50 +1,157 @@ name: release -# Native aarch64 build on the Pi runner, published to the Forgejo release. -# x86_64 is NOT built here: there is no x86_64 runner on this instance — build -# it on an x86_64 host with scripts/build-release-local.sh (same release, same -# asset naming), or the release will carry aarch64 only. +# Auto-tag and publish both Linux binaries when core paths land on main. +# Tag-push is intentionally NOT a trigger: this workflow creates the tag via +# the API, and a tag-push hook would start a second run of the same release. +# Rebuild an existing tag (or dry-run a build) with workflow_dispatch. +# Version: latest v*.*.* tag → patch+1; zero tags → v0.1.0. on: push: - tags: - - "v*.*.*" + branches: [main] + paths: + - "src/**" + - "crates/**" + - "Cargo.toml" + - "Cargo.lock" + - ".forgejo/workflows/release.yml" + - "scripts/build-release-local.sh" + - "scripts/release-body.md" workflow_dispatch: inputs: tag: - description: Existing tag to (re)build and publish - required: true + description: Existing tag to (re)build and publish (empty = next version) + required: false + type: string + dry_run: + description: Build and checksum without creating a tag or publishing + required: false + type: boolean + default: false + +concurrency: + group: onionwire-release + cancel-in-progress: false env: CARGO_TERM_COLOR: never - TARGET: aarch64-unknown-linux-gnu - # Job steps run inside node:20-bullseye (the runner's docker label image) with - # the host docker socket mounted, so builds happen in a sibling rust container. RUST_IMAGE: rust:1.91-bookworm CARGO_REGISTRY_VOLUME: onionwire-cargo-registry - CARGO_TARGET_VOLUME: onionwire-target-aarch64 - BUILD_CONTAINER: onionwire-release-build-${{ github.run_id }} jobs: + version: + runs-on: docker + timeout-minutes: 10 + outputs: + tag: ${{ steps.plan.outputs.tag }} + sha: ${{ steps.plan.outputs.sha }} + dry_run: ${{ steps.plan.outputs.dry_run }} + created_tag: ${{ steps.plan.outputs.created_tag }} + steps: + - name: Plan version, create tag unless dry_run + id: plan + env: + FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} + EVENT_NAME: ${{ github.event_name }} + EVENT_SHA: ${{ github.sha }} + INPUT_TAG: ${{ github.event.inputs.tag }} + INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }} + run: | + set -euo pipefail + : "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is not set}" + dry_run=false + if [ "$EVENT_NAME" = "workflow_dispatch" ]; then + case "${INPUT_DRY_RUN:-false}" in + true|True|TRUE) dry_run=true ;; + esac + fi + + api_curl() { + curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \ + --connect-timeout 20 --max-time 60 "$@" + } + + input_tag="${INPUT_TAG:-}" + if [ -n "$input_tag" ]; then + code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ + -H "Authorization: Bearer $FORGEJO_TOKEN" \ + "$REPO_API/tags/$input_tag") + if [ "$code" != "200" ]; then + echo "dispatch tag $input_tag not found (HTTP $code)" >&2 + cat /tmp/tag.json >&2 || true + exit 1 + fi + sha=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])") + tag="$input_tag" + created=false + echo "re-publish existing tag $tag at $sha (dry_run=$dry_run)" + else + api_curl -H "Authorization: Bearer $FORGEJO_TOKEN" \ + "$REPO_API/tags?limit=50" -o /tmp/tags.json + tag=$(python3 -c "import json,re; tags=json.load(open('/tmp/tags.json')); assert isinstance(tags, list), tags; semver=[]; [semver.append((int(m[1]), int(m[2]), int(m[3]))) for t in tags for m in [re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', t.get('name') or '')] if m]; print('v0.1.0' if not semver else 'v%d.%d.%d' % (max(semver)[0], max(semver)[1], max(semver)[2] + 1))") + sha="$EVENT_SHA" + created=false + if [ "$dry_run" = "true" ]; then + echo "dry_run: would use $tag on $sha (no tag created)" + else + code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ + -H "Authorization: Bearer $FORGEJO_TOKEN" \ + "$REPO_API/tags/$tag") + if [ "$code" = "200" ]; then + existing=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])") + if [ "$existing" != "$sha" ]; then + echo "tag $tag exists on $existing, not moving from $sha" >&2 + exit 1 + fi + echo "tag $tag already exists on $sha — joining" + elif [ "$code" = "404" ]; then + python3 -c "import json,sys; json.dump({'tag_name':sys.argv[1],'target':sys.argv[2],'message':'OnionWire '+sys.argv[1]}, sys.stdout)" \ + "$tag" "$sha" > /tmp/tag-create.json + create_code=$(api_curl -o /tmp/tag-created.json -w '%{http_code}' \ + -X POST -H "Authorization: Bearer $FORGEJO_TOKEN" \ + -H "Content-Type: application/json" \ + --data @/tmp/tag-create.json \ + "$REPO_API/tags") + if [ "$create_code" = "201" ]; then + created=true + echo "created tag $tag on $sha" + elif [ "$create_code" = "409" ]; then + echo "tag $tag created concurrently — joining" + else + echo "creating tag $tag failed HTTP $create_code" >&2 + cat /tmp/tag-created.json >&2 || true + exit 1 + fi + else + echo "GET tags/$tag failed HTTP $code" >&2 + cat /tmp/tag.json >&2 || true + exit 1 + fi + fi + fi + + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "sha=$sha" >> "$GITHUB_OUTPUT" + echo "dry_run=$dry_run" >> "$GITHUB_OUTPUT" + echo "created_tag=$created" >> "$GITHUB_OUTPUT" + echo "plan: tag=$tag sha=$sha dry_run=$dry_run created_tag=$created" + aarch64: + needs: version runs-on: docker timeout-minutes: 120 + env: + TARGET: aarch64-unknown-linux-gnu + CARGO_TARGET_VOLUME: onionwire-target-aarch64 + BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-aarch64 steps: - - name: Checkout the source tag + - name: Checkout source uses: https://code.forgejo.org/actions/checkout@v4 with: - # A tag push builds that tag; a manual dispatch builds the tag the - # caller named (otherwise the binary version would not match the - # release it is attached to). - ref: ${{ github.event.inputs.tag || github.ref_name }} + ref: ${{ needs.version.outputs.sha }} - - name: Checkout the CI tooling - uses: https://code.forgejo.org/actions/checkout@v4 - with: - # scripts/ and .forgejo/ only exist on the branch (older tags predate - # them), and the workflow itself is read from the dispatched ref — so - # fetch the same ref into .ci-tools and run the scripts from there. - ref: ${{ github.ref_name }} - path: .ci-tools + - name: Show runner arch + run: uname -m && echo "target=$TARGET" - name: Build ${{ env.TARGET }} in a rust container run: | @@ -54,9 +161,6 @@ jobs: docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null docker volume create "$CARGO_TARGET_VOLUME" > /dev/null docker rm -f "$BUILD_CONTAINER" > /dev/null 2>&1 || true - # The workspace lives in a per-task volume the host daemon cannot - # resolve, so pipe the source tree in over stdin (tar) and pull the - # binary back out with docker cp. docker create --name "$BUILD_CONTAINER" -i \ -e CARGO_TARGET_DIR=/target \ -e CARGO_BUILD_JOBS=2 \ @@ -82,30 +186,179 @@ jobs: 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 - - name: Publish to the Forgejo release - env: - FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} - REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} - EVENT_NAME: ${{ github.event_name }} - EVENT_SHA: ${{ github.sha }} - REF: ${{ github.ref_name }} - INPUT_TAG: ${{ github.event.inputs.tag }} + - name: Upload dist artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: onionwire-aarch64-unknown-linux-gnu + path: dist/ + if-no-files-found: error + retention-days: 1 + + x86_64: + needs: version + runs-on: docker-amd64 + timeout-minutes: 120 + env: + TARGET: x86_64-unknown-linux-gnu + CARGO_TARGET_VOLUME: onionwire-target-x86_64 + BUILD_CONTAINER: onionwire-release-${{ github.run_id }}-x86_64 + steps: + - name: Checkout source + uses: https://code.forgejo.org/actions/checkout@v4 + with: + ref: ${{ needs.version.outputs.sha }} + + - name: Show runner arch + run: uname -m && echo "target=$TARGET" + + - name: Build ${{ env.TARGET }} in a rust container run: | set -euo pipefail cd "${GITHUB_WORKSPACE}" - echo "pwd=$PWD workspace=$GITHUB_WORKSPACE" - ls -l dist/ 2>&1 || true - for f in dist/*; do printf 'on disk: %s %s bytes\n' "$f" "$(wc -c < "$f")"; done - tag="${INPUT_TAG:-$REF}" - # Only a tag push may create the tag; a re-publish must not move it. - if [ "$EVENT_NAME" = "push" ]; then export TARGET_COMMITISH="$EVENT_SHA"; fi - echo "publishing $tag from $REPO_API (event=$EVENT_NAME)" + echo "workspace: $GITHUB_WORKSPACE" + docker volume create "$CARGO_REGISTRY_VOLUME" > /dev/null + 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 \ + -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 update \ + && apt-get install -y --no-install-recommends pkg-config libssl-dev \ + && cargo build --release --locked \ + && strip /target/release/onionwire \ + && ls -l /target/release/onionwire' + 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" + docker rm -f "$BUILD_CONTAINER" > /dev/null + + - name: Pack and checksum + 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 + + - name: Upload dist artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: onionwire-x86_64-unknown-linux-gnu + path: dist/ + if-no-files-found: error + retention-days: 1 + + publish: + needs: [version, aarch64, x86_64] + if: needs.version.outputs.dry_run != 'true' + runs-on: docker-amd64 + timeout-minutes: 20 + steps: + - name: Checkout CI tooling + uses: https://code.forgejo.org/actions/checkout@v4 + with: + path: .ci-tools + + - name: Download both arch artifacts + uses: https://code.forgejo.org/actions/download-artifact@v3 + with: + path: artifacts + + - name: Publish both binaries to one release + env: + FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} + TAG: ${{ needs.version.outputs.tag }} + run: | + set -euo pipefail + 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" + done + missing=0 + for f in \ + 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 + do + 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 + exit 1 + fi + echo "publishing $TAG from $REPO_API" .ci-tools/scripts/publish-release.sh \ - "$tag" "OnionWire $tag" \ + "$TAG" "OnionWire $TAG" \ .ci-tools/scripts/release-body.md \ - "dist/onionwire-$TARGET" "dist/onionwire-$TARGET.sha256" + 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 + + cleanup: + needs: [version, aarch64, x86_64, publish] + if: ${{ always() && needs.version.outputs.created_tag == 'true' && (needs.aarch64.result != 'success' || needs.x86_64.result != 'success' || needs.publish.result != 'success') }} + runs-on: docker + timeout-minutes: 10 + steps: + - name: Delete tag and incomplete release we created + env: + FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} + TAG: ${{ needs.version.outputs.tag }} + run: | + set -euo pipefail + echo "fail-closed: removing tag $TAG created by this run" + code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \ + -H "Authorization: Bearer $FORGEJO_TOKEN" \ + "$REPO_API/releases/tags/$TAG") + if [ "$code" = "200" ]; then + rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])") + echo "deleting incomplete release id $rid" + curl -sS --http1.1 -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \ + "$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n" + else + echo "no release for $TAG (HTTP $code)" + fi + curl -sS --http1.1 -X DELETE -H "Authorization: Bearer $FORGEJO_TOKEN" \ + "$REPO_API/tags/$TAG" -o /dev/null -w "DELETE tag HTTP %{http_code}\n" diff --git a/README.md b/README.md index 5221e76..562ec3e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Arti onion services are still **experimental**. If the hidden service cannot com ### Option A — download a release binary -CI (`.forgejo/workflows/release.yml`, Forgejo Actions on the Pi runner) builds the **aarch64** binary on every `v*.*.*` tag and attaches it to the [Forgejo release](https://forgejo.siriusdevops.com/sirius/onionwire/releases). There is no x86_64 runner on this instance, so the **x86_64** asset is built and uploaded by `scripts/build-release-local.sh` on an x86_64 host — both land on the same release page. +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. **x86_64 (most PCs / VMs):** @@ -262,29 +262,27 @@ Every asset has a matching `.sha256` so `sha256sum -c` works. The APK is ## Releases (maintainers) -Tags trigger Forgejo Actions on the self-hosted Pi runner. The x86_64 asset has -no runner on this instance, so it is built locally and attached to the same -release. +A core change on `main` is enough. The release workflow computes the next +`v*.*.*` tag (patch+1, or `v0.1.0` if there are no tags), creates it via the +API, builds aarch64 on the Pi runner and x86_64 on the amd64 runner, and +publishes all four assets (`onionwire-` + `.sha256`) to one release. +Do not push tags by hand — a tag-push trigger would start a second run. ```bash -# 1. version in Cargo.toml must match the tag without the leading v -cargo update --offline -p onionwire # keep Cargo.lock at the new version -git commit -am "chore: release vX.Y.Z" && git push origin main +# optional: keep Cargo.toml in sync with the tag the workflow will mint +# (the workflow does not edit Cargo.toml) -# 2. tag and push — the release workflow builds + publishes aarch64 -git tag -a vX.Y.Z -m "OnionWire vX.Y.Z" -git push origin vX.Y.Z +# 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 -# 3. attach x86_64 from an x86_64 host (idempotent — safe to re-run) +# offline x86_64 fallback (idempotent — safe to re-run) FORGEJO_TOKEN= scripts/build-release-local.sh vX.Y.Z ``` -Workflows (Forgejo Actions, `.forgejo/workflows/` — jobs run on the `docker` -label of the Pi runner and do their Rust work in a `rust:1.91-bookworm` -sibling container): +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 (ignored Tor-live tests are not run). -- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — on `v*.*.*` tags: builds `aarch64-unknown-linux-gnu` natively, strips, sha256, publishes to the release. Also runnable via `workflow_dispatch` with a tag input to re-publish. +- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` on `main` and PRs (ignored Tor-live tests are not run). 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). Scripts: diff --git a/scripts/build-release-local.sh b/scripts/build-release-local.sh index 4d1c7fc..7fdf0f1 100755 --- a/scripts/build-release-local.sh +++ b/scripts/build-release-local.sh @@ -1,12 +1,13 @@ #!/usr/bin/env bash -# Build the x86_64 release asset on this host and publish it to the Forgejo -# release for . CI (.forgejo/workflows/release.yml) only covers aarch64 — -# there is no x86_64 runner on the instance, so this is the x86_64 path. +# Offline fallback: build the x86_64 release asset on this host and publish it +# to the Forgejo release for . 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.2 +# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.0 # -# 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). +# 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 }" diff --git a/scripts/publish-release.sh b/scripts/publish-release.sh index 3368eec..cdfd65b 100755 --- a/scripts/publish-release.sh +++ b/scripts/publish-release.sh @@ -100,8 +100,13 @@ for a in json.load(sys.stdin): -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')" +import json,sys +d=json.load(open('/tmp/release-asset.json')) +name, size = d.get('name'), d.get('size') +print('publish: uploaded', name, size, 'bytes') +if not size: + sys.exit('publish: server stored 0-byte asset %s — refusing to continue' % (name,)) +" done api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \ diff --git a/scripts/release-body.md b/scripts/release-body.md index 25efd86..5651385 100644 --- a/scripts/release-body.md +++ b/scripts/release-body.md @@ -3,13 +3,13 @@ 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 +# aarch64 (Raspberry Pi, ARM servers) 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 +# x86_64 (most PCs / VMs) 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 -- 2.52.0 From 58e10a0bc01b46617320fc40d34c59a1e36e43d8 Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Sat, 12 Sep 2026 00:55:18 -0400 Subject: [PATCH 2/2] ci(release): honor dry_run input and send JSON Content-Type Forgejo dispatch passes string inputs; boolean dry_run stayed false and tried to mint v0.1.0. Strip PAT newlines so Authorization does not eat the next header (422 Empty Content-Type). --- .forgejo/workflows/release.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 17975ca..3b9f22a 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -23,10 +23,10 @@ on: required: false type: string dry_run: - description: Build and checksum without creating a tag or publishing + description: Build and checksum without creating a tag or publishing (true/false) required: false - type: boolean - default: false + type: string + default: "false" concurrency: group: onionwire-release @@ -59,22 +59,24 @@ jobs: run: | set -euo pipefail : "${FORGEJO_TOKEN:?FORGEJO_TOKEN secret is not set}" + FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n') dry_run=false if [ "$EVENT_NAME" = "workflow_dispatch" ]; then case "${INPUT_DRY_RUN:-false}" in - true|True|TRUE) dry_run=true ;; + true|True|TRUE|1|yes|YES) dry_run=true ;; esac fi + echo "event=$EVENT_NAME sha=$EVENT_SHA input_tag=${INPUT_TAG-} input_dry_run=${INPUT_DRY_RUN-} dry_run=$dry_run" api_curl() { curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \ - --connect-timeout 20 --max-time 60 "$@" + --connect-timeout 20 --max-time 60 \ + -H "Authorization: Bearer $FORGEJO_TOKEN" "$@" } input_tag="${INPUT_TAG:-}" if [ -n "$input_tag" ]; then code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ - -H "Authorization: Bearer $FORGEJO_TOKEN" \ "$REPO_API/tags/$input_tag") if [ "$code" != "200" ]; then echo "dispatch tag $input_tag not found (HTTP $code)" >&2 @@ -86,8 +88,7 @@ jobs: created=false echo "re-publish existing tag $tag at $sha (dry_run=$dry_run)" else - api_curl -H "Authorization: Bearer $FORGEJO_TOKEN" \ - "$REPO_API/tags?limit=50" -o /tmp/tags.json + api_curl "$REPO_API/tags?limit=50" -o /tmp/tags.json tag=$(python3 -c "import json,re; tags=json.load(open('/tmp/tags.json')); assert isinstance(tags, list), tags; semver=[]; [semver.append((int(m[1]), int(m[2]), int(m[3]))) for t in tags for m in [re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', t.get('name') or '')] if m]; print('v0.1.0' if not semver else 'v%d.%d.%d' % (max(semver)[0], max(semver)[1], max(semver)[2] + 1))") sha="$EVENT_SHA" created=false @@ -95,7 +96,6 @@ jobs: echo "dry_run: would use $tag on $sha (no tag created)" else code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \ - -H "Authorization: Bearer $FORGEJO_TOKEN" \ "$REPO_API/tags/$tag") if [ "$code" = "200" ]; then existing=$(python3 -c "import json; print(json.load(open('/tmp/tag.json'))['commit']['sha'])") @@ -107,10 +107,10 @@ jobs: elif [ "$code" = "404" ]; then python3 -c "import json,sys; json.dump({'tag_name':sys.argv[1],'target':sys.argv[2],'message':'OnionWire '+sys.argv[1]}, sys.stdout)" \ "$tag" "$sha" > /tmp/tag-create.json + echo "tag-create payload $(wc -c < /tmp/tag-create.json) bytes" create_code=$(api_curl -o /tmp/tag-created.json -w '%{http_code}' \ - -X POST -H "Authorization: Bearer $FORGEJO_TOKEN" \ - -H "Content-Type: application/json" \ - --data @/tmp/tag-create.json \ + -X POST -H "Content-Type: application/json" \ + --data-binary @/tmp/tag-create.json \ "$REPO_API/tags") if [ "$create_code" = "201" ]; then created=true -- 2.52.0