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>
This commit is contained in:
Eligio Mariño
2026-05-09 15:35:48 +02:00
committed by GitHub
parent 3c7b0968e3
commit 40b632ca7f
14 changed files with 466 additions and 128 deletions
+5 -3
View File
@@ -116,8 +116,8 @@ jobs:
- name: Validate version.json and flutter_version.json with CUE
run: |
cue vet config/version.cue -d '#FlutterVersion' config/flutter_version.json
cue vet config/version.cue -d '#Version' config/version.json
cue vet config/schema.cue -d '#FlutterVersion' config/flutter_version.json
cue vet config/schema.cue -d '#Version' config/version.json
validate_generated_config:
runs-on: ubuntu-24.04
@@ -219,6 +219,8 @@ jobs:
- name: Update default Android platform versions in Flutter
working-directory: test_app/android
env:
BUILD_TOOLS_VERSION: ${{ fromJson(steps.version-json.outputs.content).android.buildTools.version }}
run: |
cat ../../script/updateAndroidVersions.gradle.kts >> app/build.gradle.kts
./gradlew --warning-mode all updateAndroidVersions
@@ -231,4 +233,4 @@ jobs:
digest: 06925fc1e5174591cef0b1e42ac32cff4271804742cd20893de1793b6d82d460
- name: Validate version.json with CUE
run: cue vet config/version.cue -d '#Version' config/version.json
run: cue vet config/schema.cue -d '#Version' config/version.json
+48 -17
View File
@@ -7,6 +7,9 @@ on:
permissions:
contents: read
env:
FLUTTER_VERSION_PATH: config/flutter_version.json
jobs:
update_flutter_version:
permissions:
@@ -22,25 +25,41 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Update latest Flutter version
id: update_flutter_version
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const script = require('./script/updateFlutterVersion.js')
return await script({core, fetch})
- name: Setup CUE
if: ${{ steps.update_flutter_version.outputs.result == 'true' }}
uses: jaxxstorm/action-install-gh-release@6096f2a2bbfee498ced520b6922ac2c06e990ed2 # v2.1.0
with:
repo: cue-lang/cue
tag: v0.15.0
digest: 06925fc1e5174591cef0b1e42ac32cff4271804742cd20893de1793b6d82d460
- name: Fetch and update latest Flutter version
id: update_flutter_version
run: |
releases_json_path="${RUNNER_TEMP}/releases.json"
curl -fsSL https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json \
-o "$releases_json_path"
old_version=$(jq -r '.flutter.version' "${{ env.FLUTTER_VERSION_PATH }}")
new_version=$(jq -r '[.releases[] | select(.channel=="stable")] | max_by(.release_date) | .version' "$releases_json_path")
new_channel=$(jq -r '[.releases[] | select(.channel=="stable")] | max_by(.release_date) | .channel' "$releases_json_path")
new_commit=$(jq -r '[.releases[] | select(.channel=="stable")] | max_by(.release_date) | .hash' "$releases_json_path")
echo "Current pinned version: $old_version"
echo "Latest upstream stable version: $new_version (channel: $new_channel)"
if [ "$old_version" = "$new_version" ]; then
echo "No version change — skipping update."
echo "result=false" >> "$GITHUB_OUTPUT"
else
echo "New version detected — updating ${{ env.FLUTTER_VERSION_PATH }}"
printf '{\n "flutter": {\n "channel": "%s",\n "commit": "%s",\n "version": "%s"\n }\n}\n' \
"$new_channel" "$new_commit" "$new_version" > "${{ env.FLUTTER_VERSION_PATH }}"
echo "result=true" >> "$GITHUB_OUTPUT"
fi
- name: Validate version.json with CUE
if: ${{ steps.update_flutter_version.outputs.result == 'true' }}
run: cue vet config/version.cue -d '#FlutterVersion' config/flutter_version.json
run: cue vet config/schema.cue -d '#FlutterVersion' ${{ env.FLUTTER_VERSION_PATH }}
- name: Upload artifact with the new Flutter version
if: ${{ steps.update_flutter_version.outputs.result == 'true' }}
@@ -48,7 +67,7 @@ jobs:
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: flutter_version.json
path: config/flutter_version.json
path: ${{ env.FLUTTER_VERSION_PATH }}
update_android_version:
permissions:
@@ -78,7 +97,7 @@ jobs:
# https://github.com/actions/download-artifact/issues/225
# https://github.com/actions/download-artifact/issues/138
- name: Delete flutter_version.json
run: rm config/flutter_version.json
run: rm ${{ env.FLUTTER_VERSION_PATH }}
- name: Download artifact with the new Flutter version
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
@@ -100,6 +119,13 @@ jobs:
const script = require('./script/updateFastlaneVersion.js')
await script({core, fetch})
- name: Update Android SDK build tools version
id: build_tools
run: |
build_tools_version=$(curl -fsSL https://raw.githubusercontent.com/flutter/flutter/refs/tags/${{ env.FLUTTER_VERSION }}/engine/src/flutter/tools/android_sdk/packages.txt | grep 'build-tools' | awk -F'[;:]' '{print $2}')
echo "build_tools_version=$build_tools_version" >>"$GITHUB_OUTPUT"
echo "Build tools version: $build_tools_version"
- name: Setup Flutter
run: |
cd $FLUTTER_ROOT
@@ -114,6 +140,8 @@ jobs:
# TODO: Cache gradle https://github.com/gradle/gradle-build-action
- name: Update default Android platform versions in Flutter
working-directory: test_app/android
env:
BUILD_TOOLS_VERSION: ${{ steps.build_tools.outputs.build_tools_version }}
run: |
cat ../../script/updateAndroidVersions.gradle.kts >> app/build.gradle.kts
./gradlew --warning-mode all updateAndroidVersions
@@ -175,7 +203,7 @@ jobs:
digest: 06925fc1e5174591cef0b1e42ac32cff4271804742cd20893de1793b6d82d460
- name: Validate version.json with CUE
run: cue vet config/version.cue -d '#Version' config/version.json
run: cue vet config/schema.cue -d '#Version' config/version.json
update_docs_and_create_pr:
needs:
@@ -196,7 +224,7 @@ jobs:
# https://github.com/actions/download-artifact/issues/138
- name: Delete flutter_version.json and version.json
run: |-
rm config/flutter_version.json config/version.json test/android.yml
rm ${{ env.FLUTTER_VERSION_PATH }} config/version.json test/android.yml
- name: Download configuration artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
@@ -237,8 +265,11 @@ jobs:
return await script({ core })
- name: Create commit message variable
id: create_commit_message
run: |
echo "COMMIT_MESSAGE=chore(release): upgrade flutter to ${{ env.FLUTTER_VERSION }}" >> $GITHUB_ENV
commit_message="chore(release): upgrade flutter to ${{ env.FLUTTER_VERSION }}"
echo "commit_message=$commit_message" >> "$GITHUB_OUTPUT"
echo "Commit message: $commit_message"
- name: Generate authentication token with GitHub App to trigger Actions
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
@@ -253,8 +284,8 @@ jobs:
- name: Create pull request if there are changes
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
with:
commit-message: ${{ env.COMMIT_MESSAGE }}
commit-message: ${{ steps.create_commit_message.outputs.commit_message }}
branch: update-flutter-dependencies/${{ env.FLUTTER_VERSION }}
sign-commits: true
title: ${{ env.COMMIT_MESSAGE }}
title: ${{ steps.create_commit_message.outputs.commit_message }}
token: ${{ steps.app-token.outputs.token }}