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:
parent
70ae597abc
commit
7435ce42f5
1 changed files with 22 additions and 18 deletions
|
|
@ -4,9 +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
|
||||
# via the API, and a tag-push hook would start a second run of the same
|
||||
# release. Creating the tag *does* fire android-release.yml's `push: tags`
|
||||
# trigger, which is how the APK + AAR join the same release.
|
||||
# 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.
|
||||
# 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:
|
||||
|
|
@ -59,11 +60,15 @@ 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 }}
|
||||
|
|
@ -151,23 +156,22 @@ jobs:
|
|||
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
|
||||
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
|
||||
# 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
|
||||
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