Files
flutter-docker-image/script/updateAndroidVersions.gradle.kts
Eligio Mariño 40b632ca7f ci: update version.json from a single place (#375)
- Fixes a broken pipeline: the `single_update` branch had a
half-migrated step that pre-wrote `flutter_version.json` before the JS
comparator ran, causing every scheduled run to emit `result=false` and
skip all downstream jobs — meaning no update PRs were ever opened
- Replaces `script/updateFlutterVersion.js` with a single shell+jq step
that fetches `releases_linux.json`, reads the pinned version, compares,
and only writes when the upstream stable version actually changed
- Sources `android.buildTools.version` from Flutter's own
`engine/src/flutter/tools/android_sdk/packages.txt` at the new tag
(instead of being orphaned with no write path into `version.json`)
- Fixes `config/schema.cue` undefined reference (`#PatchVersion` →
`#SemverPatch`) that caused `cue vet` to fail
- Fixes `config/android.cue` length guard typo (`fileContentTests` →
`commandTests`)
- Fixes the PR creation step writing `commit_message` to `$GITHUB_ENV`
instead of `$GITHUB_OUTPUT`, which resulted in PRs with empty titles and
commit messages

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 15:35:48 +02:00

42 lines
1.5 KiB
Kotlin

// Snippet to include at the end of android/app/build.gradle.kts
tasks.register<DefaultTask>("updateAndroidVersions") {
doLast {
val jsonFile = File("../../config/version.json")
// Parse existing JSON file
val resultJsonMap = groovy.json.JsonSlurper().parseText(jsonFile.readText()) as MutableMap<String, Any>
// Get unique platform versions
val platformVersions = listOf(
flutter.targetSdkVersion,
flutter.compileSdkVersion
).distinct()
val buildToolsVersion = System.getenv("BUILD_TOOLS_VERSION")
?: error("BUILD_TOOLS_VERSION env var is required")
// Create new Android version data
val newJsonMap = mapOf(
"platforms" to platformVersions.map {
mapOf("version" to it)
},
"gradle" to mapOf("version" to gradle.gradleVersion),
"buildTools" to mapOf("version" to buildToolsVersion),
"ndk" to mapOf("version" to flutter.ndkVersion)
)
// Merge new values into the existing JSON structure
(resultJsonMap["android"] as? MutableMap<String, Any>)?.putAll(newJsonMap)
// Format JSON with pretty printing
val jsonStr = groovy.json.JsonOutput.toJson(resultJsonMap)
val prettyStr = groovy.json.JsonOutput.prettyPrint(jsonStr)
println(prettyStr)
// Write updated JSON back to the file
jsonFile.writeText("$prettyStr\n")
}
}