Skip to content

Commit db0137a

Browse files
authored
ADFA-2278: Inject YY.ww release version into the build (#1479)
* ADFA-2278: Inject YY.ww release version into the build Read the next_release_version Gradle property (from the NEXT_RELEASE_VERSION GitHub variable) into a new BuildInfo.RELEASE_VERSION field. release.yml validates and injects it at assemble time; a missing or malformed value fails the release build fast with no APK. Local and F-Droid builds leave the field empty. * ADFA-2278: Fall back to 'Unknown' when next_release_version is not set * Revert "ADFA-2278: Fall back to 'Unknown' when next_release_version is not set" This reverts commit b6d2c35.
1 parent 1903259 commit db0137a

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,29 @@ jobs:
486486
echo "$GOOGLE_SERVICES_JSON" > app/google-services.json
487487
echo "google-services.json created successfully"
488488
489+
- name: Validate release version
490+
env:
491+
NEXT_RELEASE_VERSION: ${{ vars.NEXT_RELEASE_VERSION }}
492+
run: |
493+
if [ -z "$NEXT_RELEASE_VERSION" ]; then
494+
echo "ERROR: NEXT_RELEASE_VERSION variable is not set"
495+
exit 1
496+
fi
497+
if [[ ! "$NEXT_RELEASE_VERSION" =~ ^[0-9]{2}\.[0-9]{2}$ ]]; then
498+
echo "ERROR: NEXT_RELEASE_VERSION format is invalid: $NEXT_RELEASE_VERSION"
499+
echo "Expected format: YY.ww (two digits, dot, two digits, e.g., 25.50)"
500+
exit 1
501+
fi
502+
echo "Validated NEXT_RELEASE_VERSION: $NEXT_RELEASE_VERSION"
503+
489504
- name: Assemble Release APK
490505
env:
491506
INCLUDE_LLAMA_ASSETS: "true"
507+
NEXT_RELEASE_VERSION: ${{ vars.NEXT_RELEASE_VERSION }}
492508
run: |
493509
variant_upper=$(echo "${{ matrix.variant }}" | tr '[:lower:]' '[:upper:]')
494510
flox activate -d flox/base -- ./gradlew :app:assemble${variant_upper}Release --no-daemon \
511+
-Pnext_release_version="$NEXT_RELEASE_VERSION" \
495512
-Dorg.gradle.jvmargs="-Xmx10g -XX:MaxMetaspaceSize=2g -XX:+HeapDumpOnOutOfMemoryError --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED" \
496513
-Dandroid.aapt2.daemonHeapSize=4096M \
497514
-Dorg.gradle.workers.max=1 \

‎build-info/build.gradle.kts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.itsaky.androidide.build.config.ProjectConfig
2323
import com.itsaky.androidide.build.config.VersionUtils
2424
import com.itsaky.androidide.build.config.downloadVersion
2525
import com.itsaky.androidide.build.config.publishingVersion
26+
import com.itsaky.androidide.build.config.releaseVersion
2627
import com.itsaky.androidide.build.config.replaceContents
2728
import com.itsaky.androidide.build.config.simpleVersionName
2829

@@ -57,6 +58,7 @@ tasks.create("generateBuildInfo") {
5758
"MVN_GROUP_ID" to BuildConfig.PACKAGE_NAME,
5859
"VERSION_NAME" to rootProject.version.toString(),
5960
"VERSION_NAME_SIMPLE" to rootProject.simpleVersionName,
61+
"RELEASE_VERSION" to rootProject.releaseVersion,
6062
"VERSION_NAME_PUBLISHING" to rootProject.publishingVersion,
6163
"VERSION_NAME_DOWNLOAD" to rootProject.downloadVersion,
6264
"FDROID_BUILD" to FDroidConfig.isFDroidBuild.toString(),

‎build-info/src/main/java/com/itsaky/androidide/buildinfo/BuildInfo.java.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class BuildInfo {
3939

4040
public static final String VERSION_NAME = "@@VERSION_NAME@@";
4141
public static final String VERSION_NAME_SIMPLE = "@@VERSION_NAME_SIMPLE@@";
42+
public static final String RELEASE_VERSION = "@@RELEASE_VERSION@@";
4243
public static final String VERSION_NAME_PUBLISHING = "@@VERSION_NAME_PUBLISHING@@";
4344
public static final String VERSION_NAME_DOWNLOAD = "@@VERSION_NAME_DOWNLOAD@@";
4445

‎composite-builds/build-logic/common/src/main/java/com/itsaky/androidide/build/config/ProjectConfig.kt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.itsaky.androidide.build.config
1919

20+
import org.gradle.api.GradleException
2021
import org.gradle.api.Project
2122
import java.util.Locale
2223

@@ -86,6 +87,17 @@ val Project.simpleVersionName: String
8687
return simpleVersion
8788
}
8889

90+
val Project.releaseVersion: String
91+
get() {
92+
val raw = providers.gradleProperty("next_release_version").orNull.orEmpty().trim()
93+
if (raw.isNotEmpty() && !Regex("""^\d{2}\.\d{2}$""").matches(raw)) {
94+
throw GradleException(
95+
"Invalid next_release_version '$raw'; expected YY.ww (two digits, dot, two digits), e.g. 25.47",
96+
)
97+
}
98+
return raw
99+
}
100+
89101
private var shouldPrintVersionCode = true
90102
val Project.projectVersionCode: Int
91103
get() {

0 commit comments

Comments
 (0)