| @@ -3,7 +3,7 @@ |
| 3 | 3 | # build/vectrum-code plain binary |
| 4 | 4 | # build/Vectrum_Code-<version>-<arch>.AppImage |
| 5 | 5 | # and, with -a, a third: |
| 6 | | - # build/Vectrum_Code-<versionName>-<versionCode>.apk |
| 6 | + # build/Vectrum_Code-<version>.apk |
| 7 | 7 | # |
| 8 | 8 | # A binary only runs on the glibc it was linked against or a newer one, so by |
| 9 | 9 | # default it is built in an Ubuntu 24.04 container and linked against glibc |
| @@ -23,10 +23,12 @@ |
| 23 | 23 | # AppImage, the binary (and the APK with -a) and SHA256SUMS |
| 24 | 24 | # (the first upload publishes the release). Each release |
| 25 | 25 | # needs a new version. |
| 26 | | - # -a, --android also build the Android app (android/) as a release APK, |
| 27 | | - # with the versionCode and versionName that |
| 28 | | - # android/app/build.gradle.kts defines. Needs JDK 21 and |
| 29 | | - # the Android SDK (android/local.properties or ANDROID_HOME) |
| 26 | + # -a, --android also build the Android app (android/) as a release APK. |
| 27 | + # It has the desktop version as its versionName, and |
| 28 | + # versionCode major*1000000 + minor*1000 + patch (0.1.9 → |
| 29 | + # 1009); android/app/build.gradle.kts reads Cargo.toml. |
| 30 | + # Needs JDK 21 and the Android SDK (android/local.properties |
| 31 | + # or ANDROID_HOME) |
| 30 | 32 | # --native build with the host toolchain instead of the container; |
| 31 | 33 | # the binary then needs the host's glibc or newer |
| 32 | 34 | # -h, --help show this |
| @@ -102,12 +104,7 @@ if (( ! NATIVE )); then |
| 102 | 104 | fi |
| 103 | 105 | |
| 104 | 106 | if (( ANDROID )); then |
| 105 | | - GRADLE_APP="$ROOT/android/app/build.gradle.kts" |
| 106 | | - [[ -f "$GRADLE_APP" ]] || die "No Android app at android/app/build.gradle.kts" |
| 107 | | - APK_CODE="$(sed -n 's/^ *versionCode *= *\([0-9][0-9]*\).*/\1/p' "$GRADLE_APP" | tail -n1)" |
| 108 | | - APK_VERSION="$(sed -n 's/^ *versionName *= *"\(.*\)".*/\1/p' "$GRADLE_APP" | tail -n1)" |
| 109 | | - [[ -n "$APK_CODE" && -n "$APK_VERSION" ]] || |
| 110 | | - die "Couldn't read versionCode and versionName from android/app/build.gradle.kts" |
| 107 | + [[ -x "$ROOT/android/gradlew" ]] || die "No Android app at android/" |
| 111 | 108 | command -v java >/dev/null || die "The Android build needs a JDK (21) on \$PATH or in JAVA_HOME" |
| 112 | 109 | [[ -n "${ANDROID_HOME:-}${ANDROID_SDK_ROOT:-}" ]] || grep -qs '^sdk\.dir=' "$ROOT/android/local.properties" || |
| 113 | 110 | die "The Android build needs the SDK: set ANDROID_HOME or sdk.dir in android/local.properties" |
| @@ -258,11 +255,15 @@ log "AppImage: ${OUT#"$ROOT"/}" |
| 258 | 255 | |
| 259 | 256 | # ── 5. Android ─────────────────────────────────────────────────────────────── |
| 260 | 257 | if (( ANDROID )); then |
| 261 | | - APK="$BUILD/${PRETTY// /_}-$APK_VERSION-$APK_CODE.apk" |
| 262 | | - log "Building the Android app $APK_VERSION (versionCode $APK_CODE, release)" |
| 258 | + APK="$BUILD/${PRETTY// /_}-$VERSION.apk" |
| 259 | + APK_OUT="$ROOT/android/app/build/outputs/apk/release" |
| 260 | + log "Building the Android app $VERSION (release)" |
| 263 | 261 | (cd "$ROOT/android" && ./gradlew --quiet :app:assembleRelease) |
| 264 | | - install -m644 "$ROOT/android/app/build/outputs/apk/release/app-release.apk" "$APK" |
| 265 | | - log "APK: ${APK#"$ROOT"/}" |
| 262 | + APK_VERSION="$(sed -n 's/.*"versionName": *"\([^"]*\)".*/\1/p' "$APK_OUT/output-metadata.json")" |
| 263 | + APK_CODE="$(sed -n 's/.*"versionCode": *\([0-9]*\).*/\1/p' "$APK_OUT/output-metadata.json")" |
| 264 | + [[ "$APK_VERSION" == "$VERSION" ]] || die "The APK came out as version $APK_VERSION, not $VERSION" |
| 265 | + install -m644 "$APK_OUT/app-release.apk" "$APK" |
| 266 | + log "APK: ${APK#"$ROOT"/} (versionCode $APK_CODE)" |
| 266 | 267 | fi |
| 267 | 268 | |
| 268 | 269 | # ── 6. Release ─────────────────────────────────────────────────────────────── |