- App downloads updates itself, verifies SHA-256, opens the installer; manual Check for updates menu item - Server publishes the checksum and serves /download/IndexiPro-<v>.apk - android/release.sh tags v<version> and publishes IndexiPro-<version>.apk to the Gitea release, so F-Droid can track a versioned URL - Bump app to 1.2.0 (versionCode 3)
55 lines
2.6 KiB
Bash
Executable File
55 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# One-command Android release:
|
|
# 1. builds the APK (build-and-publish.sh) and commits the web-app copy + metadata
|
|
# 2. tags v<versionName> and pushes branch + tag
|
|
# 3. creates the Gitea release v<versionName> with the asset IndexiPro-<versionName>.apk
|
|
#
|
|
# The asset URL is therefore always predictable — handy for F-Droid "Binaries:" / auto-update:
|
|
# https://<gitea>/<owner>/<repo>/releases/download/v%v/IndexiPro-%v.apk
|
|
#
|
|
# Usage: bump versionCode + versionName in app/build.gradle.kts, commit, then
|
|
# GITEA_TOKEN=... ./release.sh [release-notes.md]
|
|
# (or GITEA_TOKEN_FILE=/path/to/token)
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
token=${GITEA_TOKEN:-}
|
|
[ -z "$token" ] && [ -n "${GITEA_TOKEN_FILE:-}" ] && token=$(tr -d '[:space:]' < "$GITEA_TOKEN_FILE")
|
|
[ -z "$token" ] && { echo "Set GITEA_TOKEN or GITEA_TOKEN_FILE"; exit 1; }
|
|
|
|
name=$(grep -oP 'versionName = "\K[^"]+' app/build.gradle.kts)
|
|
code=$(grep -oP 'versionCode = \K[0-9]+' app/build.gradle.kts)
|
|
tag="v$name"
|
|
asset="IndexiPro-$name.apk"
|
|
|
|
git diff --quiet && git diff --cached --quiet || { echo "Commit or stash your changes first."; exit 1; }
|
|
git rev-parse -q --verify "refs/tags/$tag" >/dev/null && { echo "Tag $tag already exists — bump versionName/versionCode first."; exit 1; }
|
|
|
|
# owner/repo and Gitea base from the origin remote (https or ssh form)
|
|
remote=$(git remote get-url origin)
|
|
path=$(echo "$remote" | sed -E 's#^(https?://[^/]+/|ssh://[^/]+/|[^@]+@[^:]+:)##; s#\.git$##')
|
|
host=$(echo "$remote" | sed -E 's#^(https?://|ssh://)?([^@]+@)?([^/:]+).*#\3#')
|
|
base="https://$host"
|
|
api="$base/api/v1/repos/$path"
|
|
auth="Authorization: token $token"
|
|
|
|
./build-and-publish.sh
|
|
|
|
git add ../server/public/download/indexipro.apk ../server/public/download/indexipro.json
|
|
git diff --cached --quiet || git commit -q -m "Release IndexiPro $name"
|
|
git tag -a "$tag" -m "IndexiPro $name"
|
|
git -c http.extraHeader="$auth" push -q origin HEAD "$tag"
|
|
|
|
sha=$(sha256sum "dist/$asset" | cut -d' ' -f1)
|
|
notes="IndexiPro $name (versionCode $code)."
|
|
[ -n "${1:-}" ] && notes=$(cat "$1")
|
|
notes="$notes"$'\n\n'"SHA-256 of \`$asset\`: \`$sha\`"
|
|
body=$(python3 -c 'import json,sys; print(json.dumps({"tag_name":sys.argv[1],"name":"IndexiPro "+sys.argv[2],"body":sys.argv[3]}))' "$tag" "$name" "$notes")
|
|
|
|
id=$(curl -sf -H "$auth" -H 'content-type: application/json' -X POST "$api/releases" -d "$body" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')
|
|
curl -sf -H "$auth" -F "attachment=@dist/$asset;type=application/vnd.android.package-archive" "$api/releases/$id/assets?name=$asset" >/dev/null
|
|
|
|
echo "Released $tag"
|
|
echo " $base/$path/releases/tag/$tag"
|
|
echo " $base/$path/releases/download/$tag/$asset"
|