releases: move release builds to location_share_server
- Commit
4acf727bc746b52ba0efd03a91f73a1e8ecf1a51- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-30 00:59 UTC (2 months ago)
- Parents
cd615a8
Diff
.github/workflows/android.yml
diff --git a/.github/workflows/android.yml b/.github/workflows/android.ymldeleted file mode 100644index add1eebfb2..0000000000--- a/.github/workflows/android.yml+++ /dev/null@@ -1,307 +0,0 @@-name: "๐ Publish Next Release"--on:- workflow_dispatch:--# Only the non-secret keystore filename is workflow-scoped. The signing secrets are-# scoped to the single step that consumes them so they are not in the environment of-# third-party actions.-env:- ks_filename: release_keystore.jks--jobs:- release:- runs-on: ubuntu-latest- permissions:- contents: write-- steps:- - name: Checkout Code- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- with:- fetch-depth: 0- lfs: true- submodules: recursive-- - name: Set Up JDK 21- uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0- with:- distribution: 'zulu'- java-version: '21'- cache: 'gradle'-- - name: Clean Project Files- run: |- if [ -f "settings.gradle.kts" ]; then- echo "Removing local includeBuild from settings.gradle.kts..."- sed -i '/includeBuild.*NewPipeExtractor/,/^}/d' settings.gradle.kts- fi-- if [ -f "build.gradle.kts" ]; then- echo "Removing debug signingConfig from root build.gradle.kts..."- sed -i '/signingConfig = signingConfigs.getByName("debug")/d' build.gradle.kts- fi-- - name: Decode Keystore- run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > ${{ env.ks_filename }}-- - name: Change Gradle Wrapper Permissions- run: chmod +x ./gradlew-- - name: Configure Gradle for CI runner- run: |- # GitHub-hosted Linux runners are ~16GB RAM / ~4 vCPU. The project's- # local gradle.properties defaults to a small daemon heap sized for- # scoped builds (./install all auto-escalates locally); cap heap +- # workers to runner-appropriate values via GRADLE_USER_HOME- # (~/.gradle)/gradle.properties, which overrides the project- # gradle.properties, here rather than changing the local dev defaults.- mkdir -p ~/.gradle- {- echo 'org.gradle.jvmargs=-Xmx6144m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -Dfile.encoding=UTF-8'- echo 'org.gradle.workers.max=2'- echo 'kotlin.daemon.jvm.options=-Xmx2048m'- echo 'android.compose.screenshot.maxHeapSize=2g'- } >> ~/.gradle/gradle.properties- echo "CI gradle overrides:" && cat ~/.gradle/gradle.properties-- # First thing the release actually checks. The store listings under metadata_data/ are- # consumed by "Prepare F-Droid Metadata" below, and a malformed one only shows up as a- # rejected listing at publish time, so fail here instead - before anything is built.- - name: Check Store Metadata- run: ./gradlew checkMetadata --console=plain-- - name: Read and Inject Version- id: version_info- run: |- VERSION_FILE="version.txt"- if [ ! -f "$VERSION_FILE" ]; then- echo "Error: $VERSION_FILE not found!"- exit 1- fi-- VERSION_CODE=$(sed -n '1p' "$VERSION_FILE" | tr -d '\r' | xargs)- VERSION_NAME=$(sed -n '2p' "$VERSION_FILE" | tr -d '\r' | xargs)-- echo "Using Version Name: $VERSION_NAME"- echo "Using Version Code: $VERSION_CODE"-- # Only inject version into real app modules (those using common-conventions-app).- # Explicitly exclude non-app modules: pjsip is an Android library,- # sdk/*, youpipe/extractor|ffmpeg, whatsapp-signal, tools/* are- # java/android libraries or host tools โ injecting versionCode would break them.- # Also exclude .git and build caches.- find . -mindepth 2 -name "build.gradle.kts" \- -not -path "./.git/*" \- -not -path "./.gradle/*" \- -not -path "*/build/*" \- -not -path "./library/*" \- -not -path "./pjsip/*" \- -not -path "./sdk/*" \- -not -path "./tools/*" \- -not -path "./whatsapp-signal/*" \- -not -path "./youpipe/extractor/*" \- -not -path "./watch/*" \- -not -path "./build-logic/*" | while read -r file; do- if grep -q "common-conventions-app" "$file"; then- echo "Injecting version into $file"- sed -i '/versionCode[[:space:]]*=[[:space:]]*/d' "$file"- sed -i '/versionName[[:space:]]*=[[:space:]]*/d' "$file"- sed -i "/defaultConfig[[:space:]]*{/a \ versionCode = $VERSION_CODE\n versionName = \"$VERSION_NAME\"" "$file"- else- echo "Skipping non-app module: $file"- fi- done-- echo "version_name=$VERSION_NAME" >> $GITHUB_OUTPUT- echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT-- - name: Detect App Modules- run: |- # App modules are identified by the common-conventions-app plugin,- # not by the presence of versionCode.- # Using find + grep is more robust than grep -r with exclude-dir on different platforms.- RAW_DIRS=$(find . -name "build.gradle.kts" \- -not -path "./.git/*" \- -not -path "./.gradle/*" \- -not -path "*/build/*" \- -not -path "./build-logic/*" \- -not -path "./library/*" \- -not -path "./pjsip/*" \- -not -path "./sdk/*" \- -not -path "./tools/*" \- -not -path "./whatsapp-signal/*" \- -not -path "./youpipe/extractor/*" \- -not -path "./watch/*" \- -exec grep -l "common-conventions-app" {} \; | \- sed 's|^\./||; s|/build.gradle.kts$||' | sort -u)-- echo "Detected app modules:"- echo "$RAW_DIRS"-- REVERSED_DIRS=$(echo "$RAW_DIRS" | tac | tr '\n' ' ')- echo "module_dirs=$REVERSED_DIRS" >> $GITHUB_ENV-- - name: Prepare F-Droid Metadata- run: |- # Play/F-Droid listing icons are generated here (only in CI) from each app's- # launcherIcon symbol + ic_launcher_background, instead of committing a- # per-app ic_launcher-playstore.png. Mirrors GenerateLauncherIconTask: the- # outlined Material Symbol glyph (black), scaled within a solid background.- sudo apt-get update -qq- sudo apt-get install -y -qq librsvg2-bin imagemagick >/dev/null- MATERIAL_SYMBOLS_REF="819d78680a849ceef4c78f863d8753e3160b7c89"- DEFAULT_BG="#FFFFFF"-- for dir in ${{ env.module_dirs }}; do- module_key=$(echo $dir | sed 's|/|-|g')- target_path="$dir/src/main/play/listings/en-US"-- mkdir -p "$target_path/graphics/icon"- mkdir -p "$target_path/graphics/phone-screenshots"-- # --- Generate the 512x512 Play Store icon ---- symbol=$(grep -oE 'symbol[[:space:]]*=[[:space:]]*"[^"]+"' "$dir/build.gradle.kts" 2>/dev/null | head -1 | sed -E 's/.*"([^"]+)".*/\1/')- if [ -n "$symbol" ]; then- # NOTE: these end in `grep`, which exits non-zero when there is no- # match. Under `bash -e` that would abort the whole step, so each is- # made non-fatal with `|| true` and falls back to a default below.- scale=$(grep -oE 'scale[[:space:]]*=[[:space:]]*[0-9.]+' "$dir/build.gradle.kts" 2>/dev/null | head -1 | grep -oE '[0-9.]+' || true)- scale=${scale:-0.58}- bg=$(grep -rhoE '<color name="ic_launcher_background">#[0-9A-Fa-f]+' "$dir/src/main/res" 2>/dev/null | head -1 | grep -oE '#[0-9A-Fa-f]+' || true)- bg=${bg:-$DEFAULT_BG}- glyph_px=$(awk "BEGIN{printf \"%d\", 512*$scale}")- svg_url="https://raw.githubusercontent.com/google/material-design-icons/$MATERIAL_SYMBOLS_REF/symbols/web/$symbol/materialsymbolsoutlined/${symbol}_24px.svg"- if curl -sf "$svg_url" -o /tmp/glyph.svg; then- rsvg-convert -w "$glyph_px" -h "$glyph_px" /tmp/glyph.svg -o /tmp/glyph.png- convert -size 512x512 "xc:$bg" /tmp/glyph.png -gravity center -composite "$target_path/graphics/icon/icon.png"- echo "Generated icon for $dir ($symbol on $bg, scale $scale)"- else- echo "WARNING: could not fetch Material Symbol '$symbol' for $dir"- fi- else- echo "WARNING: no launcherIcon symbol found for $dir"- fi-- screenshot_dir="metadata_data/photos/${module_key}"- screenshot_file="metadata_data/photos/${module_key}.png"- if [ -d "$screenshot_dir" ]; then- cp "$screenshot_dir"/*.png "$target_path/graphics/phone-screenshots/" 2>/dev/null || true- elif [ -f "$screenshot_file" ]; then- cp "$screenshot_file" "$target_path/graphics/phone-screenshots/1.png"- fi-- metadata_src="metadata_data/${module_key}.md"- if [ -f "$metadata_src" ]; then- head -n 1 "$metadata_src" > "$target_path/short-description.txt"- cp "$metadata_src" "$target_path/full-description.txt"- fi-- # --- Generate title.txt with MA branding (except FindFamily) ---- # Match app_name with any following attributes: most modules declare it as- # <string name="app_name" translatable="false">, which a fixed '...app_name">'- # pattern misses, silently falling through to the module-key fallback below.- app_name=$(grep -m1 -E '<string name="app_name"[^>]*>' "$dir/src/main/res/values/strings.xml" 2>/dev/null | sed -E 's/.*<string name="app_name"[^>]*>(.*)<\/string>.*/\1/' | xargs)- if [ -z "$app_name" ]; then- # Fallback: derive from module_key- app_name=$(echo "$module_key" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1')- fi- if [ "$module_key" = "findfamily" ]; then- title="$app_name"- else- case "$app_name" in- MA\ *) title="$app_name" ;;- *) title="MA $app_name" ;;- esac- fi- echo "$title" > "$target_path/title.txt"- echo "Generated title.txt for $dir: $title"- done-- - name: Local Git Commit and Tag- run: |- git config --global user.name "github-actions[bot]"- git config --global user.email "github-actions[bot]@users.noreply.github.com"- - # Stage only what the earlier steps write: the two root gradle files sed'd by- # "Clean Project Files", the per-module build.gradle.kts version injection, and- # the generated Play/F-Droid listings. Never `git add .` - that also picks up the- # decoded keystore, which this commit is reachable from once the tag is pushed.- git add -- settings.gradle.kts build.gradle.kts- for dir in ${{ env.module_dirs }}; do- git add -- "$dir/build.gradle.kts" "$dir/src/main/play/listings/en-US"- done-- VERSION_NAME="${{ steps.version_info.outputs.version_name }}"- - git commit -m "chore: prepare release $VERSION_NAME" || echo "No changes to commit"- git tag "$VERSION_NAME"-- - name: Install Rust Toolchain 1.97.0- run: |- set -e- TOOLCHAIN=$(grep -h 'channel =' rust-toolchain.toml | head -1 | cut -d'"' -f2)- if [ -z "$TOOLCHAIN" ]; then- echo "Error: could not read channel from rust-toolchain.toml" >&2- exit 1- fi- echo "Installing Rust toolchain $TOOLCHAIN + aarch64-linux-android"- rustup toolchain install $TOOLCHAIN --no-self-update --profile minimal- rustup target add aarch64-linux-android --toolchain $TOOLCHAIN- rustup default $TOOLCHAIN- rustc --version- cargo --version- rustup target list --installed --toolchain $TOOLCHAIN-- - name: Build and Sign APKs- env:- ks_store_pass: ${{ secrets.KS_STORE_PASS }}- ks_alias: ${{ secrets.KS_ALIAS }}- ks_alias_pass: ${{ secrets.KS_ALIAS_PASS }}- run: |- # Always build release APKs for every app module.- ./gradlew assembleRelease \- --no-daemon \- --max-workers=2 \- -x lint \- -x test \- -Pandroid.enableResourceOptimizations=true \- -Pandroid.enableR8.fullMode=true \- -PRELEASE_STORE_FILE="${{ github.workspace }}/${{ env.ks_filename }}" \- -PRELEASE_STORE_PASSWORD="$ks_store_pass" \- -PRELEASE_KEY_ALIAS="$ks_alias" \- -PRELEASE_KEY_PASSWORD="$ks_alias_pass"-- # Consolidate all generated APKs into one directory- mkdir -p distribution_apks- find . -path "*/build/outputs/apk/release/*.apk" -exec cp {} distribution_apks/ \;-- # Signing is done - get the key off disk before any third-party action runs.- # The `if: always()` Cleanup Keystore step below stays as a backstop for the- # case where the build fails before reaching this point.- rm -f "${{ env.ks_filename }}"-- - name: Push Tag Only- if: success()- run: |- VERSION_NAME="${{ steps.version_info.outputs.version_name }}"- git push origin "$VERSION_NAME"-- - name: Create GitHub Release- if: success()- uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3- with:- tag_name: "${{ steps.version_info.outputs.version_name }}"- name: "Release ${{ steps.version_info.outputs.version_name }}"- draft: true- body: |- Automated multi-module release.- Version Name: ${{ steps.version_info.outputs.version_name }}- Version Code: ${{ steps.version_info.outputs.version_code }}- files: distribution_apks/*.apk- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}-- - name: Cleanup Keystore- if: always()- run: rm -f ${{ env.ks_filename }}\ No newline at end of file
CONTRIBUTING.md
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 1f98ee8339..25d21aed5f 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -477,8 +477,8 @@ lint check would be the wrong way round. ## Store metadata -Every app module needs a `metadata_data/<module-key>.md`. `./release` (`release.bat` on Windows) and the release workflow-take line 1 as the store short description and the whole file as the full description, so the+Every app module needs a `metadata_data/<module-key>.md`. Line 1 is the store short+description and the whole file is the full description, so the format is strict and `./gradlew checkMetadata` enforces it both ways โ a missing file and an orphaned file are both errors. @@ -619,16 +619,3 @@ Drop the issue number if there isn't one. Use the module or area as the prefix. `.gitattributes` normalises the whole tree to LF, so you should never see a line-ending diff. If `git diff --stat` reports far more changed lines than you actually touched, your editor rewrote the file's line endings โ fix that rather than committing the churn.-------## Release--Releases are manual: the `๐ Publish Next Release` workflow is `workflow_dispatch` only.-`version.txt` holds the version code on line 1 and the version name on line 2, and both are-injected into every app module at release time. `./release` (`release.bat` on Windows) does the same locally and refuses-to run on a dirty tree.--Reproducible output is a standing requirement โ archives use fixed timestamps and ordering,-`SOURCE_DATE_EPOCH` comes from the last commit, and dependency metadata is stripped from the-APK.
SUPPLY_CHAIN_RISKS.md
diff --git a/SUPPLY_CHAIN_RISKS.md b/SUPPLY_CHAIN_RISKS.mdindex 72ad55572d..71982816bf 100644--- a/SUPPLY_CHAIN_RISKS.md+++ b/SUPPLY_CHAIN_RISKS.md@@ -301,16 +301,16 @@ build (see Verification status). --- -## 6. CI and release pipeline+## 6. CI pipeline -Four workflows: `android.yml` (release), `pr-compile-check.yml`, `cargo-deny.yml`, and-`issue_labeler.yml`.+Three workflows: `pr-compile-check.yml`, `cargo-deny.yml`, and+`issue_labeler.yml`. Releases are built outside CI. ### 6.1 Third-party action pinning โ control in place -Every third-party action across all four workflows is pinned to a full commit SHA with the tag in a+Every third-party action across all three workflows is pinned to a full commit SHA with the tag in a trailing comment: `actions/checkout`, `actions/setup-java`, `actions/github-script`,-`softprops/action-gh-release`, and `taiki-e/install-action`. A repointed upstream tag therefore+and `taiki-e/install-action`. A repointed upstream tag therefore cannot change what runs. Mitigation: keep the SHA form on every bump. The `github-actions` Dependabot ecosystem (ยง6.4)@@ -318,23 +318,23 @@ proposes them. ### 6.2 Signing key handling โ control in place -In `android.yml`, workflow-level `env:` holds only the non-secret keystore filename. `KS_STORE_PASS`,-`KS_ALIAS` and `KS_ALIAS_PASS` are step-level `env:` on the single "Build and Sign APKs" step, so-they are not in the environment of any other step. That step deletes the decoded keystore-immediately after collecting the APKs โ before `softprops/action-gh-release` runs โ and an-`if: always()` cleanup step is a backstop for a build that fails earlier.+Only the non-secret keystore filename is shared build state. The store password,+key alias and key password exist only in the environment of the single build-and-sign+step, so they are not visible to any other step. That step deletes the keystore copy+immediately after collecting the APKs โ before the release is created โ and an+unconditional cleanup is a backstop for a build that fails earlier (including cancel). The release commit stages explicit paths (`settings.gradle.kts`, `build.gradle.kts`, and each detected module's `build.gradle.kts` and generated listing directory) rather than `git add .`, so-the decoded keystore cannot be captured into a commit that the pushed tag is reachable from.+the keystore cannot be captured into a commit that the pushed tag is reachable from. -The job holds `contents: write`. `pr-compile-check.yml` and `cargo-deny.yml` are `contents: read`;+`pr-compile-check.yml` and `cargo-deny.yml` are `contents: read`; `issue_labeler.yml` is `issues: write`. ### 6.3 Rust version check โ control in place -The "Install Rust Toolchain" step greps the repository-root `rust-toolchain.toml` for its channel-and exits non-zero if the value is empty, so CI tracks the real pin instead of falling back to a+The release build's "Install Rust Toolchain" step greps the repository-root `rust-toolchain.toml` for its channel+and exits non-zero if the value is empty, so the build tracks the real pin instead of falling back to a hardcoded version. ### 6.4 Dependency monitoring โ control in place, JVM half missing@@ -355,35 +355,26 @@ today. Mitigation: add a JVM advisory scan (OWASP dependency-check or equivalent) to CI. -### 6.5 Release APK upload uses a shell script with an ambient token โ Low--`release.sh:165-168` uploads every built APK and a generated `index.json` with-`gh release create ... --draft`, using whatever credential the local `gh` CLI holds. This is the-manual counterpart to the `android.yml` release job and runs on a developer machine with a personal-token rather than a scoped `GITHUB_TOKEN`.--Mitigation: prefer the workflow path for real releases; keep `release.sh` for dry runs.--### 6.6 The PR check does not exercise the release toolchain โ Medium+### 6.5 The PR check does not exercise the release toolchain โ Medium `pr-compile-check.yml` is the only workflow that compiles application code on a pull request, and it-diverges from the release job in two ways that matter.+diverges from the release build in two ways that matter. -**It runs a different JDK.** `pr-compile-check.yml:20-24` sets up JDK 17; `android.yml:26-30` sets up-JDK 21. For routine code changes the gap is harmless. For a toolchain change โ an AGP major, a+**It runs a different JDK.** `pr-compile-check.yml:20-24` sets up JDK 17; the release build+uses JDK 21. For routine code changes the gap is harmless. For a toolchain change โ an AGP major, a Kotlin realignment โ the JDK is precisely the variable that bites, because toolchain resolution and Kotlin `jvmTarget` behaviour differ across the two. A green PR check on that class of diff does not-establish that the release job still builds.+establish that the release build still works. **It compiles and nothing else.** The PR check runs `./gradlew :compileDevKotlin` only, and the-release job runs `assembleRelease` with `-x lint -x test`. So neither workflow ever runs `lint` or+release build runs `assembleRelease` with `-x lint -x test`. So neither CI workflow ever runs `lint` or the test suite: the repo's own lint rules (including the build-failing ones) and every unit test are verified only by whoever remembers to run them locally. This bounds what CI can be relied on to catch, including for the unverified changes listed under Verification status. -Mitigation: align the PR check's JDK with the release job's, and run `lint` and `test` somewhere in+Mitigation: align the PR check's JDK with the release build's, and run `lint` and `test` somewhere in CI rather than excluding them from the one job that could. ---@@ -471,8 +462,9 @@ is needed. The residual trust is in GitHub serving the correct object for that S ### 7.5 Launcher icon fetch โ Low integrity risk, Medium availability risk `LauncherIconGen.kt` fetches Material Symbols sources from `raw.githubusercontent.com`, pinned to-the full commit SHA `819d78680a849ceef4c78f863d8753e3160b7c89`, which is also the SHA used by the-second, separate fetch of the same upstream in `android.yml:174` for Play/F-Droid listing icons.+the full commit SHA `819d78680a849ceef4c78f863d8753e3160b7c89`. The release build performs a+second, separate fetch of the same upstream for Play/F-Droid listing icons, pinned to the same+SHA. Results are cached under `$GRADLE_USER_HOME/material-symbols-cache/<ref>/`, and a cache hit skips the download. @@ -482,7 +474,7 @@ plus TLS. Availability is the sharper edge. The fetch is reached from 72 `launcherIcon` blocks across the app modules, and a failure throws `GradleException` โ so on a cold cache without GitHub reachability the-build fails outright rather than degrading. The `android.yml` copy is softer: it warns and continues+build fails outright rather than degrading. The release builder copy is softer: it warns and continues without an icon. Mitigation: vendor the icon sources to remove the build-time network dependency entirely, or record@@ -912,14 +904,13 @@ up above, this section only names the host. `dl.google.com`, `repo.maven.apache.org` and `plugins.gradle.org` (no verification metadata, ยง1.1); `build-artifacts.signal.org` (ยง2.1); `crates.io` (`--locked`, ยง4); `static.rust-lang.org`; `proxy.golang.org`, `sum.golang.org` and `github.com` for the unblockjam Go tools (hash-pinned);-`cdn.azul.com` for the JDK; Ubuntu apt mirrors; `github.com` for Actions; and `api.github.com`,-including the `gh release create` upload in `release.sh` (ยง6.5).+`cdn.azul.com` for the JDK; Ubuntu apt mirrors; `github.com` for Actions; and `api.github.com`. **`raw.githubusercontent.com` โ five consumers.** | Consumer | Pinning | |---|---|-| Material Symbols (`LauncherIconGen.kt`, plus the second site at `android.yml:174`) | Full commit SHA (ยง7.5) |+| Material Symbols (`LauncherIconGen.kt`, plus the second fetch in the release build) | Full commit SHA (ยง7.5) | | simdjson and zstd (`scripts/geocoder_gen.sh`) | Full commit SHAs (ยง7.4) | | brave/adblock-resources | **`master` โ mutable, unpinned** | | gorhill/uBlock | **`master` โ mutable, unpinned, and executed** (Highest-severity findings) |
build-logic/src/main/kotlin/RustNative.kt
diff --git a/build-logic/src/main/kotlin/RustNative.kt b/build-logic/src/main/kotlin/RustNative.ktindex 2a9a1ef816..0cfcf03a70 100644--- a/build-logic/src/main/kotlin/RustNative.kt+++ b/build-logic/src/main/kotlin/RustNative.kt@@ -228,7 +228,7 @@ fun Project.rustNativeLib( environment("CXXFLAGS", "-ffile-prefix-map=$cargoHome=/cargo -ffile-prefix-map=$rustSrc=/$remapLabel -Wdate-time -Werror=date-time") environment("CPPFLAGS", "-ffile-prefix-map=$cargoHome=/cargo -ffile-prefix-map=$rustSrc=/$remapLabel -Wdate-time -Werror=date-time") environment("ZERO_AR_DATE", "1")- // Reproducible builds: respect SOURCE_DATE_EPOCH if set (exported by release.sh / CI)+ // Reproducible builds: respect SOURCE_DATE_EPOCH if set (exported by the release build) // https://reproducible-builds.org/docs/source-date-epoch/ System.getenv("SOURCE_DATE_EPOCH")?.takeIf { it.isNotBlank() }?.let { environment("SOURCE_DATE_EPOCH", it)
build-logic/src/main/kotlin/common-conventions-preview-metadata.gradle.kts
diff --git a/build-logic/src/main/kotlin/common-conventions-preview-metadata.gradle.kts b/build-logic/src/main/kotlin/common-conventions-preview-metadata.gradle.ktsindex 2ec966db89..e67338486d 100644--- a/build-logic/src/main/kotlin/common-conventions-preview-metadata.gradle.kts+++ b/build-logic/src/main/kotlin/common-conventions-preview-metadata.gradle.kts@@ -7,7 +7,7 @@ import org.gradle.api.tasks.bundling.AbstractArchiveTask // // Apply this INSTEAD OF `common-conventions-metadata` on an app whose screens have been // split into stateless composables. It registers the same `metadata` task name, so-// `./gradlew :calculator:metadata` keeps working and `release.sh` needs no change โ but it+// `./gradlew :calculator:metadata` keeps working with the release build โ but it // needs no emulator, no adb, and no `pm clear` of a real device. // // ./gradlew :calculator:metadata
build.gradle.kts
diff --git a/build.gradle.kts b/build.gradle.ktsindex 4895bc0294..1c081a491a 100644--- a/build.gradle.kts+++ b/build.gradle.kts@@ -44,8 +44,8 @@ tasks.register("fixStrings") { } } -// Store listings are generated from metadata_data/<module-key>.md by release.sh and the-// "Prepare F-Droid Metadata" step of .github/workflows/android.yml, both of which take line 1+// Store listings are generated from metadata_data/<module-key>.md by the release build,+// which takes line 1 // as the short description and the whole file as the full description. Play and F-Droid cap a // summary at 80 characters, and nothing else in the build looks at these files, so the format // is enforced here. Required shape, exactly:@@ -124,7 +124,7 @@ tasks.register("checkMetadata") { val metadataDir = File(projectRoot, "metadata_data") - // release.sh and android.yml find app modules by grepping for the bare string+ // Module detection by grepping for the bare string // "common-conventions-app", which also matches library/map, where it appears only in a // comment. Matching the plugin application instead keeps this list to real apps. val appPlugin = Regex("""id\("common-conventions-app"\)""")
release
diff --git a/release b/releasedeleted file mode 100755index 916f6983fe..0000000000--- a/release+++ /dev/null@@ -1,178 +0,0 @@-#!/bin/bash--# release.sh - Local script to prepare release, build, tag, and push (Headless mode)-set -e--# 0. Environment check: Ensure working directory is clean-if [[ -n $(git status --porcelain) ]]; then- echo "โ Error: Your working directory is not clean."- echo "Please commit or stash your changes before running the release script."- exit 1-fi--# Check for GitHub CLI (gh)-if ! command -v gh &> /dev/null; then- echo "โ ๏ธ Warning: 'gh' (GitHub CLI) is not installed. Release creation will be skipped."- echo " Install it with: sudo apt install gh (on Debian/Ubuntu)"- HAS_GH=false-else- HAS_GH=true-fi--ORIGINAL_COMMIT=$(git rev-parse HEAD)-VERSION_FILE="version.txt"--if [ ! -f "$VERSION_FILE" ]; then- echo "Error: $VERSION_FILE not found!"- exit 1-fi--VERSION_CODE=$(sed -n '1p' "$VERSION_FILE" | tr -d '\r' | xargs)-VERSION_NAME=$(sed -n '2p' "$VERSION_FILE" | tr -d '\r' | xargs)--export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)-echo "๐ SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH for reproducible builds"--echo "๐ Preparing headless release $VERSION_NAME ($VERSION_CODE)..."--# 1. Inject version into build.gradle.kts files-echo "๐ Injecting versions into sub-module build.gradle.kts files..."-find . -mindepth 2 -name "build.gradle.kts" | while read file; do- if [[ "$file" == *"build-logic"* ]]; then continue; fi- sed -i '/versionCode[[:space:]]*=[[:space:]]*/d' "$file"- sed -i '/versionName[[:space:]]*=[[:space:]]*/d' "$file"- sed -i "/defaultConfig[[:space:]]*{/a \ versionCode = $VERSION_CODE\n versionName = \"$VERSION_NAME\"" "$file"-done--# 2. Prepare F-Droid Metadata-echo "๐ฆ Preparing F-Droid metadata..."-MODULE_DIRS=$(find . -mindepth 2 -name "build.gradle.kts" | sed 's|^\./||; s|/build.gradle.kts$||' | sort -u)--for dir in $MODULE_DIRS; do- module_key=$(echo $dir | sed 's|/|-|g')- target_path="$dir/src/main/play/listings/en-US"- if [ -f "metadata_data/${module_key}.md" ] || [ -f "$dir/src/main/ic_launcher-playstore.png" ]; then- mkdir -p "$target_path/graphics/icon"- mkdir -p "$target_path/graphics/phone-screenshots"- if [ -f "$dir/src/main/ic_launcher-playstore.png" ]; then cp "$dir/src/main/ic_launcher-playstore.png" "$target_path/graphics/icon/icon.png"; fi- if [ -d "metadata_data/photos/${module_key}" ]; then- i=1- for shot in $(ls "metadata_data/photos/${module_key}"/*.png 2>/dev/null | sort -V); do- cp "$shot" "$target_path/graphics/phone-screenshots/${i}.png"- i=$((i + 1))- done- elif [ -f "metadata_data/photos/${module_key}.png" ]; then- cp "metadata_data/photos/${module_key}.png" "$target_path/graphics/phone-screenshots/1.png"- fi- if [ -f "metadata_data/${module_key}.md" ]; then- head -n 1 "metadata_data/${module_key}.md" > "$target_path/short-description.txt"- cp "metadata_data/${module_key}.md" "$target_path/full-description.txt"- fi- fi-done--# 3. Git Commit and Tag (Done BEFORE build so build sees committed state)-echo "๐พ Creating temporary commit and tag..."-# Reproducible builds: make commit/tag timestamps deterministic using SOURCE_DATE_EPOCH-# so the tag object doesn't embed wall-clock time and can be verified.-export GIT_AUTHOR_DATE="@${SOURCE_DATE_EPOCH}"-export GIT_COMMITTER_DATE="@${SOURCE_DATE_EPOCH}"-git add .-git commit -m "chore: prepare release $VERSION_NAME" || { echo "No changes to commit"; exit 1; }-git tag -a "$VERSION_NAME" -m "Release $VERSION_NAME"--# 4. Build Apps (Parallel with Worker Limits)-echo "๐จ Building all app modules in parallel (constrained)..."-# Detect modules that apply the app conventions-APP_MODULES=$(grep -r "common-conventions-app" . --include="build.gradle.kts" | cut -d: -f1 | sed 's|^\./||; s|/build.gradle.kts$||' | sort -u)-TASKS=$(echo "$APP_MODULES" | sed 's|^|:|; s|/|:|g; s|$|:assembleRelease|' | tr '\n' ' ')--rm -rf distribution_apks-mkdir -p distribution_apks--# - --parallel: Build modules in parallel-# - --max-workers=2: Strictly limit concurrent tasks to prevent memory spikes-# - --no-daemon: Use a fresh process to ensure memory is released after build-./gradlew $TASKS \- --parallel \- --max-workers=2 \- --no-daemon \- -x lint \- -x test \- -Pandroid.enableResourceOptimizations=true \- -Pandroid.enableR8.fullMode=true \- -Dorg.gradle.jvmargs="-Xmx6g -XX:MaxMetaspaceSize=1g"--# 5. Consolidate APKs-echo "๐ Collecting APKs into distribution_apks/..."-find . -path "*/build/outputs/apk/release/*.apk" -exec cp {} distribution_apks/ \;--# 5b. Build index.json for the :appstore "Modern Apps" source.-# The store cannot map an asset filename back to a package name on its own-# (:games:chess builds chess-release.apk but installs as com.vayunmathur.games.chess),-# so the release has to state it. This index is NOT signed and does not need to be:-# :appstore verifies every APK from this source against its own signing certificate,-# so a rewritten index can change which bytes are offered but not which bytes install.-echo "๐งพ Generating distribution_apks/index.json..."-AAPT2=$(ls -1 "${ANDROID_HOME:-$HOME/Library/Android/sdk}"/build-tools/*/aapt2 2>/dev/null | sort -V | tail -1)-if [ -z "$AAPT2" ]; then- echo "โ aapt2 not found under \$ANDROID_HOME/build-tools; cannot generate index.json"- exit 1-fi--{- printf '{\n "versionCode": %s,\n "versionName": "%s",\n "apps": [\n' "$VERSION_CODE" "$VERSION_NAME"- first=true- for apk in distribution_apks/*.apk; do- [ -e "$apk" ] || continue- badging=$("$AAPT2" dump badging "$apk" 2>/dev/null)- pkg=$(echo "$badging" | sed -n "s/^package: name='\([^']*\)'.*/\1/p")- vcode=$(echo "$badging" | sed -n "s/^package:.*versionCode='\([^']*\)'.*/\1/p")- vname=$(echo "$badging" | sed -n "s/^package:.*versionName='\([^']*\)'.*/\1/p")- tsdk=$(echo "$badging" | sed -n "s/^targetSdkVersion:'\([^']*\)'.*/\1/p")- label=$(echo "$badging" | sed -n "s/^application-label:'\([^']*\)'.*/\1/p")- if [ -z "$pkg" ]; then- echo "โ ๏ธ Skipping $apk (aapt2 could not read a package name)" >&2- continue- fi- [ -n "$label" ] || label="$pkg"- sha=$(shasum -a 256 "$apk" | cut -d' ' -f1)- size=$(wc -c < "$apk" | tr -d ' ')- # Short description = first line of the F-Droid metadata, when there is one.- module_key=$(grep -rl "applicationId = \"$pkg\"" --include=build.gradle.kts . 2>/dev/null \- | head -1 | sed 's|^\./||; s|/build.gradle.kts$||; s|/|-|g')- summary=""- if [ -n "$module_key" ] && [ -f "metadata_data/${module_key}.md" ]; then- summary=$(head -n 1 "metadata_data/${module_key}.md" | sed 's/\\/\\\\/g; s/"/\\"/g')- fi- $first || printf ',\n'- first=false- printf ' {"packageName": "%s", "label": "%s", "apk": "%s", "sha256": "%s", "size": %s, "versionCode": %s, "versionName": "%s", "targetSdk": %s, "summary": "%s"}' \- "$pkg" "$(echo "$label" | sed 's/\\/\\\\/g; s/"/\\"/g')" "$(basename "$apk")" \- "$sha" "$size" "${vcode:-0}" "${vname:-$VERSION_NAME}" "${tsdk:-0}" "$summary"- done- printf '\n ]\n}\n'-} > distribution_apks/index.json--echo " $(grep -c '"packageName"' distribution_apks/index.json) apps indexed"--# 6. Push Tag and Create GitHub Release-echo "๐ค Pushing tag $VERSION_NAME to origin..."-git push origin "$VERSION_NAME"--if [ "$HAS_GH" = true ]; then- echo "๐ Creating GitHub Release..."- gh release create "$VERSION_NAME" distribution_apks/*.apk distribution_apks/index.json \- --title "Release $VERSION_NAME" \- --notes "Automated multi-module release. Version Code: $VERSION_CODE" \- --draft- echo "โ Release created as a draft."-else- echo "โ ๏ธ Skipping GitHub Release creation (gh CLI not found)."-fi--# 7. Restore local branch state (Headless effect)-echo "๐งน Restoring local branch to original state ($ORIGINAL_COMMIT)..."-git reset --hard "$ORIGINAL_COMMIT"--echo "โ Done! All apps built and tag pushed."
release.bat
diff --git a/release.bat b/release.batdeleted file mode 100644index 1700721686..0000000000--- a/release.bat+++ /dev/null@@ -1,339 +0,0 @@-<# :-@echo off-setlocal-where pwsh >nul 2>nul-if %errorlevel%==0 ( set "PSBIN=pwsh" ) else ( set "PSBIN=powershell" )-%PSBIN% -NoProfile -ExecutionPolicy Bypass -Command "$env:_BATROOT='%~dp0'; $env:_BATPATH='%~f0'; & ([scriptblock]::Create((Get-Content -Raw '%~f0'))) %*"-exit /b %errorlevel%-: end batch #>-# release.bat - Local script to prepare release, build, tag, and push (headless mode).-# (PowerShell twin of ./release.)-$ErrorActionPreference = 'Stop'--$ReleaseRoot = if ($PSScriptRoot) { $PSScriptRoot } else { $env:_BATROOT.TrimEnd('\') }-Set-Location -LiteralPath $ReleaseRoot--function Invoke-ReleaseGit([string[]]$GitArgs) {- $ReleasePrevPref = $ErrorActionPreference- $ErrorActionPreference = 'Continue'- $ReleaseOut = & git @GitArgs 2>&1- $ReleaseRc = $LASTEXITCODE- $ErrorActionPreference = $ReleasePrevPref- return @{ Out = @($ReleaseOut); Rc = $ReleaseRc }-}--function ConvertTo-ReleaseRelative([string]$FullPath) {- $ReleaseSlash = $FullPath.Replace('\', '/')- $ReleaseRootSlash = $ReleaseRoot.Replace('\', '/').TrimEnd('/')- if ($ReleaseSlash.StartsWith("$ReleaseRootSlash/")) {- return $ReleaseSlash.Substring($ReleaseRootSlash.Length + 1)- }- return $ReleaseSlash-}--function Get-ReleaseJsonString([string]$S) {- return ($S -replace '\\', '\\' -replace '"', '\"')-}--# 0. Environment check: Ensure working directory is clean-$ReleaseStatus = Invoke-ReleaseGit @('status', '--porcelain')-if (($ReleaseStatus.Out | Where-Object { [string]$_ -ne '' }).Count -gt 0) {- Write-Output 'Error: Your working directory is not clean.'- Write-Output 'Please commit or stash your changes before running the release script.'- exit 1-}--# Check for GitHub CLI (gh)-$ReleaseGhCmd = Get-Command gh -ErrorAction SilentlyContinue-if (-not $ReleaseGhCmd) {- Write-Output "Warning: 'gh' (GitHub CLI) is not installed. Release creation will be skipped."- Write-Output ' Install it from https://cli.github.com/ (winget install GitHub.cli)'- $ReleaseHasGh = $false-}-else {- $ReleaseHasGh = $true-}--$ReleaseHead = Invoke-ReleaseGit @('rev-parse', 'HEAD')-$ReleaseOriginalCommit = ([string]$ReleaseHead.Out[0]).Trim()-$ReleaseVersionFile = Join-Path $ReleaseRoot 'version.txt'--if (-not (Test-Path -LiteralPath $ReleaseVersionFile -PathType Leaf)) {- Write-Output 'Error: version.txt not found!'- exit 1-}--$ReleaseVersionLines = [System.IO.File]::ReadAllLines($ReleaseVersionFile)-$ReleaseVersionCode = ([string]$ReleaseVersionLines[0]).Trim()-$ReleaseVersionName = ([string]$ReleaseVersionLines[1]).Trim()--$ReleaseEpoch = Invoke-ReleaseGit @('log', '-1', '--pretty=%ct')-$env:SOURCE_DATE_EPOCH = ([string]$ReleaseEpoch.Out[0]).Trim()-Write-Output "SOURCE_DATE_EPOCH=$($env:SOURCE_DATE_EPOCH) for reproducible builds"--Write-Output "Preparing headless release $ReleaseVersionName ($ReleaseVersionCode)..."--# 1. Inject version into build.gradle.kts files-Write-Output 'Injecting versions into sub-module build.gradle.kts files...'-$ReleaseBuildFiles = Get-ChildItem -LiteralPath $ReleaseRoot -Recurse -Filter 'build.gradle.kts' -File -Force -ErrorAction SilentlyContinue |- Where-Object { $_.FullName.Replace('\', '/') -notlike '*/build-logic/*' }-foreach ($ReleaseBf in $ReleaseBuildFiles) {- $ReleaseLines = [System.IO.File]::ReadAllLines($ReleaseBf.FullName)- $ReleaseKept = @()- foreach ($ReleaseLine in $ReleaseLines) {- if ($ReleaseLine -match 'versionCode\s*=') { continue }- if ($ReleaseLine -match 'versionName\s*=') { continue }- $ReleaseKept += $ReleaseLine- }- $ReleaseInjected = @()- foreach ($ReleaseLine in $ReleaseKept) {- $ReleaseInjected += $ReleaseLine- if ($ReleaseLine -match 'defaultConfig\s*\{') {- $ReleaseInjected += " versionCode = $ReleaseVersionCode"- $ReleaseInjected += " versionName = `"$ReleaseVersionName`""- }- }- [System.IO.File]::WriteAllLines($ReleaseBf.FullName, $ReleaseInjected)-}--# 2. Prepare F-Droid Metadata-Write-Output 'Preparing F-Droid metadata...'-$ReleaseModuleDirs = @($ReleaseBuildFiles |- ForEach-Object { ConvertTo-ReleaseRelative $_.FullName } |- ForEach-Object { [regex]::Replace($_, '/build\.gradle\.kts$', '') } |- Sort-Object -Unique)-foreach ($ReleaseDir in $ReleaseModuleDirs) {- $ReleaseModuleKey = $ReleaseDir.Replace('/', '-')- $ReleaseTargetPath = Join-Path $ReleaseRoot "$ReleaseDir/src/main/play/listings/en-US"- $ReleaseMd = Join-Path $ReleaseRoot "metadata_data/$ReleaseModuleKey.md"- $ReleaseIcon = Join-Path $ReleaseRoot "$ReleaseDir/src/main/ic_launcher-playstore.png"- if ((Test-Path -LiteralPath $ReleaseMd) -or (Test-Path -LiteralPath $ReleaseIcon)) {- New-Item -ItemType Directory -Force -Path "$ReleaseTargetPath/graphics/icon" | Out-Null- New-Item -ItemType Directory -Force -Path "$ReleaseTargetPath/graphics/phone-screenshots" | Out-Null- if (Test-Path -LiteralPath $ReleaseIcon) {- Copy-Item -LiteralPath $ReleaseIcon -Destination "$ReleaseTargetPath/graphics/icon/icon.png" -Force- }- $ReleasePhotosDir = Join-Path $ReleaseRoot "metadata_data/photos/$ReleaseModuleKey"- $ReleasePhotoFile = Join-Path $ReleaseRoot "metadata_data/photos/$ReleaseModuleKey.png"- if (Test-Path -LiteralPath $ReleasePhotosDir -PathType Container) {- $ReleaseI = 1- # natural (version) sort like `sort -V`: 2.png before 10.png.- $ReleaseShots = Get-ChildItem -LiteralPath $ReleasePhotosDir -Filter '*.png' -File |- Sort-Object { [regex]::Replace($_.Name, '\d+', { param($M) $M.Value.PadLeft(10, '0') }) }- foreach ($ReleaseShot in $ReleaseShots) {- Copy-Item -LiteralPath $ReleaseShot.FullName -Destination "$ReleaseTargetPath/graphics/phone-screenshots/$ReleaseI.png" -Force- $ReleaseI++- }- }- elseif (Test-Path -LiteralPath $ReleasePhotoFile) {- Copy-Item -LiteralPath $ReleasePhotoFile -Destination "$ReleaseTargetPath/graphics/phone-screenshots/1.png" -Force- }- if (Test-Path -LiteralPath $ReleaseMd) {- $ReleaseMdLines = [System.IO.File]::ReadAllLines($ReleaseMd)- [System.IO.File]::WriteAllText("$ReleaseTargetPath/short-description.txt", $ReleaseMdLines[0])- Copy-Item -LiteralPath $ReleaseMd -Destination "$ReleaseTargetPath/full-description.txt" -Force- }- }-}--# 3. Git Commit and Tag (Done BEFORE build so build sees committed state)-Write-Output 'Creating temporary commit and tag...'-# Reproducible builds: make commit/tag timestamps deterministic using SOURCE_DATE_EPOCH-# so the tag object doesn't embed wall-clock time and can be verified.-$env:GIT_AUTHOR_DATE = "@$($env:SOURCE_DATE_EPOCH)"-$env:GIT_COMMITTER_DATE = "@$($env:SOURCE_DATE_EPOCH)"-$ReleaseAdd = Invoke-ReleaseGit @('add', '.')-$ReleaseCommit = Invoke-ReleaseGit @('commit', '-m', "chore: prepare release $ReleaseVersionName")-if ($ReleaseCommit.Rc -ne 0) {- Write-Output 'No changes to commit'- exit 1-}-$ReleaseTag = Invoke-ReleaseGit @('tag', '-a', $ReleaseVersionName, '-m', "Release $ReleaseVersionName")-if ($ReleaseTag.Rc -ne 0) {- Write-Output "Error: git tag failed: $($ReleaseTag.Out -join ' ')"- exit 1-}--# 4. Build Apps (Parallel with Worker Limits)-Write-Output 'Building all app modules in parallel (constrained)...'-# Detect modules that apply the app conventions-$ReleaseAppModules = @()-foreach ($ReleaseBf in $ReleaseBuildFiles) {- if (Select-String -LiteralPath $ReleaseBf.FullName -Pattern 'common-conventions-app' -Quiet) {- $ReleaseAppModules += [regex]::Replace((ConvertTo-ReleaseRelative $ReleaseBf.FullName), '/build\.gradle\.kts$', '')- }-}-$ReleaseAppModules = @($ReleaseAppModules | Sort-Object -Unique)-$ReleaseTasks = @()-foreach ($ReleaseMod in $ReleaseAppModules) {- $ReleaseTasks += ":$($ReleaseMod.Replace('/', ':')):assembleRelease"-}--$ReleaseDistDir = Join-Path $ReleaseRoot 'distribution_apks'-if (Test-Path -LiteralPath $ReleaseDistDir) { Remove-Item -LiteralPath $ReleaseDistDir -Recurse -Force }-New-Item -ItemType Directory -Force -Path $ReleaseDistDir | Out-Null--# - --parallel: Build modules in parallel-# - --max-workers=2: Strictly limit concurrent tasks to prevent memory spikes-# - --no-daemon: Use a fresh process to ensure memory is released after build-$ReleaseGradlewBat = Join-Path $ReleaseRoot 'gradlew.bat'-$ReleaseGradlewSh = Join-Path $ReleaseRoot 'gradlew'-$ReleaseBashCmd = Get-Command bash -ErrorAction SilentlyContinue-$ReleasePrevPref = $ErrorActionPreference-$ErrorActionPreference = 'Continue'-$ReleaseGradleArgs = @($ReleaseTasks) + @(- '--parallel', '--max-workers=2', '--no-daemon',- '-x', 'lint', '-x', 'test',- '-Pandroid.enableResourceOptimizations=true',- '-Pandroid.enableR8.fullMode=true',- '-Dorg.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=1g'-)-if ((Test-Path -LiteralPath $ReleaseGradlewBat) -and ($env:OS -eq 'Windows_NT')) {- & $ReleaseGradlewBat @ReleaseGradleArgs- $ReleaseBuildRc = $LASTEXITCODE-}-elseif ($ReleaseBashCmd -and (Test-Path -LiteralPath $ReleaseGradlewSh)) {- & $ReleaseBashCmd.Source $ReleaseGradlewSh @ReleaseGradleArgs- $ReleaseBuildRc = $LASTEXITCODE-}-else {- $ErrorActionPreference = $ReleasePrevPref- Write-Output 'Error: no Gradle wrapper found (gradlew.bat / gradlew).'- exit 1-}-$ErrorActionPreference = $ReleasePrevPref-if ($ReleaseBuildRc -ne 0) {- Write-Output "Error: Gradle build failed (exit $ReleaseBuildRc)."- exit 1-}--# 5. Consolidate APKs-Write-Output 'Collecting APKs into distribution_apks/...'-Get-ChildItem -LiteralPath $ReleaseRoot -Recurse -Filter '*.apk' -File -Force -ErrorAction SilentlyContinue |- Where-Object { $_.FullName.Replace('\', '/') -like '*/build/outputs/apk/release/*.apk' } |- ForEach-Object { Copy-Item -LiteralPath $_.FullName -Destination $ReleaseDistDir -Force }--# 5b. Build index.json for the :appstore "Modern Apps" source.-# The store cannot map an asset filename back to a package name on its own-# (:games:chess builds chess-release.apk but installs as com.vayunmathur.games.chess),-# so the release has to state it. This index is NOT signed and does not need to be:-# :appstore verifies every APK from this source against its own signing certificate,-# so a rewritten index can change which bytes are offered but not which bytes install.-Write-Output 'Generating distribution_apks/index.json...'-$ReleaseSdkBase = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } elseif ($env:ANDROID_SDK_ROOT) { $env:ANDROID_SDK_ROOT } else { Join-Path $HOME 'Library/Android/sdk' }-if ($env:LOCALAPPDATA -and (-not (Test-Path -LiteralPath (Join-Path $ReleaseSdkBase 'build-tools')))) {- $ReleaseSdkBase = Join-Path $env:LOCALAPPDATA 'Android/Sdk'-}-$ReleaseAapt2 = Get-ChildItem -LiteralPath (Join-Path $ReleaseSdkBase 'build-tools') -Filter 'aapt2*' -File -Recurse -ErrorAction SilentlyContinue |- Sort-Object FullName | Select-Object -Last 1-if (-not $ReleaseAapt2) {- Write-Output 'Error: aapt2 not found under $ANDROID_HOME/build-tools; cannot generate index.json'- exit 1-}--# 5b index helpers (ConvertTo-ReleaseRelative, Get-ReleaseJsonString) are defined-# at the top next to Invoke-ReleaseGit: PowerShell executes straight-line code-# in order, so helpers must be defined before step 2 calls them.-$ReleaseIndexPath = Join-Path $ReleaseDistDir 'index.json'-$ReleaseIndexLines = @(- '{',- " `"versionCode`": $ReleaseVersionCode,",- " `"versionName`": `"$ReleaseVersionName`",",- ' "apps": ['-)-$ReleaseFirst = $true-$ReleaseApks = @(Get-ChildItem -LiteralPath $ReleaseDistDir -Filter '*.apk' -File | Sort-Object Name)-foreach ($ReleaseApk in $ReleaseApks) {- $ReleaseBadging = & $ReleaseAapt2.FullName dump badging $ReleaseApk.FullName 2>$null- $ReleaseBadgingText = ($ReleaseBadging -join "`n")- $ReleasePkg = ''- $ReleaseVcode = ''- $ReleaseVname = ''- $ReleaseTsdk = ''- $ReleaseLabel = ''- $ReleaseM = [regex]::Match($ReleaseBadgingText, "^package: name='([^']*)'", 'Multiline')- if ($ReleaseM.Success) { $ReleasePkg = $ReleaseM.Groups[1].Value }- $ReleaseM = [regex]::Match($ReleaseBadgingText, "versionCode='([^']*)'")- if ($ReleaseM.Success) { $ReleaseVcode = $ReleaseM.Groups[1].Value }- $ReleaseM = [regex]::Match($ReleaseBadgingText, "versionName='([^']*)'")- if ($ReleaseM.Success) { $ReleaseVname = $ReleaseM.Groups[1].Value }- $ReleaseM = [regex]::Match($ReleaseBadgingText, "^targetSdkVersion:'([^']*)'", 'Multiline')- if ($ReleaseM.Success) { $ReleaseTsdk = $ReleaseM.Groups[1].Value }- $ReleaseM = [regex]::Match($ReleaseBadgingText, "^application-label:'([^']*)'", 'Multiline')- if ($ReleaseM.Success) { $ReleaseLabel = $ReleaseM.Groups[1].Value }- if (-not $ReleasePkg) {- Write-Output "Warning: Skipping $($ReleaseApk.Name) (aapt2 could not read a package name)"- continue- }- if (-not $ReleaseLabel) { $ReleaseLabel = $ReleasePkg }- $ReleaseSha = (Get-FileHash -LiteralPath $ReleaseApk.FullName -Algorithm SHA256).Hash.ToLowerInvariant()- $ReleaseSize = (Get-Item -LiteralPath $ReleaseApk.FullName).Length- # Short description = first line of the F-Droid metadata, when there is one.- $ReleaseFoundBuild = ''- foreach ($ReleaseBf in $ReleaseBuildFiles) {- if (Select-String -LiteralPath $ReleaseBf.FullName -Pattern "applicationId = `"$ReleasePkg`"" -SimpleMatch -Quiet) {- $ReleaseFoundBuild = $ReleaseBf.FullName- break- }- }- $ReleaseSummary = ''- if ($ReleaseFoundBuild) {- $ReleaseModKey = [regex]::Replace((ConvertTo-ReleaseRelative $ReleaseFoundBuild), '/build\.gradle\.kts$', '').Replace('/', '-')- $ReleaseMdPath = Join-Path $ReleaseRoot "metadata_data/$ReleaseModKey.md"- if (Test-Path -LiteralPath $ReleaseMdPath) {- $ReleaseSummary = Get-ReleaseJsonString ([System.IO.File]::ReadAllLines($ReleaseMdPath)[0])- }- }- if (-not $ReleaseFirst) { $ReleaseIndexLines += ',' }- $ReleaseFirst = $false- if (-not $ReleaseVcode) { $ReleaseVcode = '0' }- if (-not $ReleaseVname) { $ReleaseVname = $ReleaseVersionName }- if (-not $ReleaseTsdk) { $ReleaseTsdk = '0' }- $ReleaseIndexLines[-1] += " {`"packageName`": `"$ReleasePkg`", `"label`": `"$(Get-ReleaseJsonString $ReleaseLabel)`", `"apk`": `"$($ReleaseApk.Name)`", `"sha256`": `"$ReleaseSha`", `"size`": $ReleaseSize, `"versionCode`": $ReleaseVcode, `"versionName`": `"$(Get-ReleaseJsonString $ReleaseVname)`", `"targetSdk`": $ReleaseTsdk, `"summary`": `"$ReleaseSummary`"}"-}-$ReleaseIndexLines += ' ]'-$ReleaseIndexLines += '}'-[System.IO.File]::WriteAllLines($ReleaseIndexPath, $ReleaseIndexLines)--$ReleaseIndexed = ([regex]::Matches([System.IO.File]::ReadAllText($ReleaseIndexPath), '"packageName"')).Count-Write-Output " $ReleaseIndexed apps indexed"--# 6. Push Tag and Create GitHub Release-Write-Output "Pushing tag $ReleaseVersionName to origin..."-$ReleasePush = Invoke-ReleaseGit @('push', 'origin', $ReleaseVersionName)-if ($ReleasePush.Rc -ne 0) {- Write-Output "Error: git push failed: $($ReleasePush.Out -join ' ')"- exit 1-}--if ($ReleaseHasGh) {- Write-Output 'Creating GitHub Release...'- $ReleaseAssets = @((Get-ChildItem -LiteralPath $ReleaseDistDir -Filter '*.apk' -File | ForEach-Object { $_.FullName })) + @($ReleaseIndexPath)- $ReleasePrevPref = $ErrorActionPreference- $ErrorActionPreference = 'Continue'- & $ReleaseGhCmd.Source release create $ReleaseVersionName @ReleaseAssets `- --title "Release $ReleaseVersionName" `- --notes "Automated multi-module release. Version Code: $ReleaseVersionCode" `- --draft- $ReleaseGhRc = $LASTEXITCODE- $ErrorActionPreference = $ReleasePrevPref- if ($ReleaseGhRc -ne 0) {- Write-Output "Error: gh release create failed (exit $ReleaseGhRc)."- exit 1- }- Write-Output 'Release created as a draft.'-}-else {- Write-Output 'Skipping GitHub Release creation (gh CLI not found).'-}--# 7. Restore local branch state (Headless effect)-Write-Output "Restoring local branch to original state ($ReleaseOriginalCommit)..."-$ReleaseReset = Invoke-ReleaseGit @('reset', '--hard', $ReleaseOriginalCommit)-if ($ReleaseReset.Rc -ne 0) {- Write-Output "Error: git reset failed: $($ReleaseReset.Out -join ' ')"- exit 1-}--Write-Output 'Done! All apps built and tag pushed.'-exit 0