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
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
# Create the release signing key (once) and store it as the CI secrets
|
||||
# ANDROID_KEYSTORE_B64 + ANDROID_KEYSTORE_PASSWORD of tth/meshcore-open.
|
||||
#
|
||||
# .gitea/setup-signing.sh key from $KEYDIR, create it if missing
|
||||
#
|
||||
# The key lives in ~/.config/meshcore-open/ (keystore + password file, 0600).
|
||||
# BACK IT UP: every installed copy only accepts updates signed by this key;
|
||||
# lose it and the app has to be uninstalled (with its data) and reinstalled.
|
||||
#
|
||||
# Secrets never go to argv: the token and the payload reach curl through
|
||||
# --config on stdin and a 0600 temp file.
|
||||
set -euo pipefail
|
||||
|
||||
REPO="${REPO:-tth/meshcore-open}"
|
||||
KEYDIR="${KEYDIR:-$HOME/.config/meshcore-open}"
|
||||
CREDS="${CREDS:-$HOME/.config/gitea/credentials}"
|
||||
ALIAS=meshcore-open
|
||||
|
||||
ks="$KEYDIR/release.jks"
|
||||
pwf="$KEYDIR/release.password"
|
||||
|
||||
for bin in curl jq keytool base64 openssl; do
|
||||
command -v "$bin" >/dev/null || {
|
||||
echo "missing $bin" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
umask 077
|
||||
if [[ ! -s $ks ]]; then
|
||||
install -d -m700 "$KEYDIR"
|
||||
[[ -s $pwf ]] || openssl rand -base64 33 | tr -d '/+=\n' >"$pwf"
|
||||
keytool -genkeypair -keystore "$ks" -storetype PKCS12 -alias "$ALIAS" \
|
||||
-keyalg RSA -keysize 4096 -validity 36500 \
|
||||
-dname "CN=meshcore-open tth build" \
|
||||
-storepass:file "$pwf" -keypass:file "$pwf" >/dev/null 2>&1
|
||||
echo "created $ks"
|
||||
fi
|
||||
keytool -list -keystore "$ks" -alias "$ALIAS" -storepass:file "$pwf" -v 2>/dev/null |
|
||||
grep -m1 'SHA256:' | sed 's/^\s*/certificate /'
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "$CREDS"
|
||||
: "${GITEA_TOKEN:?no GITEA_TOKEN in $CREDS}"
|
||||
API="${GITEA_URL:-https://git.rfa.cz}/api/v1/repos/$REPO/actions/secrets"
|
||||
|
||||
tmp="$(mktemp)"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
put() {
|
||||
jq -n --rawfile v "$2" '{data: ($v | rtrimstr("\n"))}' >"$tmp"
|
||||
code=$(curl -sS -o /dev/null -w '%{http_code}' --config - -X PUT \
|
||||
-H 'Content-Type: application/json' --data-binary "@$tmp" "$API/$1" \
|
||||
<<<"header = \"Authorization: token $GITEA_TOKEN\"")
|
||||
case "$code" in
|
||||
201 | 204) echo "secret $1 set" ;;
|
||||
*)
|
||||
echo "secret $1: HTTP $code" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
b64="$(mktemp)"
|
||||
trap 'rm -f "$tmp" "$b64"' EXIT
|
||||
base64 -w0 "$ks" >"$b64"
|
||||
put ANDROID_KEYSTORE_B64 "$b64"
|
||||
put ANDROID_KEYSTORE_PASSWORD "$pwf"
|
||||
Executable
+107
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env bash
|
||||
# upstream-sync: merge upstream into our production branch, report failures.
|
||||
#
|
||||
# IDENTICAL COPY in meshcore-tth, meshy, openhop_core, openhop_repeater,
|
||||
# corescope and openhop-repeater (report only). Change one, change all; the
|
||||
# repo list is in MeshCore/tools/stack_status.py (REPOS).
|
||||
#
|
||||
# upstream-sync.sh merge BRANCH, UPSTREAM_URL, UPSTREAM_REFS ("main dev")
|
||||
# -> outputs changed=true|false, sha=<HEAD>
|
||||
# upstream-sync.sh report TOKEN; opens (or comments on) one issue
|
||||
# upstream-sync.sh resolve TOKEN; closes that issue after a good run
|
||||
#
|
||||
# MERGE, never rebase: Solo's cron rebased and fell over the same conflict on
|
||||
# every run until the branch was merged instead (3. 8. and 24. 8. 2026). A
|
||||
# merge resolved once stays resolved.
|
||||
#
|
||||
# Pushing is the workflow's job and happens only after its tests pass. A push
|
||||
# made with the job token does not start other workflows on Gitea, so anything
|
||||
# that has to build the result runs in the same workflow or on its own cron.
|
||||
set -euo pipefail
|
||||
|
||||
out() { printf '%s=%s\n' "$1" "$2" >>"${GITHUB_OUTPUT:-/dev/null}"; }
|
||||
|
||||
need_jq() {
|
||||
command -v jq >/dev/null || { apt-get update -qq && apt-get install -y -qq jq >/dev/null; }
|
||||
}
|
||||
|
||||
merge() {
|
||||
: "${BRANCH:?}" "${UPSTREAM_URL:?}" "${UPSTREAM_REFS:?}"
|
||||
git config user.name "upstream-sync-bot"
|
||||
git config user.email "upstream-sync@rfa.cz"
|
||||
git remote add upstream "$UPSTREAM_URL" 2>/dev/null || git remote set-url upstream "$UPSTREAM_URL"
|
||||
git fetch --quiet origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH"
|
||||
git checkout --quiet -B "$BRANCH" "origin/$BRANCH"
|
||||
local before ref n
|
||||
before="$(git rev-parse HEAD)"
|
||||
for ref in $UPSTREAM_REFS; do
|
||||
git fetch --quiet --tags upstream "+refs/heads/$ref:refs/remotes/upstream/$ref"
|
||||
if git merge-base --is-ancestor "upstream/$ref" HEAD; then
|
||||
echo "upstream/$ref: nothing new"
|
||||
continue
|
||||
fi
|
||||
n="$(git rev-list --count "HEAD..upstream/$ref")"
|
||||
echo "upstream/$ref: merging $n commits"
|
||||
git log --no-merges --max-count=40 --format=' %h %s' "HEAD..upstream/$ref"
|
||||
if ! git merge --no-edit -m "Merge upstream/$ref ($n commits) [upstream-sync]" "upstream/$ref"; then
|
||||
echo "::error::merge conflict with upstream/$ref"
|
||||
{
|
||||
echo "Merge conflict with \`upstream/$ref\` ($n new commits). Files:"
|
||||
git diff --name-only --diff-filter=U | sed 's/^/- `/; s/$/`/'
|
||||
echo
|
||||
echo "Resolve locally: \`git fetch upstream && git merge upstream/$ref\` on \`$BRANCH\`, push, and the next run carries on."
|
||||
} >"${RUNNER_TEMP:-/tmp}/upstream-sync-reason.md"
|
||||
git merge --abort
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
out changed "$([ "$before" != "$(git rev-parse HEAD)" ] && echo true || echo false)"
|
||||
out sha "$(git rev-parse HEAD)"
|
||||
out before "$before"
|
||||
}
|
||||
|
||||
report() {
|
||||
: "${TOKEN:?}"
|
||||
need_jq
|
||||
local api title run reason num body
|
||||
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
title="upstream-sync failed"
|
||||
run="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_NUMBER}"
|
||||
reason="${RUNNER_TEMP:-/tmp}/upstream-sync-reason.md"
|
||||
if [ -s "$reason" ]; then
|
||||
body="$(cat "$reason")"
|
||||
else
|
||||
body="A step after the merge failed (tests or build), so nothing was pushed."
|
||||
fi
|
||||
body="$(printf '%s\n\nRun: %s\n' "$body" "$run")"
|
||||
num="$(curl -sf -H "Authorization: token $TOKEN" "$api/issues?state=open&type=issues&limit=50" |
|
||||
jq -r --arg t "$title" '[.[] | select(.title == $t)][0].number // empty')"
|
||||
if [ -n "$num" ]; then
|
||||
jq -n --arg b "$body" '{body: $b}' |
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d @- "$api/issues/$num/comments" >/dev/null
|
||||
echo "commented on issue #$num"
|
||||
else
|
||||
jq -n --arg t "$title" --arg b "$body" '{title: $t, body: $b}' |
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d @- "$api/issues" | jq -r '"opened issue #\(.number)"'
|
||||
fi
|
||||
}
|
||||
|
||||
resolve() {
|
||||
: "${TOKEN:?}"
|
||||
need_jq
|
||||
local api num
|
||||
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
num="$(curl -sf -H "Authorization: token $TOKEN" "$api/issues?state=open&type=issues&limit=50" |
|
||||
jq -r '[.[] | select(.title == "upstream-sync failed")][0].number // empty')" || return 0
|
||||
[ -n "$num" ] || return 0
|
||||
jq -n --arg b "Synced again in ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_NUMBER}" '{body: $b}' |
|
||||
curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d @- "$api/issues/$num/comments" >/dev/null
|
||||
curl -sf -X PATCH -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d '{"state":"closed"}' "$api/issues/$num" >/dev/null
|
||||
echo "closed issue #$num"
|
||||
}
|
||||
|
||||
"$@"
|
||||
@@ -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
|
||||
@@ -2,6 +2,20 @@
|
||||
|
||||
Open-source Flutter client for MeshCore LoRa mesh networking devices.
|
||||
|
||||
> **Fork tth:** build bez on-device ML (překlad zpráv, neuronový kodek
|
||||
> obrázků) a jen pro arm64 — APK má ~40 MB místo ~340 MB. Jinak shodné
|
||||
> s upstreamem `dev`, který se slévá každou noc; co a proč je jinak:
|
||||
> [`stubs/README.md`](stubs/README.md), build: `.gitea/workflows/build.yml`.
|
||||
>
|
||||
> **Instalace přes Obtainium:** naskenuj QR telefonem, nebo na telefonu otevři
|
||||
> [tenhle odkaz](https://apps.obtainium.imranr.dev/redirect.html?r=obtainium%3A%2F%2Fapp%2F%257B%2522id%2522%253A%2522com.meshcore.meshcore_open%2522%252C%2522url%2522%253A%2522https%253A%252F%252Fgit.rfa.cz%252Ftth%252Fmeshcore-open%2522%252C%2522author%2522%253A%2522tth%2522%252C%2522name%2522%253A%2522MeshCore%2520Open%2520%2528tth%2529%2522%252C%2522preferredApkIndex%2522%253A0%252C%2522additionalSettings%2522%253A%2522%257B%257D%2522%252C%2522overrideSource%2522%253A%2522Codeberg%2522%257D).
|
||||
>
|
||||
> <img src="docs/tth/obtainium-qr.png" width="200" alt="QR pro Obtainium"/>
|
||||
>
|
||||
> Ručně: Obtainium → Add App → URL `https://git.rfa.cz/tth/meshcore-open`,
|
||||
> „Override source" = **Forgejo (Codeberg)**. Releases jsou podepsané vlastním
|
||||
> klíčem, takže přes upstreamové APK se neaktualizují (a naopak).
|
||||
|
||||
## Overview
|
||||
|
||||
MeshCore Open is a cross-platform application for communicating with MeshCore LoRa mesh radios over Bluetooth Low Energy (BLE), USB serial, or TCP. The app enables long-range, off-grid communication through peer-to-peer messaging, public channels, and mesh networking capabilities.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in new issue
Block a user