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: 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 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 diff --git a/install-flutter-sdk.sh b/install-flutter-sdk.sh index 0df29f5..a4b020d 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 - flutter precache $PRECACHE +if [[ $PRECACHE != "no" ]]; then + $FLUTTER_PATH/bin/flutter precache $PRECACHE fi \ No newline at end of file