diff --git a/README.md b/README.md index 203eea4..363266a 100644 --- a/README.md +++ b/README.md @@ -98,3 +98,13 @@ Installing app on device... ``` $ flutterpi_tool run -d pi5 --profile ``` + +### 7. Building with artifacts pinned to a specific GitHub Actions run +```console +$ flutterpi_tool build --release \ + --github-artifacts-runid=23382732417 \ + --github-artifacts-engine-version=052f31d115eceda8cbff1b3481fcde4330c4ae12 +``` + +This is useful when you want `build` to use workflow artifacts from a specific +run instead of the default release-based artifact lookup. diff --git a/lib/src/cli/commands/build.dart b/lib/src/cli/commands/build.dart index ba328ac..674c581 100644 --- a/lib/src/cli/commands/build.dart +++ b/lib/src/cli/commands/build.dart @@ -37,6 +37,7 @@ class BuildCommand extends FlutterpiCommand { usesDartDefineOption(); usesTargetOption(); usesLocalFlutterpiExecutableArg(verboseHelp: verboseHelp); + usesGithubWorkflowArtifactsArgs(verboseHelp: verboseHelp); usesFilesystemLayoutArg(verboseHelp: verboseHelp); argParser diff --git a/lib/src/cli/flutterpi_command.dart b/lib/src/cli/flutterpi_command.dart index cabdc2e..c364240 100644 --- a/lib/src/cli/flutterpi_command.dart +++ b/lib/src/cli/flutterpi_command.dart @@ -135,6 +135,38 @@ mixin FlutterpiCommandMixin on fl.FlutterCommand { ); } + void usesGithubWorkflowArtifactsArgs({bool verboseHelp = false}) { + argParser + ..addOption( + 'github-artifacts-repo', + help: + 'Use workflow artifacts from the specified GitHub repository instead of release artifacts.', + valueHelp: 'owner/name', + hide: !verboseHelp, + ) + ..addOption( + 'github-artifacts-runid', + help: + 'Use workflow artifacts from the specified GitHub Actions run id.', + valueHelp: 'run id', + hide: !verboseHelp, + ) + ..addOption( + 'github-artifacts-engine-version', + help: + 'Restrict workflow artifact lookup to the specified engine version.', + valueHelp: 'engine version', + hide: !verboseHelp, + ) + ..addOption( + 'github-artifacts-auth-token', + help: + 'Use this GitHub token when querying private or rate-limited workflow artifacts.', + valueHelp: 'token', + hide: !verboseHelp, + ); + } + void usesRotationArg() { argParser.addOption( 'rotation', diff --git a/test/commands/build_test.dart b/test/commands/build_test.dart index 898ad6a..fd1d054 100644 --- a/test/commands/build_test.dart +++ b/test/commands/build_test.dart @@ -671,4 +671,45 @@ void main() { reason: "Expected BuildSystem.build to be called", ); }); + + test('accepts github workflow artifact flags', () async { + var buildWasCalled = false; + appBuilder.buildFn = ({ + required FlutterpiHostPlatform host, + required FlutterpiTargetPlatform target, + required fl.BuildInfo buildInfo, + required FilesystemLayout fsLayout, + fl.FlutterProject? project, + FlutterpiArtifacts? artifacts, + String? mainPath, + String manifestPath = fl.defaultManifestPath, + String? applicationKernelFilePath, + String? depfilePath, + Directory? outDir, + bool unoptimized = false, + bool includeDebugSymbols = false, + bool forceBundleFlutterpi = false, + }) async { + buildWasCalled = true; + }; + + await _runInTestContext(() async { + await runner.run([ + 'build', + '--release', + '--arch', + 'arm64', + '--cpu', + 'generic', + '--github-artifacts-runid=23382732417', + '--github-artifacts-engine-version=052f31d115eceda8cbff1b3481fcde4330c4ae12', + ]); + }); + + expect( + buildWasCalled, + isTrue, + reason: "Expected BuildSystem.build to be called", + ); + }); }