Compare commits
3 Commits
v2.19.0
...
947e9c91a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
947e9c91a5 | ||
|
|
395322a6cd | ||
|
|
02d6ac3427 |
64
README.md
64
README.md
@@ -64,8 +64,8 @@ steps:
|
|||||||
>
|
>
|
||||||
> Using `flutter-version-file` requires [`yq`](https://github.com/mikefarah/yq),
|
> Using `flutter-version-file` requires [`yq`](https://github.com/mikefarah/yq),
|
||||||
> which is not pre-installed in `windows` runners. Fortunately, since version
|
> which is not pre-installed in `windows` runners. Fortunately, since version
|
||||||
> 2.18.0, this action installs `yq` automatically, so no action is required from
|
> 2.18.0, this action installs `yq` automatically if `flutter-version-file`
|
||||||
> you.
|
> is specified, so no action is required from you.
|
||||||
|
|
||||||
### Use latest release for particular channel
|
### Use latest release for particular channel
|
||||||
|
|
||||||
@@ -122,6 +122,24 @@ steps:
|
|||||||
- run: flutter --version
|
- run: flutter --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Use a Flutter mirror by set ENV
|
||||||
|
|
||||||
|
You can get more infomation from [Flutter official docs](https://docs.flutter.dev/community/china).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Clone repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Flutter
|
||||||
|
env:
|
||||||
|
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: master
|
||||||
|
flutter-version: 5b12b74 # tag, commit or branch
|
||||||
|
- run: flutter --version
|
||||||
|
```
|
||||||
|
|
||||||
### Use alternative Flutter repository
|
### Use alternative Flutter repository
|
||||||
|
|
||||||
This action supports "alternative Flutters" in addition to the official
|
This action supports "alternative Flutters" in addition to the official
|
||||||
@@ -317,6 +335,38 @@ dynamic values:
|
|||||||
- `:hash:`
|
- `:hash:`
|
||||||
- `:sha256:`
|
- `:sha256:`
|
||||||
|
|
||||||
|
### Using cache outputs
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> `PUB-CACHE-HIT` and `CACHE-HIT` directly use the `cache-hit` output from `actions/cache@v4`, which is the following:
|
||||||
|
> - `cache-hit` - A string value to indicate an exact match was found for the key.
|
||||||
|
> - If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`.
|
||||||
|
> - If there's a cache miss, this will be an empty string.
|
||||||
|
|
||||||
|
Example usage (inspired by [actions/cache@v4](https://github.com/actions/cache/blob/c45d39173a637a28edbd526cb160189cc4e84f5a/README.md#skipping-steps-based-on-cache-hit) and [#346](https://github.com/subosito/flutter-action/pull/346)) to skip `melos bootstrap` if there was a pub cache hit:
|
||||||
|
|
||||||
|
```
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Flutter
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
id: flutter-action
|
||||||
|
with:
|
||||||
|
channel: stable
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Conditionally run melos bootstrap
|
||||||
|
if: steps.flutter-action.outputs.PUB-CACHE-HIT != 'true'
|
||||||
|
run: melos bootstrap
|
||||||
|
|
||||||
|
- name: Continue with build
|
||||||
|
run: flutter build apk
|
||||||
|
```
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
Use outputs from `flutter-action`:
|
Use outputs from `flutter-action`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -338,6 +388,8 @@ steps:
|
|||||||
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
||||||
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||||
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
||||||
|
echo CACHE-HIT=${{ steps.flutter-action.outputs.CACHE-HIT }}
|
||||||
|
echo PUB-CACHE-HIT=${{ steps.flutter-action.outputs.PUB-CACHE-HIT }}
|
||||||
```
|
```
|
||||||
|
|
||||||
If you don't need to install Flutter and just want the outputs, you can use the
|
If you don't need to install Flutter and just want the outputs, you can use the
|
||||||
@@ -361,7 +413,11 @@ steps:
|
|||||||
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
||||||
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||||
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
||||||
|
echo CACHE-HIT=${{ steps.flutter-action.outputs.CACHE-HIT }}
|
||||||
|
echo PUB-CACHE-HIT=${{ steps.flutter-action.outputs.PUB-CACHE-HIT }}
|
||||||
shell: bash
|
shell: bash
|
||||||
```
|
```
|
||||||
[Alif Rachmawadi]: https://github.com/subosito
|
|
||||||
[Bartek Pacia]: https://github.com/bartekpacia
|
[Alif Rachmawadi](https://github.com/subosito)
|
||||||
|
|
||||||
|
[Bartek Pacia](https://github.com/bartekpacia)
|
||||||
|
|||||||
13
action.yaml
13
action.yaml
@@ -76,15 +76,22 @@ outputs:
|
|||||||
GIT_SOURCE:
|
GIT_SOURCE:
|
||||||
value: "${{ steps.flutter-action.outputs.GIT_SOURCE }}"
|
value: "${{ steps.flutter-action.outputs.GIT_SOURCE }}"
|
||||||
description: Git source of Flutter SDK repository to clone
|
description: Git source of Flutter SDK repository to clone
|
||||||
|
CACHE-HIT:
|
||||||
|
value: "${{ steps.cache-flutter.outputs.cache-hit }}"
|
||||||
|
description: "`true` if the flutter cache was a hit"
|
||||||
|
PUB-CACHE-HIT:
|
||||||
|
value: "${{ steps.cache-pub.outputs.cache-hit }}"
|
||||||
|
description: "`true` if the pub cache was a hit"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
# This is a cross-platform composite action that needs yq.
|
# This is a cross-platform composite action that needs yq in order to parse
|
||||||
|
# the pubspec.yaml file.
|
||||||
# It's not preinstalled on Windows runners.
|
# It's not preinstalled on Windows runners.
|
||||||
# See https://github.com/actions/runner-images/issues/7443#issuecomment-1514597691
|
# See https://github.com/actions/runner-images/issues/7443#issuecomment-1514597691
|
||||||
- name: Make yq tool available on Windows runners
|
- name: Make yq tool available on Windows runners
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows' && inputs.flutter-version-file != ''
|
||||||
run: choco install yq
|
run: choco install yq
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
@@ -108,6 +115,7 @@ runs:
|
|||||||
${{ inputs.channel }}
|
${{ inputs.channel }}
|
||||||
|
|
||||||
- name: Cache Flutter
|
- name: Cache Flutter
|
||||||
|
id: cache-flutter
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
if: ${{ inputs.cache == 'true' }}
|
if: ${{ inputs.cache == 'true' }}
|
||||||
with:
|
with:
|
||||||
@@ -116,6 +124,7 @@ runs:
|
|||||||
|
|
||||||
- name: Cache pub dependencies
|
- name: Cache pub dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
|
id: cache-pub
|
||||||
if: ${{ inputs.cache == 'true' }}
|
if: ${{ inputs.cache == 'true' }}
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||||
|
|||||||
2
setup.sh
2
setup.sh
@@ -12,7 +12,7 @@ fi
|
|||||||
|
|
||||||
OS_NAME=$(echo "$RUNNER_OS" | awk '{print tolower($0)}')
|
OS_NAME=$(echo "$RUNNER_OS" | awk '{print tolower($0)}')
|
||||||
ARCH_NAME=$(echo "$RUNNER_ARCH" | awk '{print tolower($0)}')
|
ARCH_NAME=$(echo "$RUNNER_ARCH" | awk '{print tolower($0)}')
|
||||||
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
|
MANIFEST_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.googleapis.com}/flutter_infra_release/releases"
|
||||||
MANIFEST_JSON_PATH="releases_$OS_NAME.json"
|
MANIFEST_JSON_PATH="releases_$OS_NAME.json"
|
||||||
MANIFEST_URL="$MANIFEST_BASE_URL/$MANIFEST_JSON_PATH"
|
MANIFEST_URL="$MANIFEST_BASE_URL/$MANIFEST_JSON_PATH"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user