From 330598592d4b5aee86638035f26bd519a8ca6c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:28:07 +0200 Subject: [PATCH 1/8] feat: precache --- .github/workflows/run.yml | 24 ++++++++++++++++++++++++ action.yml | 8 ++++++-- install-flutter-sdk.sh | 7 ++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 55b6309..b6eb0ef 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -18,3 +18,27 @@ jobs: - uses: ./ - run: flutter --version - run: dart pub global activate git_helper && git_helper -h + test-beta-install: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + channel: 'beta' + - run: flutter --version + - run: dart pub global activate git_helper && git_helper -h + test-precache: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + precache: '--web' + - run: flutter --version + - run: dart pub global activate git_helper && git_helper -h diff --git a/action.yml b/action.yml index a85291b..50ae107 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: 'Install Flutter SDK' description: 'Dart and Flutter CLIs available for your GitHub Action' -author: 'Marcin Wróblewski' +author: 'Marcin Wróblewski, Monterail Sp. z o.o. (monterail.com)' branding: color: 'white' icon: 'download' @@ -9,10 +9,14 @@ inputs: description: 'Desired Flutter channel' required: false default: 'stable' + precache: + description: 'Comma-separated platforms list to precache' + required: false + default: '' runs: using: 'composite' steps: - run: chmod +x $GITHUB_ACTION_PATH/install-flutter-sdk.sh shell: bash - - run: $GITHUB_ACTION_PATH/install-flutter-sdk.sh -c ${{ inputs.channel }} + - run: $GITHUB_ACTION_PATH/install-flutter-sdk.sh -c ${{ inputs.channel }} -p ${{ inputs.precache }} shell: bash \ No newline at end of file diff --git a/install-flutter-sdk.sh b/install-flutter-sdk.sh index 380b3d6..0df29f5 100644 --- a/install-flutter-sdk.sh +++ b/install-flutter-sdk.sh @@ -1,9 +1,10 @@ #!/bin/bash CHANNEL="stable" -while getopts 'v:c:' param; do +while getopts 'c:p:' param; do case $param in c) CHANNEL="$OPTARG" ;; + p) PRECACHE="$OPTARG" ;; esac done @@ -16,3 +17,7 @@ git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$FLUTTER_PATH" echo "$HOME/.pub-cache/bin" # POSIX echo "$LOCALAPPDATA\Pub\Cache\bin" # Windows } >> "$GITHUB_PATH" + +if [ -z ${PRECACHE+x} ]; then + flutter precache $PRECACHE +fi \ No newline at end of file From 1fd3a555e54a37aba5d3c219eb4a83794724b90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:28:50 +0200 Subject: [PATCH 2/8] feat: precache --- .github/workflows/run.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index b6eb0ef..4268567 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -1,11 +1,10 @@ on: push: branches: - - main - development pull_request: branches: - - main + - development jobs: test-install: From 7657e8c3fbfc33b5fdff90b86d221562138d9875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:30:26 +0200 Subject: [PATCH 3/8] feat: precache --- install-flutter-sdk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-flutter-sdk.sh b/install-flutter-sdk.sh index 0df29f5..f5d9199 100644 --- a/install-flutter-sdk.sh +++ b/install-flutter-sdk.sh @@ -19,5 +19,5 @@ git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$FLUTTER_PATH" } >> "$GITHUB_PATH" if [ -z ${PRECACHE+x} ]; then - flutter precache $PRECACHE + $FLUTTER_PATH/bin precache $PRECACHE fi \ No newline at end of file From 30e4cc50dd03715dc5ef0af729bf61132886255a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:33:18 +0200 Subject: [PATCH 4/8] feat: precache --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 50ae107..63a1eda 100644 --- a/action.yml +++ b/action.yml @@ -12,11 +12,11 @@ inputs: precache: description: 'Comma-separated platforms list to precache' required: false - default: '' + default: 'no' runs: using: 'composite' steps: - run: chmod +x $GITHUB_ACTION_PATH/install-flutter-sdk.sh shell: bash - - run: $GITHUB_ACTION_PATH/install-flutter-sdk.sh -c ${{ inputs.channel }} -p ${{ inputs.precache }} + - run: $GITHUB_ACTION_PATH/install-flutter-sdk.sh -c ${{ inputs.channel }} -p "${{ inputs.precache }}" shell: bash \ No newline at end of file From fa1b0540a31d57fcdf3deeadee5d2a5508870731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:35:16 +0200 Subject: [PATCH 5/8] feat: precache --- install-flutter-sdk.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install-flutter-sdk.sh b/install-flutter-sdk.sh index f5d9199..52d86b8 100644 --- a/install-flutter-sdk.sh +++ b/install-flutter-sdk.sh @@ -1,6 +1,7 @@ #!/bin/bash CHANNEL="stable" +PRECACHE="no" while getopts 'c:p:' param; do case $param in c) CHANNEL="$OPTARG" ;; @@ -18,6 +19,6 @@ git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$FLUTTER_PATH" echo "$LOCALAPPDATA\Pub\Cache\bin" # Windows } >> "$GITHUB_PATH" -if [ -z ${PRECACHE+x} ]; then +if [[ $PRECACHE != "no" ]]; then $FLUTTER_PATH/bin precache $PRECACHE fi \ No newline at end of file From 096c95eec47ff5cf453ea03c690ca58b1f88c469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:41:30 +0200 Subject: [PATCH 6/8] feat: precache --- install-flutter-sdk.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install-flutter-sdk.sh b/install-flutter-sdk.sh index 52d86b8..cb8689f 100644 --- a/install-flutter-sdk.sh +++ b/install-flutter-sdk.sh @@ -9,9 +9,10 @@ while getopts 'c:p:' param; do esac done -FLUTTER_PATH="$GITHUB_ACTION_PATH/flutter" +FLUTTER_PATH=$(join_path "$GITHUB_ACTION_PATH flutter") git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$FLUTTER_PATH" + { echo "$FLUTTER_PATH/bin" echo "$FLUTTER_PATH/bin/cache/dart-sdk/bin" @@ -20,5 +21,5 @@ git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$FLUTTER_PATH" } >> "$GITHUB_PATH" if [[ $PRECACHE != "no" ]]; then - $FLUTTER_PATH/bin precache $PRECACHE + $FLUTTER_PATH/bin/flutter precache $PRECACHE fi \ No newline at end of file From cff3169fd408118310221809f4693c3082990809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:42:22 +0200 Subject: [PATCH 7/8] feat: precache --- install-flutter-sdk.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install-flutter-sdk.sh b/install-flutter-sdk.sh index cb8689f..a4b020d 100644 --- a/install-flutter-sdk.sh +++ b/install-flutter-sdk.sh @@ -9,10 +9,9 @@ while getopts 'c:p:' param; do esac done -FLUTTER_PATH=$(join_path "$GITHUB_ACTION_PATH flutter") +FLUTTER_PATH="$GITHUB_ACTION_PATH/flutter" git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$FLUTTER_PATH" - { echo "$FLUTTER_PATH/bin" echo "$FLUTTER_PATH/bin/cache/dart-sdk/bin" From 345209a7c188fc801845a5e367daf834b3de2531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Fri, 12 Jul 2024 08:50:40 +0200 Subject: [PATCH 8/8] docs: update docs to v2, add precache recipe --- README.md | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a7ae29c..9313dc1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Copy and paste the following snippet into your action's `.yml` file. ```yaml - name: Install Flutter - uses: monterail/flutter-action@v1 + uses: monterail/flutter-action@v2 ``` ## Usage @@ -21,7 +21,7 @@ With Flutter SDK for GitHub Actions you can do the following: ```yaml steps: - - uses: monterail/flutter-action@v1 + - uses: monterail/flutter-action@v2 - run: flutter build ... ``` @@ -32,6 +32,7 @@ steps: | Name | Description | Default | | --- | --- | --- | | `channel` | Flutter [channel](https://github.com/flutter/flutter/wiki/Flutter-build-release-channels) | `stable` | +| `precache` | `flutter precache` arguments list, see [recipe](#precache-web-and-android-build-tools) | no-op | ## Recipes @@ -56,7 +57,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: monterail/flutter-action@v1 + - uses: monterail/flutter-action@v2 - run: flutter pub get - uses: invertase/github-action-dart-analyzer@v3 with: @@ -86,7 +87,39 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: monterail/flutter-action@v1 + - uses: monterail/flutter-action@v2 + - run: flutter pub get + - run: flutter build web + - uses: actions/upload-artifact@v4 + with: + name: web-app + path: build/web +``` + + + +### Precache web and Android build tools + +By default Flutter will fetch the tools necessary to build specific platforms after `flutter build` command is ran. The process can be sped up with precaching specific platforms at Flutter installation stage. + +
+ +```yaml +name: Setup Flutter for web and Android builds + +on: + push: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: monterail/flutter-action@v2 + with: + precache: "--web --android" - run: flutter pub get - run: flutter build web - uses: actions/upload-artifact@v4