From e4ce42cd46a4d8c09d84910a798511ff97221203 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 1 May 2026 10:51:49 -0700 Subject: [PATCH] feat: support module_version for add-to-app releases Adds SHOREBIRD_MODULE_VERSION env var support to compileShorebirdYaml. When set, the value is written into the compiled shorebird.yaml as module_version, which the updater then sends to the server (alongside release_version) for add-to-app patch lookup. The shorebird CLI passes this env var through when running `flutter build aar` or `flutter build ios-framework` for module releases (see shorebirdtech/shorebird#3674). --- .../lib/src/shorebird/shorebird_yaml.dart | 4 ++++ .../shorebird/shorebird_yaml_test.dart | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/packages/flutter_tools/lib/src/shorebird/shorebird_yaml.dart b/packages/flutter_tools/lib/src/shorebird/shorebird_yaml.dart index 24d76f84ed257..3f4191cef7191 100644 --- a/packages/flutter_tools/lib/src/shorebird/shorebird_yaml.dart +++ b/packages/flutter_tools/lib/src/shorebird/shorebird_yaml.dart @@ -72,5 +72,9 @@ Map compileShorebirdYaml( if (shorebirdPublicKeyEnvVar != null) { compiled['patch_public_key'] = shorebirdPublicKeyEnvVar; } + final String? moduleVersion = environment['SHOREBIRD_MODULE_VERSION']; + if (moduleVersion != null) { + compiled['module_version'] = moduleVersion; + } return compiled; } diff --git a/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart b/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart index 240ae45f5bb18..d0e3950538fb1 100644 --- a/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart +++ b/packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart @@ -83,6 +83,29 @@ patch_verification: strict 'patch_public_key': '4-a', }); }); + test('module_version from environment', () { + const String yamlContents = ''' +app_id: 1-a +'''; + final YamlDocument input = loadYamlDocument(yamlContents); + final YamlMap yamlMap = input.contents as YamlMap; + + // Without env var, module_version is absent. + final Map withoutEnv = compileShorebirdYaml( + yamlMap, + flavor: null, + environment: {}, + ); + expect(withoutEnv.containsKey('module_version'), isFalse); + + // With env var, module_version is included. + final Map withEnv = compileShorebirdYaml( + yamlMap, + flavor: null, + environment: {'SHOREBIRD_MODULE_VERSION': 'abc1234'}, + ); + expect(withEnv['module_version'], 'abc1234'); + }); test('edit in place', () { const String yamlContents = ''' app_id: 1-a