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.
This commit is contained in:
parent
7435ce42f5
commit
2cf055c1e8
4 changed files with 73 additions and 50 deletions
|
|
@ -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
|
||||
# tag the core just created>`. The core's run leaves the tag; this attaches
|
||||
# the APK + AAR to it.
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue