CI on git.rfa.cz: nightly upstream merge, signed arm64 release
build / build (push) Successful in 20m46s
build / build (push) Successful in 20m46s
.gitea/workflows/build.yml merges upstream dev, runs the tests, builds a signed arm64 APK in ghcr.io/cirruslabs/flutter and publishes a release for Obtainium (one per HEAD, newest 5 kept). upstream-sync.sh is the shared copy from the other forks; setup-signing.sh creates the key and stores it as CI secrets. README gets an Obtainium QR code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
42e4a1e0de
commit
cbf2abeaad
5 files changed
+360
No files matched your search
@@ -0,0 +1,172 @@
|
||||
---
|
||||
# Merge upstream zjs81/meshcore-open dev into tth every night, run the tests,
|
||||
# build a signed arm64 APK without the on-device ML (see stubs/README.md),
|
||||
# push the merge and publish a release that Obtainium picks up.
|
||||
#
|
||||
# A release is made only when HEAD has none yet (its body carries
|
||||
# "commit: <sha>"); workflow_dispatch always builds.
|
||||
#
|
||||
# Signing: secrets ANDROID_KEYSTORE_B64 + ANDROID_KEYSTORE_PASSWORD, set by
|
||||
# .gitea/setup-signing.sh. Without them the job fails rather than publish a
|
||||
# debug-signed APK - Android refuses an update signed by a different key.
|
||||
#
|
||||
# On failure: issue "upstream-sync failed"; closed by the next good run.
|
||||
name: build
|
||||
|
||||
"on":
|
||||
schedule:
|
||||
- cron: "50 4 * * *"
|
||||
push:
|
||||
branches: [tth]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: build
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
BRANCH: tth
|
||||
UPSTREAM_URL: https://github.com/zjs81/meshcore-open.git
|
||||
UPSTREAM_REFS: dev
|
||||
GITEA: https://git.rfa.cz
|
||||
KEEP_RELEASES: 5
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: big
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
container:
|
||||
image: ghcr.io/cirruslabs/flutter:stable
|
||||
steps:
|
||||
# Plain git instead of actions/checkout: that is a JS action and the
|
||||
# image (Ubuntu 24.04) only offers node 18.
|
||||
- name: Checkout
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config --global --add safe.directory '*'
|
||||
git init -q .
|
||||
git remote add origin "$GITEA/$GITHUB_REPOSITORY.git"
|
||||
# Also authenticates the push at the end; the container is thrown away.
|
||||
git config "http.$GITEA/.extraheader" "Authorization: token $TOKEN"
|
||||
git fetch -q origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH"
|
||||
git checkout -q -B "$BRANCH" "origin/$BRANCH"
|
||||
|
||||
- name: Merge upstream
|
||||
id: merge
|
||||
run: bash .gitea/upstream-sync.sh merge
|
||||
|
||||
- name: Release needed?
|
||||
id: rel
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
SHA: ${{ steps.merge.outputs.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
last=$(curl -sSf --config - "$GITEA/api/v1/repos/$GITHUB_REPOSITORY/releases?limit=1" \
|
||||
<<<"header = \"Authorization: token $TOKEN\"" |
|
||||
jq -r '.[0].body // ""' | sed -n 's/^commit: *//p' | head -n1)
|
||||
echo "HEAD $SHA, last release commit ${last:-none}"
|
||||
if [ "$last" = "$SHA" ] && [ "$GITHUB_EVENT_NAME" != workflow_dispatch ]; then
|
||||
echo "needed=false" >>"$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "needed=true" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Tests
|
||||
if: steps.rel.outputs.needed == 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
flutter pub get
|
||||
flutter test --no-pub -r failures-only
|
||||
|
||||
- name: Build signed APK
|
||||
if: steps.rel.outputs.needed == 'true'
|
||||
id: apk
|
||||
env:
|
||||
KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
|
||||
KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[ -n "$KEYSTORE_B64" ] && [ -n "$KEYSTORE_PASSWORD" ] || {
|
||||
echo "::error::signing secrets missing, run .gitea/setup-signing.sh"
|
||||
exit 1
|
||||
}
|
||||
ks="$RUNNER_TEMP/release.jks"
|
||||
base64 -d <<<"$KEYSTORE_B64" >"$ks"
|
||||
# PKCS12: key password = store password.
|
||||
umask 077
|
||||
printf 'storeFile=%s\nstorePassword=%s\nkeyAlias=meshcore-open\nkeyPassword=%s\n' \
|
||||
"$ks" "$KEYSTORE_PASSWORD" "$KEYSTORE_PASSWORD" >android/key.properties
|
||||
base=$(sed -n 's/^version: *\([^+ ]*\).*/\1/p' pubspec.yaml)
|
||||
name="$base-tth.$(date -u +%Y%m%d%H%M)"
|
||||
# Minutes since 2026-01-01: monotonic, and far above upstream's codes.
|
||||
code=$((($(date -u +%s) - 1767225600) / 60))
|
||||
flutter build apk --release --no-pub --target-platform android-arm64 \
|
||||
--build-name "$name" --build-number "$code"
|
||||
rm -f android/key.properties "$ks"
|
||||
apk="$RUNNER_TEMP/meshcore-open-$name-arm64.apk"
|
||||
cp build/app/outputs/flutter-apk/app-release.apk "$apk"
|
||||
signer=$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -n1)/apksigner
|
||||
certs=$("$signer" verify --print-certs "$apk")
|
||||
if grep -q 'CN=Android Debug' <<<"$certs"; then
|
||||
echo "::error::APK is debug-signed"
|
||||
exit 1
|
||||
fi
|
||||
grep 'certificate SHA-256' <<<"$certs"
|
||||
ls -lh "$apk"
|
||||
echo "name=$name" >>"$GITHUB_OUTPUT"
|
||||
echo "apk=$apk" >>"$GITHUB_OUTPUT"
|
||||
|
||||
- name: Push
|
||||
if: steps.merge.outputs.changed == 'true'
|
||||
run: git push origin "HEAD:$BRANCH"
|
||||
|
||||
- name: Release
|
||||
if: steps.rel.outputs.needed == 'true'
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
SHA: ${{ steps.merge.outputs.sha }}
|
||||
NAME: ${{ steps.apk.outputs.name }}
|
||||
APK: ${{ steps.apk.outputs.apk }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
api="$GITEA/api/v1/repos/$GITHUB_REPOSITORY"
|
||||
auth="header = \"Authorization: token $TOKEN\""
|
||||
upstream=$(git log -1 --format='%h %s' "upstream/${UPSTREAM_REFS%% *}" 2>/dev/null || true)
|
||||
body=$(printf 'commit: %s\n\nupstream %s: %s\n\narm64 only, without on-device ML (translation, neural image codec).\n' \
|
||||
"$SHA" "${UPSTREAM_REFS%% *}" "$upstream")
|
||||
jq -n --arg t "v$NAME" --arg c "$SHA" --arg b "$body" \
|
||||
'{tag_name: $t, target_commitish: $c, name: $t, body: $b}' >"$RUNNER_TEMP/rel.json"
|
||||
id=$(curl -sSf --config - -X POST -H 'Content-Type: application/json' \
|
||||
--data-binary "@$RUNNER_TEMP/rel.json" "$api/releases" <<<"$auth" | jq -r .id)
|
||||
curl -sSf --config - -X POST -F "attachment=@$APK" \
|
||||
"$api/releases/$id/assets?name=$(basename "$APK")" <<<"$auth" >/dev/null
|
||||
echo "released v$NAME (id $id)"
|
||||
# Keep the newest KEEP_RELEASES releases and their tags.
|
||||
curl -sSf --config - "$api/releases?limit=50" <<<"$auth" |
|
||||
jq -r --argjson k "$KEEP_RELEASES" '.[$k:][] | "\(.id) \(.tag_name)"' |
|
||||
while read -r old tag; do
|
||||
curl -sSf --config - -X DELETE "$api/releases/$old" <<<"$auth"
|
||||
curl -sSf --config - -X DELETE "$api/tags/$(jq -rn --arg t "$tag" '$t|@uri')" <<<"$auth" || true
|
||||
echo "removed $tag"
|
||||
done
|
||||
|
||||
- name: Close failure issue
|
||||
if: success()
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
run: bash .gitea/upstream-sync.sh resolve
|
||||
|
||||
- name: Report failure
|
||||
if: failure()
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
run: bash .gitea/upstream-sync.sh report
|
||||
Reference in new issue
Block a user