From 813ff814ea0cabfab46a5536565564e0ee022b45 Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Tue, 19 May 2026 03:25:58 +0100 Subject: [PATCH] build(gradle): auto-rewrite update.json on packaging Previously module/update.json had to be hand-bumped to keep versionCode and zipUrl in lockstep with module.prop's expanded $gitCommitCount. Wire a refreshUpdateJson task to the prepareModuleFiles${variant} pipeline so every zipDebug/zipRelease regenerates the file from current verName and gitCommitCount. --- app/build.gradle.kts | 29 +++++++++++++++++++++++++++++ module/update.json | 6 +++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5011302..1b82a4d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -108,6 +108,34 @@ tasks.configureEach { } } +// Auto-rewrite module/update.json on every packaging build so versionCode and +// zipUrl track gitCommitCount automatically, matching module.prop. +val refreshUpdateJson by tasks.registering { + group = "TEESimulator-RS Module Packaging" + description = "Rewrite module/update.json to match current verName and gitCommitCount." + + val updateJsonFile = rootProject.projectDir.resolve("module/update.json") + val capturedVerName = verName + val capturedCount = gitCommitCount + + inputs.property("verName", capturedVerName) + inputs.property("gitCommitCount", capturedCount) + outputs.file(updateJsonFile) + + doLast { + val fullVer = "$capturedVerName-$capturedCount" + updateJsonFile.writeText( + """{ + "version": "$fullVer", + "versionCode": $capturedCount, + "zipUrl": "https://github.com/Enginex0/TEESimulator-RS/releases/download/$fullVer/TEESimulator-RS-$fullVer-Release.zip", + "changelog": "https://raw.githubusercontent.com/Enginex0/TEESimulator-RS/main/module/changelog.md" +} +""" + ) + } +} + androidComponents { onVariants(selector().all()) { variant -> val capitalized = variant.name.replaceFirstChar { it.uppercase() } @@ -132,6 +160,7 @@ androidComponents { dependsOn("strip${capitalized}DebugSymbols") } dependsOn(buildRustCertgen) + dependsOn(refreshUpdateJson) if (isDebug) { from(variant.artifacts.get(SingleArtifact.APK)) { diff --git a/module/update.json b/module/update.json index 1e84411..1003b95 100644 --- a/module/update.json +++ b/module/update.json @@ -1,6 +1,6 @@ { - "version": "v6.0.0", - "versionCode": 162, - "zipUrl": "https://github.com/Enginex0/TEESimulator-RS/releases/download/v6.0.0-162/TEESimulator-RS-v6.0.0-162-Release.zip", + "version": "v6.0.0-171", + "versionCode": 171, + "zipUrl": "https://github.com/Enginex0/TEESimulator-RS/releases/download/v6.0.0-171/TEESimulator-RS-v6.0.0-171-Release.zip", "changelog": "https://raw.githubusercontent.com/Enginex0/TEESimulator-RS/main/module/changelog.md" }