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.
|
||||
#
|
||||
# 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
|
||||
# tag and then fails, it deletes that tag so the next run retries the same
|
||||
# version instead of skipping.
|
||||
# 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.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "android/**"
|
||||
- "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"
|
||||
workflow_dispatch:
|
||||
|
|
@ -86,6 +90,8 @@ jobs:
|
|||
INPUT_TAG: ${{ github.event.inputs.tag || inputs.tag }}
|
||||
INPUT_DRY_RUN: ${{ github.event.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: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
|
|
@ -102,13 +108,37 @@ jobs:
|
|||
if [ -z "$latest" ]; then
|
||||
ver="0.1.0"
|
||||
else
|
||||
ver="${latest#v}"
|
||||
major="${ver%%.*}"
|
||||
rest="${ver#*.}"
|
||||
minor="${rest%%.*}"
|
||||
patch="${rest#*.}"
|
||||
patch=$((patch + 1))
|
||||
ver="${major}.${minor}.${patch}"
|
||||
# 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
|
||||
ver="${latest#v}"
|
||||
major="${ver%%.*}"
|
||||
rest="${ver#*.}"
|
||||
minor="${rest%%.*}"
|
||||
patch="${rest#*.}"
|
||||
patch=$((patch + 1))
|
||||
ver="${major}.${minor}.${patch}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "$ver" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || {
|
||||
|
|
@ -384,27 +414,6 @@ jobs:
|
|||
| docker start -a -i "$PUB_C"
|
||||
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
|
||||
if: always()
|
||||
run: |
|
||||
|
|
|
|||
Loading…
Reference in a new issue