ci(release): manual, batched releases — no release on merge
All checks were successful
ci / test (pull_request) Successful in 3m49s

Drop `push: branches: [main]` from both release workflows. release.yml now
runs only via workflow_dispatch, with bump (default minor), version, tag and
dry_run inputs; contradictory input is rejected instead of guessed at.

android-release.yml keeps the Android assets on the same tag by subscribing to
`push: tags: v*.*.*`: creating a tag over the API sends the same push
notification a git push does, so the core's tag wakes it. No workflow_call —
this Forgejo is 10.0.3, where reusable workflows are not supported.

docs/RELEASING.md is the policy and procedure.
This commit is contained in:
sirius 2026-09-12 17:57:15 -04:00
commit 6c9fd00b8a
No known key found for this signature in database
5 changed files with 225 additions and 38 deletions

View file

@ -14,19 +14,17 @@ name: android-release
# First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the
# 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.
on:
push:
branches: [main]
paths:
- "android/app/**"
- "android/sdk/**"
- "android/*.gradle.kts"
- "android/gradle/**"
- "android/gradle.properties"
- "android/settings.gradle.kts"
- "scripts/build-android-local.sh"
- ".forgejo/workflows/android-release.yml"
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:

View file

@ -1,23 +1,32 @@
name: release
# 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.
# Manual, batched releases. There is deliberately NO push trigger: a merged
# 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.
# 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:
push:
branches: [main]
paths:
- "src/**"
- "crates/**"
- "Cargo.toml"
- "Cargo.lock"
- "scripts/release-body.md"
workflow_dispatch:
inputs:
bump:
description: Bump off the newest v*.*.* tag (ignored when version or tag is set)
required: false
type: choice
options:
- minor
- patch
- major
default: minor
version:
description: Explicit version MAJOR.MINOR.PATCH (or vMAJOR.MINOR.PATCH); overrides bump
required: false
type: string
tag:
description: Existing tag to (re)build and publish (empty = next version)
description: Existing tag to (re)build and publish (empty = create the next version)
required: false
type: string
dry_run:
@ -57,6 +66,8 @@ jobs:
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
EVENT_SHA: ${{ github.sha }}
INPUT_BUMP: ${{ github.event.inputs.bump }}
INPUT_VERSION: ${{ github.event.inputs.version }}
INPUT_TAG: ${{ github.event.inputs.tag }}
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
run: |
@ -69,7 +80,7 @@ jobs:
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"
echo "event=$EVENT_NAME sha=$EVENT_SHA input_version=${INPUT_VERSION-} input_tag=${INPUT_TAG-} input_bump=${INPUT_BUMP-} input_dry_run=${INPUT_DRY_RUN-} dry_run=$dry_run"
api_curl() {
curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \
@ -78,6 +89,13 @@ jobs:
}
input_tag="${INPUT_TAG:-}"
version_input="${INPUT_VERSION:-}"
bump="${INPUT_BUMP:-minor}"
# Contradictory input is rejected, never guessed at.
if [ -n "$input_tag" ] && [ -n "$version_input" ]; then
echo "got both tag='$input_tag' and version='$version_input': tag rebuilds an existing tag, version mints a new one — pass one" >&2
exit 1
fi
if [ -n "$input_tag" ]; then
code=$(api_curl -o /tmp/tag.json -w '%{http_code}' \
"$REPO_API/tags/$input_tag")
@ -91,8 +109,33 @@ jobs:
created=false
echo "re-publish existing tag $tag at $sha (dry_run=$dry_run)"
else
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))")
if [ -n "$version_input" ]; then
tag=$(python3 -c "import re,sys; m=re.fullmatch(r'v?([0-9]+)\.([0-9]+)\.([0-9]+)', sys.argv[1].strip()); print('v' + '.'.join(m.groups()) if m else '')" "$version_input")
if [ -z "$tag" ]; then
echo "version must be MAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH, got '$version_input'" >&2
exit 1
fi
else
case "$bump" in
patch|minor|major) ;;
*) echo "bump must be patch|minor|major, got '$bump'" >&2; exit 1 ;;
esac
api_curl "$REPO_API/tags?limit=50" -o /tmp/tags.json
latest=$(python3 -c "import json,re; tags=json.load(open('/tmp/tags.json')); assert isinstance(tags, list), tags; s=[tuple(int(x) for x in m.groups()) for t in tags for m in [re.fullmatch(r'v([0-9]+)\.([0-9]+)\.([0-9]+)', t.get('name') or '')] if m]; print('%d.%d.%d' % max(s) if s else '')")
if [ -z "$latest" ]; then
tag="v0.1.0"
else
major="${latest%%.*}"
rest="${latest#*.}"
minor="${rest%%.*}"
patch="${rest#*.}"
case "$bump" in
major) tag="v$((major + 1)).0.0" ;;
minor) tag="v$major.$((minor + 1)).0" ;;
patch) tag="v$major.$minor.$((patch + 1))" ;;
esac
fi
fi
sha="$EVENT_SHA"
created=false
if [ "$dry_run" = "true" ]; then