fix(ci): join latest tag when its release lacks the APK
All checks were successful
ci / test (pull_request) Successful in 2m45s
All checks were successful
ci / test (pull_request) Successful in 2m45s
Core owns tag creation. If vN exists and the release is missing the Android APK, attach there instead of minting N+1. Never delete tags. Path filter is sources/Gradle only — README edits do not publish.
This commit is contained in:
parent
87ab0d2869
commit
1e6a4c12b2
2 changed files with 43 additions and 33 deletions
|
|
@ -8,15 +8,19 @@ name: android-release
|
||||||
# the same stdin-tar + docker cp pattern as .forgejo/workflows/ci.yml.
|
# the same stdin-tar + docker cp pattern as .forgejo/workflows/ci.yml.
|
||||||
#
|
#
|
||||||
# First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the
|
# First automated version with zero tags: v0.1.0. Afterwards, patch+1 from the
|
||||||
# latest v*.*.* tag. Never move an existing tag. If this workflow creates a
|
# latest v*.*.* tag UNLESS that tag's release is missing the Android assets —
|
||||||
# tag and then fails, it deletes that tag so the next run retries the same
|
# then join it (core owns tag creation). Never move or delete a tag.
|
||||||
# version instead of skipping.
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
paths:
|
paths:
|
||||||
- "android/**"
|
- "android/app/**"
|
||||||
|
- "android/sdk/**"
|
||||||
|
- "android/*.gradle.kts"
|
||||||
|
- "android/gradle/**"
|
||||||
|
- "android/gradle.properties"
|
||||||
|
- "android/settings.gradle.kts"
|
||||||
- "scripts/build-android-local.sh"
|
- "scripts/build-android-local.sh"
|
||||||
- ".forgejo/workflows/android-release.yml"
|
- ".forgejo/workflows/android-release.yml"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
@ -86,6 +90,8 @@ jobs:
|
||||||
INPUT_TAG: ${{ github.event.inputs.tag || inputs.tag }}
|
INPUT_TAG: ${{ github.event.inputs.tag || inputs.tag }}
|
||||||
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
|
INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }}
|
||||||
CALL_DRY_RUN: ${{ inputs.dry_run }}
|
CALL_DRY_RUN: ${{ inputs.dry_run }}
|
||||||
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
cd "${GITHUB_WORKSPACE}"
|
||||||
|
|
@ -101,6 +107,29 @@ jobs:
|
||||||
latest="$(git tag -l 'v*.*.*' --sort=-v:refname | head -n1 || true)"
|
latest="$(git tag -l 'v*.*.*' --sort=-v:refname | head -n1 || true)"
|
||||||
if [ -z "$latest" ]; then
|
if [ -z "$latest" ]; then
|
||||||
ver="0.1.0"
|
ver="0.1.0"
|
||||||
|
else
|
||||||
|
# Core owns tag creation. If the latest tag's release is missing
|
||||||
|
# the Android APK, join that version instead of minting patch+1.
|
||||||
|
join=0
|
||||||
|
if [ -n "${FORGEJO_TOKEN:-}" ]; then
|
||||||
|
http=$(curl -sS --http1.1 -o /tmp/latest-rel.json -w '%{http_code}' \
|
||||||
|
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
||||||
|
"$REPO_API/releases/tags/$latest" || true)
|
||||||
|
if [ "$http" != "200" ]; then
|
||||||
|
join=1
|
||||||
|
echo "latest tag $latest has no release (http $http); joining"
|
||||||
|
elif node -e 'const d=require("/tmp/latest-rel.json"); const n=(d.assets||[]).some(a=>/onionwire-.*-android-.*\\.apk$/.test(a.name)); process.exit(n?0:1)'; then
|
||||||
|
echo "latest tag $latest already has an Android APK; patch+1"
|
||||||
|
else
|
||||||
|
join=1
|
||||||
|
echo "latest tag $latest release is missing Android APK; joining"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "FORGEJO_TOKEN unset; cannot inspect release assets, joining $latest"
|
||||||
|
join=1
|
||||||
|
fi
|
||||||
|
if [ "$join" = "1" ]; then
|
||||||
|
ver="${latest#v}"
|
||||||
else
|
else
|
||||||
ver="${latest#v}"
|
ver="${latest#v}"
|
||||||
major="${ver%%.*}"
|
major="${ver%%.*}"
|
||||||
|
|
@ -111,6 +140,7 @@ jobs:
|
||||||
ver="${major}.${minor}.${patch}"
|
ver="${major}.${minor}.${patch}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
echo "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || {
|
echo "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || {
|
||||||
echo "not a MAJOR.MINOR.PATCH version: $ver" >&2
|
echo "not a MAJOR.MINOR.PATCH version: $ver" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -384,27 +414,6 @@ jobs:
|
||||||
| docker start -a -i "$PUB_C"
|
| docker start -a -i "$PUB_C"
|
||||||
docker rm -f "$PUB_C" >/dev/null || true
|
docker rm -f "$PUB_C" >/dev/null || true
|
||||||
|
|
||||||
- name: Drop dangling tag on failure
|
|
||||||
if: failure() && steps.version.outputs.dry_run != 'true' && steps.publish.outputs.created_tag == 'true'
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
: "${FORGEJO_TOKEN:?}"
|
|
||||||
echo "build/publish failed after creating $TAG; deleting so the next run retries this version"
|
|
||||||
curl -sS --http1.1 -X DELETE \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/git/tags/$TAG" || true
|
|
||||||
curl -sS --http1.1 -X DELETE \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/tags/$TAG" || true
|
|
||||||
code=$(curl -sS --http1.1 -o /tmp/tag-after.json -w '%{http_code}' \
|
|
||||||
-H "Authorization: Bearer $FORGEJO_TOKEN" \
|
|
||||||
"$REPO_API/tags/$TAG" || true)
|
|
||||||
echo "GET tags/$TAG after delete -> $code"
|
|
||||||
|
|
||||||
- name: Scrub keystore
|
- name: Scrub keystore
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,8 @@ deobfuscation, not before.
|
||||||
The job image is `node:20-bullseye` (EOL) — **do not apt-get there**. The
|
The job image is `node:20-bullseye` (EOL) — **do not apt-get there**. The
|
||||||
toolchain runs in a sibling `debian:bookworm` container
|
toolchain runs in a sibling `debian:bookworm` container
|
||||||
(stdin-tar + `docker cp`, same pattern as the Rust CI job).
|
(stdin-tar + `docker cp`, same pattern as the Rust CI job).
|
||||||
Any push to `main` that touches `android/**` (or the local build script / this
|
Any push to `main` that touches Android **sources or build config**
|
||||||
|
(`android/app/**`, `android/sdk/**`, Gradle files — not `android/README.md`)
|
||||||
workflow) builds `onionwire-<version>-android-arm64-v8a.apk` and
|
workflow) builds `onionwire-<version>-android-arm64-v8a.apk` and
|
||||||
`onionwire-sdk-<version>.aar`, verifies them, and attaches them to the Forgejo
|
`onionwire-sdk-<version>.aar`, verifies them, and attaches them to the Forgejo
|
||||||
release for that tag. Version is the latest `v*.*.*` tag plus patch, or
|
release for that tag. Version is the latest `v*.*.*` tag plus patch, or
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue