From 2cf055c1e8eef3fa34053ee9f824f011a550c24a Mon Sep 17 00:00:00 2001 From: sirius Date: Sat, 12 Sep 2026 18:55:58 -0400 Subject: [PATCH] ci(release): android-release is dispatch-only; a CI-created tag cannot wake it Neither decoupled trigger fires on Forgejo 10.0.3: a tag created by the CI (API or git push) is an Actions-user push and is not dispatched back into Actions, and reusable workflows need Forgejo >= 12. The release procedure is therefore two dispatches: release.yml, then android-release with that tag. --- .forgejo/workflows/android-release.yml | 20 +++++++----- .forgejo/workflows/release.yml | 41 +++++++++++------------- README.md | 14 +++++--- docs/RELEASING.md | 44 ++++++++++++++++++-------- 4 files changed, 71 insertions(+), 48 deletions(-) diff --git a/.forgejo/workflows/android-release.yml b/.forgejo/workflows/android-release.yml index 0307826..8b93cd0 100644 --- a/.forgejo/workflows/android-release.yml +++ b/.forgejo/workflows/android-release.yml @@ -15,16 +15,20 @@ name: android-release # latest v*.*.* tag UNLESS that tag's release is missing the Android assets — # then join it (core owns tag creation). Never move or delete a tag. # -# No `push: branches: [main]` trigger: a merged android PR does not publish an -# APK. This workflow is woken by the tag release.yml creates for a manual, -# batched release — creating a tag over the API sends the same push -# notification a `git push` does, so the tag ref matches this filter. -# See docs/RELEASING.md. +# No automatic trigger, on purpose. Two candidate decoupled triggers were +# tried and both dead-end on Forgejo 10.0.3 (see docs/RELEASING.md): +# - `push: tags: ['v*.*.*']` — a tag created by release.yml (API or git push) +# does not fire it: pushes made with the CI's token are Actions-user events +# and Forgejo deliberately does not dispatch those back into Actions. +# Verified: the v0.2.0 and v0.2.1 tags produced no run, while hand-pushed +# tags did historically. +# - `workflow_call` from release.yml — reusable workflows only exist from +# Forgejo 12; this instance is 10.0.3. +# So a release is two dispatches: release.yml, then this one with `tag=`. The core's run leaves the tag; this attaches +# the APK + AAR to it. on: - push: - tags: - - "v*.*.*" workflow_dispatch: inputs: tag: diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index c6a7803..c4b13d0 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -4,10 +4,10 @@ name: release # PR does not mint a release. A maintainer dispatches this at a stopping point # (a batch of work has landed and CI is green on main) — see docs/RELEASING.md. # Tag-push is intentionally NOT a trigger here: this workflow creates the tag -# itself and a tag-push hook would start a second run of the same release. -# The tag is created with a real `git push` (not POST /tags) precisely so that -# android-release.yml's `push: tags` trigger fires and the APK + AAR join the -# same release — an API-created tag sends no push event on this Forgejo. +# via the API, and a tag-push hook would start a second run of the same release. +# (A tag this workflow creates does not wake android-release.yml either — see +# docs/RELEASING.md: on this Forgejo, pushes made with the CI token are +# Actions-user events and are not dispatched back into Actions.) # Version: explicit `version`, else `bump` off the newest v*.*.* tag # (default minor — a batched release is usually a feature set); zero tags → v0.1.0. on: @@ -60,15 +60,11 @@ jobs: dry_run: ${{ steps.plan.outputs.dry_run }} created_tag: ${{ steps.plan.outputs.created_tag }} steps: - - name: Checkout source (needed to create the tag) - uses: https://code.forgejo.org/actions/checkout@v4 - - 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 }} - GIT_URL: ${{ github.server_url }}/${{ github.repository }}.git EVENT_NAME: ${{ github.event_name }} EVENT_SHA: ${{ github.sha }} INPUT_BUMP: ${{ github.event.inputs.bump }} @@ -156,22 +152,23 @@ jobs: fi echo "tag $tag already exists on $sha — joining" elif [ "$code" = "404" ]; then - # Create the tag with a real `git push`, not POST /tags. - # A tag pushed by git fires the `push: tags: v*.*.*` trigger - # that android-release.yml listens on; a tag created through - # the API does not (verified on this instance: the v0.2.0 tag - # created by POST /tags produced no android-release run). - git config user.name "onionwire-ci" - git config user.email "onionwire-ci@localhost" - git tag -a "$tag" "$sha" -m "OnionWire $tag" - push_url="https://sirius:${FORGEJO_TOKEN}@${GIT_URL#https://}" - if ! git push "$push_url" "refs/tags/$tag" 2>&1 \ - | sed "s|${FORGEJO_TOKEN}|***|g"; then - echo "creating tag $tag on $sha failed" >&2 + 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 "Content-Type: application/json" \ + --data-binary @/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 - created=true - echo "created tag $tag on $sha (git push)" else echo "GET tags/$tag failed HTTP $code" >&2 cat /tmp/tag.json >&2 || true diff --git a/README.md b/README.md index 9e33521..c873d2e 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,10 @@ rationale, the 16 KB page-size check and the signing story are in Releases are **manual and batched**: no merge publishes anything, and neither does a tag push. Cut one when a batch of work has reached a stopping point — CI green on `main`, the feature set landed, no half-merged stack. Full policy -and procedure: [`docs/RELEASING.md`](docs/RELEASING.md). +and procedure: [`docs/RELEASING.md`](docs/RELEASING.md) — it is two dispatches, +`release` (tag + Linux binaries) then `android-release` with that tag (APK + +AAR): on this Forgejo neither a tag push nor `workflow_call` can wake the +Android job. Actions → release → Run workflow: @@ -284,9 +287,10 @@ Pass `tag` **or** `version`, not both; an unparseable version is rejected rather than guessed at. The workflow computes the version, creates the tag over the API (refusing to move an existing tag), builds aarch64 on the Pi runner and x86_64 on the amd64 runner, and publishes all four assets (`onionwire-` -+ `.sha256`) to one release. Creating that tag fires `android-release.yml`, -which builds the APK + AAR and joins the same release. If a build or the -publish fails, the run deletes the tag it created. Do not push tags by hand — ++ `.sha256`) to one release. Then dispatch `android-release` with that tag to +attach the APK + AAR to the same release (it has no automatic trigger on this +Forgejo — see `docs/RELEASING.md`). If a build or the publish fails, the core +run deletes the tag it created. Do not push tags by hand — `release.yml` has no tag-push trigger, so a hand-pushed tag would build nothing. @@ -301,7 +305,7 @@ FORGEJO_TOKEN= scripts/build-release-local.sh vX.Y.Z 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/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. The tag it creates fires [`android-release.yml`](.forgejo/workflows/android-release.yml) (`push: tags: v*.*.*`), which joins the same release with the APK + AAR. 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`. +- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). 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: diff --git a/docs/RELEASING.md b/docs/RELEASING.md index f605b04..a4ccc3b 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -37,7 +37,10 @@ created if the build or publish fails", and the dry-run path. 4. **Watch it.** The run name is `release`; `scripts/watch-release-run.sh` reports job status (it reads `action_run`/`action_run_job` on the Pi's database, so it works for dispatched runs as well as any other). -5. **Check the assets.** Open the release page (or +5. **Attach the Android assets.** Dispatch `android-release` with the tag the + core run just created — see [Android](#android-apk--aar-on-the-same-tag). + The Linux binaries land first; the APK build is the long pole. +6. **Check the assets.** Open the release page (or `GET /api/v1/repos/sirius/onionwire/releases/tags/`) and require a non-zero `size` for every asset: the two Linux binaries + `.sha256`, the APK + `.sha256`, the AAR + `.sha256`. A green run is not proof — the Pi @@ -81,20 +84,35 @@ final step deletes the incomplete release and the tag. A failed `aarch64` or ## Android (APK + AAR) on the same tag -Creating the tag sends the same push notification a `git push` would, and -[`android-release.yml`](../.forgejo/workflows/android-release.yml) is -subscribed to `push: tags: v*.*.*`. The core workflow therefore does not call -it, and no `main`-push trigger exists on either file. +A release is **two dispatches**. After the core run has created the tag and +published the Linux binaries: -That run builds the signed APK and the SDK AAR on the **amd64** runner (the Pi -is aarch64 and cannot produce an APK), then a second job on the Pi attaches the -APK + AAR + `.sha256` to the same tag. If the release does not exist yet it is -created; if it exists it is joined (`publish-release.sh` is create-or-update). -Android assets land on the release a while after the Linux ones — the Android -build is the long pole. +1. Actions → **android-release** → *Run workflow*, `tag=vX.Y.Z` (the tag the + core just created; leave `dry_run` false). +2. Check the release again — the APK + AAR + `.sha256` are attached to the + **same** tag. If the release did not exist yet it is created; if it exists + it is joined (`publish-release.sh` is create-or-update). -The workflow also has `workflow_dispatch` with the same `tag` / `dry_run` -inputs, which is how you repair or re-attach the Android assets by hand. +`android-release.yml` has no automatic trigger, and that is deliberate. Both +candidate decoupled triggers were tried on this instance and neither fires: + +- **A tag created by `release.yml` does not wake `push: tags: ['v*.*.*']`.** + Tried both ways — the tag created through `POST /tags`, and the tag created + by a real `git push` from the version job. Neither produced an + `android-release` run: pushes made with the CI's token are Actions-user + events, and Forgejo deliberately does not dispatch those back into Actions + (`services/actions/notifier_helper.go`: a doer that `IsActions()` is ignored). + Historically, *hand-pushed* tags did fire tag-filtered workflows, which is why + the trigger looked plausible. +- **`workflow_call` is unavailable.** Reusable workflows only appear in the + Forgejo docs from v12 onward; this instance reports + `10.0.3+gitea-1.22.0` (`GET /api/v1/version`), so a caller job with + `uses: ./.forgejo/workflows/android-release.yml` would never run. The + `workflow_call` block is left declared for the day the instance is upgraded. + +The Android build runs on the **amd64** runner (the Pi is aarch64 and cannot +produce an APK), then a second job on the Pi attaches the assets. It is the +long pole of a release — the Linux binaries land first. ## Rebuilding an existing tag