ci(release): create the release tag with git push so the Android job fires

POST /tags sends no push event on this Forgejo (the v0.2.0 tag it created
produced no android-release run), so the tag is now created locally and
pushed, which does fire android-release.yml's `push: tags` trigger.
This commit is contained in:
sirius 2026-09-12 18:48:57 -04:00
commit 7435ce42f5
No known key found for this signature in database

View file

@ -4,9 +4,10 @@ name: release
# PR does not mint a release. A maintainer dispatches this at a stopping point # 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. # (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 # Tag-push is intentionally NOT a trigger here: this workflow creates the tag
# via the API, and a tag-push hook would start a second run of the same # itself and a tag-push hook would start a second run of the same release.
# release. Creating the tag *does* fire android-release.yml's `push: tags` # The tag is created with a real `git push` (not POST /tags) precisely so that
# trigger, which is how the APK + AAR join the same release. # 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.
# Version: explicit `version`, else `bump` off the newest v*.*.* tag # 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. # (default minor — a batched release is usually a feature set); zero tags → v0.1.0.
on: on:
@ -59,11 +60,15 @@ jobs:
dry_run: ${{ steps.plan.outputs.dry_run }} dry_run: ${{ steps.plan.outputs.dry_run }}
created_tag: ${{ steps.plan.outputs.created_tag }} created_tag: ${{ steps.plan.outputs.created_tag }}
steps: 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 - name: Plan version, create tag unless dry_run
id: plan id: plan
env: env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
GIT_URL: ${{ github.server_url }}/${{ github.repository }}.git
EVENT_NAME: ${{ github.event_name }} EVENT_NAME: ${{ github.event_name }}
EVENT_SHA: ${{ github.sha }} EVENT_SHA: ${{ github.sha }}
INPUT_BUMP: ${{ github.event.inputs.bump }} INPUT_BUMP: ${{ github.event.inputs.bump }}
@ -151,23 +156,22 @@ jobs:
fi fi
echo "tag $tag already exists on $sha — joining" echo "tag $tag already exists on $sha — joining"
elif [ "$code" = "404" ]; then 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)" \ # Create the tag with a real `git push`, not POST /tags.
"$tag" "$sha" > /tmp/tag-create.json # A tag pushed by git fires the `push: tags: v*.*.*` trigger
echo "tag-create payload $(wc -c < /tmp/tag-create.json) bytes" # that android-release.yml listens on; a tag created through
create_code=$(api_curl -o /tmp/tag-created.json -w '%{http_code}' \ # the API does not (verified on this instance: the v0.2.0 tag
-X POST -H "Content-Type: application/json" \ # created by POST /tags produced no android-release run).
--data-binary @/tmp/tag-create.json \ git config user.name "onionwire-ci"
"$REPO_API/tags") git config user.email "onionwire-ci@localhost"
if [ "$create_code" = "201" ]; then git tag -a "$tag" "$sha" -m "OnionWire $tag"
created=true push_url="https://sirius:${FORGEJO_TOKEN}@${GIT_URL#https://}"
echo "created tag $tag on $sha" if ! git push "$push_url" "refs/tags/$tag" 2>&1 \
elif [ "$create_code" = "409" ]; then | sed "s|${FORGEJO_TOKEN}|***|g"; then
echo "tag $tag created concurrently — joining" echo "creating tag $tag on $sha failed" >&2
else
echo "creating tag $tag failed HTTP $create_code" >&2
cat /tmp/tag-created.json >&2 || true
exit 1 exit 1
fi fi
created=true
echo "created tag $tag on $sha (git push)"
else else
echo "GET tags/$tag failed HTTP $code" >&2 echo "GET tags/$tag failed HTTP $code" >&2
cat /tmp/tag.json >&2 || true cat /tmp/tag.json >&2 || true