#!/usr/bin/env bash # Build, sign and publish one app as a Gitea release that Obtainium can find. # Usage: scripts/release.sh wetter (version comes from app/build.gradle.kts) # Needs: .giteatoken in the repo root (git-ignored) and ~/.android/nogoogleapps-release.properties set -euo pipefail cd "$(dirname "$0")/.." app="${1:?app folder, e.g. wetter}" title="$(tr '[:lower:]' '[:upper:]' <<< "${app:0:1}")${app:1}" version="$(sed -nE 's/.*versionName = "([^"]+)".*/\1/p' "$app/app/build.gradle.kts")" tag="$app-v$version" api="https://git.mrblake.cc/api/v1/repos/MrBlake/NoGooleApps" token="$(tr -d ' \n' < .giteatoken)" [ -f ~/.android/nogoogleapps-release.properties ] || { echo "release key missing" >&2; exit 1; } (cd "$app" && ./gradlew -q :app:assembleRelease) apk="$app/app/build/outputs/apk/release/app-release.apk" "${ANDROID_HOME:-$HOME/Android/Sdk}"/build-tools/36.0.0/apksigner verify "$apk" git -c credential.helper= push -q "https://MrBlake:$token@git.mrblake.cc/MrBlake/NoGooleApps.git" HEAD:main body="$(printf '{"tag_name":"%s","target_commitish":"%s","name":"%s %s","prerelease":true}' "$tag" "$(git rev-parse HEAD)" "$title" "$version")" id="$(curl -sf -X POST -H "Authorization: token $token" -H "Content-Type: application/json" -d "$body" "$api/releases" \ | python3 -I -c 'import sys,json; print(json.load(sys.stdin)["id"])')" curl -sf -X POST -H "Authorization: token $token" \ -F "attachment=@$apk;type=application/vnd.android.package-archive" \ "$api/releases/$id/assets?name=$app-$version.apk" > /dev/null echo "published $title $version ($tag)"