Skip to content

Commit e4ce42c

Browse files
committed
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).
1 parent cedb807 commit e4ce42c

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

packages/flutter_tools/lib/src/shorebird/shorebird_yaml.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,9 @@ Map<String, dynamic> compileShorebirdYaml(
7272
if (shorebirdPublicKeyEnvVar != null) {
7373
compiled['patch_public_key'] = shorebirdPublicKeyEnvVar;
7474
}
75+
final String? moduleVersion = environment['SHOREBIRD_MODULE_VERSION'];
76+
if (moduleVersion != null) {
77+
compiled['module_version'] = moduleVersion;
78+
}
7579
return compiled;
7680
}

packages/flutter_tools/test/general.shard/shorebird/shorebird_yaml_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ patch_verification: strict
8383
'patch_public_key': '4-a',
8484
});
8585
});
86+
test('module_version from environment', () {
87+
const String yamlContents = '''
88+
app_id: 1-a
89+
''';
90+
final YamlDocument input = loadYamlDocument(yamlContents);
91+
final YamlMap yamlMap = input.contents as YamlMap;
92+
93+
// Without env var, module_version is absent.
94+
final Map<String, dynamic> withoutEnv = compileShorebirdYaml(
95+
yamlMap,
96+
flavor: null,
97+
environment: <String, String>{},
98+
);
99+
expect(withoutEnv.containsKey('module_version'), isFalse);
100+
101+
// With env var, module_version is included.
102+
final Map<String, dynamic> withEnv = compileShorebirdYaml(
103+
yamlMap,
104+
flavor: null,
105+
environment: <String, String>{'SHOREBIRD_MODULE_VERSION': 'abc1234'},
106+
);
107+
expect(withEnv['module_version'], 'abc1234');
108+
});
86109
test('edit in place', () {
87110
const String yamlContents = '''
88111
app_id: 1-a

0 commit comments

Comments
 (0)