From 044b6368b883f81b05e91cb615fe972344c1c9b6 Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Sun, 14 Jun 2026 14:39:49 +0000 Subject: [PATCH] Prepare public 0.1 release --- .gitignore | 1 - README.md | 17 --- scripts/generate_launcher_icon.py | 6 +- scripts/release-gitea.sh | 185 ------------------------------ version.properties | 1 + 5 files changed, 4 insertions(+), 206 deletions(-) delete mode 100755 scripts/release-gitea.sh create mode 100644 version.properties diff --git a/.gitignore b/.gitignore index 45c7271..5483bbc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ /local/ /local.properties /project.md -/build.sh # Build output /.gradle/ diff --git a/README.md b/README.md index c47924e..5093965 100644 --- a/README.md +++ b/README.md @@ -81,23 +81,6 @@ Release builds require local signing configuration: ./gradlew assembleRelease ``` -## Releases - -Public releases use two-part versions such as `0.1`, `0.2`, and eventually -`1.0`. - -Gitea automatically provides source archives for release tags, so the release -assets only need the APK and its checksum. A release can be created with: - -```bash -mkdir -p local -printf '%s' 'your-gitea-token' > local/gitea-token - -GITEA_BASE_URL=git.ajpanton.se \ -GITEA_TOKEN_FILE=local/gitea-token \ -scripts/release-gitea.sh 0.1 -``` - ## Development Note This project has been coded with the help of AI as an implementation aid. The diff --git a/scripts/generate_launcher_icon.py b/scripts/generate_launcher_icon.py index 16b6ac0..d502c67 100755 --- a/scripts/generate_launcher_icon.py +++ b/scripts/generate_launcher_icon.py @@ -2,7 +2,7 @@ """Generate the launcher icon VectorDrawable files and a local SVG preview. This keeps the icon tweakable without hand-editing dense Android vector XML. -Edit the constants below, run this script, then open local/launcher-icon-preview.svg. +Edit the constants below, run this script, then open build/launcher-icon-preview.svg. """ from __future__ import annotations @@ -16,12 +16,12 @@ ROOT = Path(__file__).resolve().parents[1] FOREGROUND = ROOT / "app/src/main/res/drawable/ic_launcher_foreground.xml" MONOCHROME = ROOT / "app/src/main/res/drawable/ic_launcher_monochrome.xml" BACKGROUND = ROOT / "app/src/main/res/drawable/ic_launcher_background.xml" -PREVIEW = ROOT / "local/launcher-icon-preview.svg" +PREVIEW = ROOT / "build/launcher-icon-preview.svg" VIEWPORT = 108 # Main geometry knobs. Coordinates are in Android/SVG viewport units. -# Open local/launcher-icon-preview.svg after regenerating to compare the +# Open build/launcher-icon-preview.svg after regenerating to compare the # square, rounded, and circular launcher masks. # Statusbar panel. It fills the full top width. STATUS_BOTTOM = 54 diff --git a/scripts/release-gitea.sh b/scripts/release-gitea.sh deleted file mode 100755 index 3d57f30..0000000 --- a/scripts/release-gitea.sh +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -usage() { - cat <<'EOF' -Usage: - GITEA_BASE_URL=git.example.com GITEA_TOKEN_FILE=local/gitea-token scripts/release-gitea.sh 0.1 - -Creates a Gitea release for the current HEAD and uploads: - - the signed release APK - - a SHA-256 checksum file for the APK - -Environment: - GITEA_BASE_URL Base URL of the Gitea instance, for example git.example.com - GITEA_TOKEN Gitea access token with repository write/release permissions - GITEA_TOKEN_FILE Optional file containing the token, used when GITEA_TOKEN is unset - GITEA_OWNER Optional repository owner override. Defaults to origin remote owner. - GITEA_REPO Optional repository name override. Defaults to origin remote repo. - VERSION_CODE Optional Android versionCode override. - -The script requires a clean working tree and pushes the current branch and tag. -EOF -} - -if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then - usage - exit 0 -fi - -version="${1:-}" -if [[ ! "$version" =~ ^[0-9]+\.[0-9]+$ ]]; then - usage >&2 - exit 2 -fi - -: "${GITEA_BASE_URL:?Set GITEA_BASE_URL, for example git.example.com}" - -if [[ -z "${GITEA_TOKEN:-}" && -n "${GITEA_TOKEN_FILE:-}" ]]; then - if [[ ! -f "$GITEA_TOKEN_FILE" ]]; then - echo "GITEA_TOKEN_FILE does not exist: ${GITEA_TOKEN_FILE}" >&2 - exit 1 - fi - GITEA_TOKEN="$(tr -d '\r\n' < "$GITEA_TOKEN_FILE")" -fi -: "${GITEA_TOKEN:?Set GITEA_TOKEN or GITEA_TOKEN_FILE to a Gitea access token}" - -require_clean_tree() { - if [[ -n "$(git status --porcelain)" ]]; then - echo "Working tree is not clean. Commit or stash changes before releasing." >&2 - exit 1 - fi -} - -remote_repo_path() { - local remote_url - remote_url="$(git remote get-url origin)" - remote_url="${remote_url%.git}" - case "$remote_url" in - ssh://*) - remote_url="${remote_url#ssh://}" - remote_url="${remote_url#*/}" - ;; - http://*|https://*) - remote_url="${remote_url#http://}" - remote_url="${remote_url#https://}" - remote_url="${remote_url#*/}" - ;; - *@*:*) - remote_url="${remote_url#*:}" - ;; - esac - printf '%s\n' "$remote_url" -} - -json_string() { - python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$1" -} - -extract_json_id() { - python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])' -} - -version_code_for() { - local major minor - IFS=. read -r major minor <<<"$1" - printf '%d\n' "$((major * 10000 + minor * 100))" -} - -urlencode() { - python3 -c 'import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=""))' "$1" -} - -normalize_base_url() { - local base_url - base_url="${1%/}" - case "$base_url" in - http://*|https://*) ;; - *) base_url="https://${base_url}" ;; - esac - printf '%s\n' "$base_url" -} - -require_clean_tree - -tag="v${version}" -release_name="StatusBarTweak ${version}" -version_code="${VERSION_CODE:-$(version_code_for "$version")}" -repo_path="$(remote_repo_path)" -owner="${GITEA_OWNER:-${repo_path%%/*}}" -repo="${GITEA_REPO:-${repo_path##*/}}" -gitea_base_url="$(normalize_base_url "$GITEA_BASE_URL")" -api_base="${gitea_base_url}/api/v1" - -if [[ "$owner" == "$repo_path" || -z "$owner" || -z "$repo" ]]; then - echo "Could not infer owner/repo from origin. Set GITEA_OWNER and GITEA_REPO." >&2 - exit 1 -fi - -git fetch origin --tags -if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then - echo "Tag ${tag} already exists." >&2 - exit 1 -fi - -./gradlew clean assembleRelease \ - -PsbtVersionName="$version" \ - -PsbtVersionCode="$version_code" - -apk_source="app/build/outputs/apk/release/app-release.apk" -if [[ ! -f "$apk_source" ]]; then - echo "Release APK not found at ${apk_source}." >&2 - exit 1 -fi - -release_dir="build/release/${tag}" -apk_name="StatusBarTweak-${version}.apk" -checksum_name="${apk_name}.sha256" -mkdir -p "$release_dir" -cp "$apk_source" "${release_dir}/${apk_name}" -(cd "$release_dir" && sha256sum "$apk_name" > "$checksum_name") - -git tag -a "$tag" -m "$release_name" -git push origin HEAD -git push origin "$tag" - -body="Tested primarily on Samsung Galaxy Fold 5 running One UI 8.0 / Android 16." -payload="$( - cat </dev/null -} - -upload_asset "${release_dir}/${apk_name}" -upload_asset "${release_dir}/${checksum_name}" - -echo "Created release ${tag}: ${gitea_base_url}/${owner}/${repo}/releases/tag/${tag}" diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..79010b2 --- /dev/null +++ b/version.properties @@ -0,0 +1 @@ +version=0.1