diff --git a/.gitea/setup-signing.sh b/.gitea/setup-signing.sh new file mode 100755 index 00000000..87884be7 --- /dev/null +++ b/.gitea/setup-signing.sh @@ -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" diff --git a/.gitea/upstream-sync.sh b/.gitea/upstream-sync.sh new file mode 100755 index 00000000..3a05442d --- /dev/null +++ b/.gitea/upstream-sync.sh @@ -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=
+# 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" +} + +"$@" diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 00000000..9e6761fd --- /dev/null +++ b/.gitea/workflows/build.yml @@ -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:
+>
+> 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.
diff --git a/docs/tth/obtainium-qr.png b/docs/tth/obtainium-qr.png
new file mode 100644
index 00000000..b0873e83
Binary files /dev/null and b/docs/tth/obtainium-qr.png differ