Prepare public 0.1 release
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
/local/
|
/local/
|
||||||
/local.properties
|
/local.properties
|
||||||
/project.md
|
/project.md
|
||||||
/build.sh
|
|
||||||
|
|
||||||
# Build output
|
# Build output
|
||||||
/.gradle/
|
/.gradle/
|
||||||
|
|||||||
@@ -81,23 +81,6 @@ Release builds require local signing configuration:
|
|||||||
./gradlew assembleRelease
|
./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
|
## Development Note
|
||||||
|
|
||||||
This project has been coded with the help of AI as an implementation aid. The
|
This project has been coded with the help of AI as an implementation aid. The
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"""Generate the launcher icon VectorDrawable files and a local SVG preview.
|
"""Generate the launcher icon VectorDrawable files and a local SVG preview.
|
||||||
|
|
||||||
This keeps the icon tweakable without hand-editing dense Android vector XML.
|
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
|
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"
|
FOREGROUND = ROOT / "app/src/main/res/drawable/ic_launcher_foreground.xml"
|
||||||
MONOCHROME = ROOT / "app/src/main/res/drawable/ic_launcher_monochrome.xml"
|
MONOCHROME = ROOT / "app/src/main/res/drawable/ic_launcher_monochrome.xml"
|
||||||
BACKGROUND = ROOT / "app/src/main/res/drawable/ic_launcher_background.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
|
VIEWPORT = 108
|
||||||
|
|
||||||
# Main geometry knobs. Coordinates are in Android/SVG viewport units.
|
# 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.
|
# square, rounded, and circular launcher masks.
|
||||||
# Statusbar panel. It fills the full top width.
|
# Statusbar panel. It fills the full top width.
|
||||||
STATUS_BOTTOM = 54
|
STATUS_BOTTOM = 54
|
||||||
|
|||||||
@@ -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 <<EOF
|
|
||||||
{
|
|
||||||
"tag_name": $(json_string "$tag"),
|
|
||||||
"target_commitish": $(json_string "$(git rev-parse HEAD)"),
|
|
||||||
"name": $(json_string "$release_name"),
|
|
||||||
"body": $(json_string "$body"),
|
|
||||||
"draft": false,
|
|
||||||
"prerelease": true
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)"
|
|
||||||
|
|
||||||
release_id="$(
|
|
||||||
curl --fail --silent --show-error \
|
|
||||||
-X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
--data "$payload" \
|
|
||||||
"${api_base}/repos/$(urlencode "$owner")/$(urlencode "$repo")/releases" \
|
|
||||||
| extract_json_id
|
|
||||||
)"
|
|
||||||
|
|
||||||
upload_asset() {
|
|
||||||
local path name
|
|
||||||
path="$1"
|
|
||||||
name="$(basename "$path")"
|
|
||||||
curl --fail --silent --show-error \
|
|
||||||
-X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-F "attachment=@${path}" \
|
|
||||||
"${api_base}/repos/$(urlencode "$owner")/$(urlencode "$repo")/releases/${release_id}/assets?name=$(urlencode "$name")" \
|
|
||||||
>/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}"
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
version=0.1
|
||||||
Reference in New Issue
Block a user