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>
68 lines
2.1 KiB
Bash
Executable File
68 lines
2.1 KiB
Bash
Executable File
#!/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"
|