mirror of
https://github.com/subosito/flutter-action.git
synced 2026-08-01 03:20:47 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62f096cacd | ||
|
|
844082558d | ||
|
|
14bf5302ef | ||
|
|
02b923c0e1 | ||
|
|
aa6d9b9844 | ||
|
|
2783a3f08e | ||
|
|
c33c37022b | ||
|
|
cc97e1648f | ||
|
|
ed388baf1d | ||
|
|
48cafc2471 | ||
|
|
1508160852 | ||
|
|
88cab4064b | ||
|
|
55a58f6493 | ||
|
|
d369dd765d | ||
|
|
42b3ed07e1 | ||
|
|
8dbc29a898 | ||
|
|
ed0e860e8f | ||
|
|
37734c707c | ||
|
|
b1ba330d99 | ||
|
|
43c32c5d3a | ||
|
|
dbf1fa04f4 | ||
|
|
1e6ee87cb8 | ||
|
|
45dd344cec | ||
|
|
de3cdb9a4b | ||
|
|
1e952778af | ||
|
|
9d48f4efd5 | ||
|
|
6c2e035f26 | ||
|
|
c30358aafe | ||
|
|
472d887f68 | ||
|
|
b1d33bca25 | ||
|
|
e5fb13927b | ||
|
|
ebff0a3874 | ||
|
|
d8cf9a8ccc | ||
|
|
e09ab0131a | ||
|
|
becfb71246 | ||
|
|
54864698df | ||
|
|
ea686d7c56 | ||
|
|
9c6ea81337 | ||
|
|
29ad5bdaf4 | ||
|
|
0c3f14223a | ||
|
|
0f2cd3391b | ||
|
|
cf0b7b2cac | ||
|
|
d8687e6979 | ||
|
|
2fcd5629bc | ||
|
|
6a13bd0836 | ||
|
|
f0cc0311e0 | ||
|
|
5e1529bc12 | ||
|
|
99cf4656b5 | ||
|
|
b3c14e7ecc | ||
|
|
05b7251cb1 | ||
|
|
2d3283596d | ||
|
|
b5a1c34304 | ||
|
|
77740fc108 | ||
|
|
36e70a6528 | ||
|
|
d5878a0492 | ||
|
|
31089a7435 | ||
|
|
4f5d1c6d12 | ||
|
|
03e576dcd6 | ||
|
|
f95a8c953b | ||
|
|
3dae472464 | ||
|
|
523b0faa40 | ||
|
|
813937b170 | ||
|
|
8af4ab61aa | ||
|
|
59a5481c7d | ||
|
|
4686a99fc5 |
@@ -0,0 +1 @@
|
|||||||
|
github: [subosito]
|
||||||
+120
-48
@@ -1,74 +1,146 @@
|
|||||||
name: Main workflow
|
name: Main workflow
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- setup.sh
|
||||||
|
- action.yml
|
||||||
jobs:
|
jobs:
|
||||||
|
lint_shellcheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ludeeus/action-shellcheck@master
|
||||||
test_channel:
|
test_channel:
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
channel: [stable, beta, dev]
|
channel: [stable, beta, master]
|
||||||
|
include:
|
||||||
|
- operating-system: ubuntu-latest
|
||||||
|
channel: main
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v2
|
- id: flutter-action
|
||||||
- uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
channel: ${{ matrix.channel }}
|
channel: ${{ matrix.channel }}
|
||||||
- name: Print FLUTTER_ROOT
|
- name: Echo outputs
|
||||||
|
run: |
|
||||||
|
echo RUNNER-OS=${{ runner.os }}
|
||||||
|
echo RUNNER-ARCH=${{ runner.arch }}
|
||||||
|
|
||||||
|
echo CACHE-PATH=${{ steps.flutter-action.outputs.CACHE-PATH }}
|
||||||
|
echo CACHE-KEY=${{ steps.flutter-action.outputs.CACHE-KEY }}
|
||||||
|
echo CHANNEL=${{ steps.flutter-action.outputs.CHANNEL }}
|
||||||
|
echo VERSION=${{ steps.flutter-action.outputs.VERSION }}
|
||||||
|
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "FLUTTER_ROOT set to $FLUTTER_ROOT"
|
- run: dart --version
|
||||||
- name: Print PUBCACHE
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "PUBCACHE set to $PUBCACHE"
|
- run: flutter --version
|
||||||
- name: Run dart --version
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: dart --version
|
test_cache:
|
||||||
- name: Run flutter --version
|
runs-on: ${{ matrix.operating-system }}
|
||||||
shell: bash
|
|
||||||
run: flutter --version
|
|
||||||
test_version:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: [ 2.5.3, 2.x, 1, v1.12 ]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
channel: stable
|
channel: stable
|
||||||
flutter-version: ${{ matrix.version }}
|
flutter-version: '3.10.6'
|
||||||
- name: Run dart --version
|
cache: true
|
||||||
|
- run: dart --version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: dart --version
|
- run: flutter --version
|
||||||
- name: Run flutter --version
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: flutter --version
|
test_print_output:
|
||||||
test_master_channel:
|
runs-on: macos-latest
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v2
|
- run: ./setup.sh -t -p | grep 'stable'
|
||||||
- uses: ./
|
|
||||||
with:
|
|
||||||
channel: master
|
|
||||||
- name: Run dart --version
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: dart --version
|
- run: ./setup.sh -t -p | grep '3.7.7'
|
||||||
- name: Run flutter --version
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: flutter --version
|
- run: ./setup.sh -t -p | grep 'x64'
|
||||||
test_any_channel:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- uses: ./
|
|
||||||
with:
|
|
||||||
channel: any
|
|
||||||
flutter-version: 2
|
|
||||||
- name: Run dart --version
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: dart --version
|
- run: ./setup.sh -t -p stable | grep 'stable'
|
||||||
- name: Run flutter --version
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p beta | grep 'beta'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p beta | grep '3.9.0-0.1.pre'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 3.3.10 stable | grep '3.3.10'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 3.3.1 stable | grep '3.3.1'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 2 stable | grep '2.10.5'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 2 beta | grep '2.13.0-0.4.pre'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 2 any | grep 'beta'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 2 any | grep '2.13.0-0.4.pre'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 3 any | grep 'beta'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 3 any | grep '3.9.0-0.1.pre'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 3 -a arm64 any | grep 'arm64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n any -a arm64 stable | grep 'stable'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n any -a arm64 stable | grep '3.7.7'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n any -a arm64 stable | grep 'arm64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 1 stable | grep '1.22.6'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 0 any | grep 'beta'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 0 any | grep '0.11.13'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p | grep 'flutter-macos-stable-3.7.7-x64-2ad6cd72c040113b47ee9055e722606a490ef0da'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p stable | grep 'flutter-macos-stable-3.7.7-x64-2ad6cd72c040113b47ee9055e722606a490ef0da'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p beta | grep 'flutter-macos-beta-3.9.0-0.1.pre-x64-f732038a8cf4562ce38a1d7debb30209ae3da896'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p dev | grep 'flutter-macos-dev-2.11.0-0.1.pre-x64-b101bfe32f634566e7cb2791a9efe19cf8828b15'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p master | grep 'flutter-macos-master-any-x64-master'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 5b12b74 master | grep 'flutter-macos-master-5b12b74-x64-master'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 3.12.0-12.0.pre master | grep 'flutter-macos-master-3.12.0-12.0.pre-x64-master'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n stable master | grep 'flutter-macos-master-stable-x64-master'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 2 any | grep 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 1 any | grep 'flutter-macos-beta-1.26.0-17.8.pre-x64-044f2cf5607a26f8818dab0f766400e85c52bdff'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -n 0 any | grep 'flutter-macos-beta-0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p | grep '/Users/runner/work/_temp/flutter/stable-3.7.7-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p stable | grep '/Users/runner/work/_temp/flutter/stable-3.7.7-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p beta | grep '/Users/runner/work/_temp/flutter/beta-3.9.0-0.1.pre-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p dev | grep '/Users/runner/work/_temp/flutter/dev-2.11.0-0.1.pre-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p master | grep '/Users/runner/work/_temp/flutter/master-any-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -k 'custom-:channel:-:version:-:hash:' | grep 'custom-stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -k 'custom-:channel:-:version:-:sha256:' | grep 'custom-stable-3.7.7-78957b52f023a0d811add27eddc59b1a59d27d2ada5df123f39d0315708fb2d5'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -t -p -c '/tmp/flutter/:channel:-:version:-:hash:' | grep '/tmp/flutter/stable-3.7.7-2ad6cd72c040113b47ee9055e722606a490ef0da'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: flutter --version
|
|
||||||
|
|||||||
@@ -1,110 +1,95 @@
|
|||||||
# flutter-action
|
# flutter-action
|
||||||
|
|
||||||
This action sets up a flutter environment for use in actions. It works on Linux, Windows, and macOS.
|
Flutter environment for use in GitHub Actions. It works on Linux, Windows, and macOS.
|
||||||
|
|
||||||
# Usage
|
## Usage
|
||||||
|
|
||||||
|
Use specific version and channel:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: '11'
|
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '2.0.5'
|
flutter-version: '3.16.9'
|
||||||
- run: flutter pub get
|
channel: 'stable'
|
||||||
- run: flutter test
|
- run: flutter --version
|
||||||
```
|
```
|
||||||
|
|
||||||
Use latest release for particular channel:
|
Use latest release for particular channel:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: '11'
|
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
channel: 'stable' # or: 'beta', 'dev' or 'master'
|
channel: 'stable' # or: 'beta', 'dev', 'master' (or 'main')
|
||||||
- run: flutter pub get
|
- run: flutter --version
|
||||||
- run: flutter test
|
|
||||||
- run: flutter build apk
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Use latest release for particular version and/or channel:
|
Use latest release for particular version and/or channel:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: '11'
|
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '1.22.x' # or, you can use 1.22
|
flutter-version: '1.22.x'
|
||||||
channel: 'dev'
|
channel: 'dev'
|
||||||
- run: flutter pub get
|
- run: flutter --version
|
||||||
- run: flutter test
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Use particular version on any channel:
|
Use particular version on any channel:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: '11'
|
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '2.x'
|
flutter-version: '3.x'
|
||||||
channel: 'any'
|
channel: 'any'
|
||||||
- run: flutter pub get
|
- run: flutter --version
|
||||||
- run: flutter test
|
```
|
||||||
|
|
||||||
|
Use particular git reference on master channel:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
flutter-version: '5b12b74' # tag, commit or branch
|
||||||
|
channel: 'master'
|
||||||
|
- run: flutter --version
|
||||||
```
|
```
|
||||||
|
|
||||||
Build Android APK and app bundle:
|
Build Android APK and app bundle:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: '11'
|
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '2.0.5'
|
flutter-version: '3.16.9'
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- run: flutter test
|
- run: flutter test
|
||||||
- run: flutter build apk
|
- run: flutter build apk
|
||||||
- run: flutter build appbundle
|
- run: flutter build appbundle
|
||||||
```
|
```
|
||||||
|
|
||||||
Build for iOS too (macOS only):
|
Build for iOS (macOS only):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: '11'
|
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '2.0.5'
|
channel: 'stable'
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- run: flutter test
|
- run: flutter test
|
||||||
- run: flutter build apk
|
|
||||||
- run: flutter build ios --release --no-codesign
|
- run: flutter build ios --release --no-codesign
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -112,10 +97,10 @@ Build for the web:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '2.0.5'
|
channel: 'stable'
|
||||||
- run: flutter pub get
|
- run: flutter pub get
|
||||||
- run: flutter test
|
- run: flutter test
|
||||||
- run: flutter build web
|
- run: flutter build web
|
||||||
@@ -124,37 +109,89 @@ steps:
|
|||||||
Build for Windows:
|
Build for Windows:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
windows:
|
jobs:
|
||||||
runs-on: windows-latest
|
build:
|
||||||
steps:
|
runs-on: windows-latest
|
||||||
- uses: actions/checkout@v2
|
steps:
|
||||||
- uses: subosito/flutter-action@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
- uses: subosito/flutter-action@v2
|
||||||
channel: beta
|
with:
|
||||||
- run: flutter config --enable-windows-desktop
|
channel: 'stable'
|
||||||
- run: flutter build windows
|
- run: flutter build windows
|
||||||
```
|
```
|
||||||
|
|
||||||
Matrix Testing:
|
Build for Linux desktop:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
build:
|
||||||
name: Test on ${{ matrix.os }}
|
runs-on: ubuntu-latest
|
||||||
runs-on: ${{ matrix.os }}
|
steps:
|
||||||
strategy:
|
- uses: actions/checkout@v4
|
||||||
matrix:
|
- uses: subosito/flutter-action@v2
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
with:
|
||||||
steps:
|
channel: 'stable'
|
||||||
- uses: actions/checkout@v2
|
- run: |
|
||||||
- uses: actions/setup-java@v2
|
sudo apt-get update -y
|
||||||
with:
|
sudo apt-get install -y ninja-build libgtk-3-dev
|
||||||
distribution: 'zulu'
|
- run: flutter build linux
|
||||||
java-version: '11'
|
```
|
||||||
- uses: subosito/flutter-action@v2
|
|
||||||
with:
|
Build for macOS desktop:
|
||||||
flutter-version: '1.20.2'
|
|
||||||
channel: 'beta'
|
```yaml
|
||||||
- run: dart --version
|
jobs:
|
||||||
- run: flutter --version
|
build:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: 'stable'
|
||||||
|
- run: flutter build macos
|
||||||
|
```
|
||||||
|
|
||||||
|
Integration with `actions/cache`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: 'stable'
|
||||||
|
cache: true
|
||||||
|
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache
|
||||||
|
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path
|
||||||
|
pub-cache-key: 'flutter-pub:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache of dart pub get dependencies
|
||||||
|
pub-cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path
|
||||||
|
- run: flutter --version
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: `cache-key`, `pub-cache-key`, and `cache-path` has support for several dynamic values:
|
||||||
|
|
||||||
|
- `:os:`
|
||||||
|
- `:channel:`
|
||||||
|
- `:version:`
|
||||||
|
- `:arch:`
|
||||||
|
- `:hash:`
|
||||||
|
- `:sha256:`
|
||||||
|
|
||||||
|
Use outputs from `flutter-action`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- id: flutter-action
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: 'stable'
|
||||||
|
- run: |
|
||||||
|
echo CACHE-PATH=${{ steps.flutter-action.outputs.CACHE-PATH }}
|
||||||
|
echo CACHE-KEY=${{ steps.flutter-action.outputs.CACHE-KEY }}
|
||||||
|
echo CHANNEL=${{ steps.flutter-action.outputs.CHANNEL }}
|
||||||
|
echo VERSION=${{ steps.flutter-action.outputs.VERSION }}
|
||||||
|
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
||||||
|
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||||
|
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
||||||
|
shell: bash
|
||||||
```
|
```
|
||||||
|
|||||||
+57
-1
@@ -8,12 +8,68 @@ inputs:
|
|||||||
flutter-version:
|
flutter-version:
|
||||||
description: 'The Flutter version to make available on the path'
|
description: 'The Flutter version to make available on the path'
|
||||||
required: false
|
required: false
|
||||||
|
default: 'any'
|
||||||
channel:
|
channel:
|
||||||
description: 'The Flutter build release channel'
|
description: 'The Flutter build release channel'
|
||||||
required: false
|
required: false
|
||||||
default: 'stable'
|
default: 'stable'
|
||||||
|
cache:
|
||||||
|
description: 'Cache the Flutter SDK'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
cache-key:
|
||||||
|
description: 'Identifier for the Flutter SDK cache'
|
||||||
|
required: false
|
||||||
|
default: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
|
||||||
|
pub-cache-key:
|
||||||
|
description: 'Identifier for the Dart .pub-cache cache'
|
||||||
|
required: false
|
||||||
|
default: 'flutter-pub:os:-:channel:-:version:-:arch:-:hash:'
|
||||||
|
cache-path:
|
||||||
|
description: 'Flutter SDK cache path'
|
||||||
|
required: false
|
||||||
|
default: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
|
||||||
|
architecture:
|
||||||
|
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
|
||||||
|
required: false
|
||||||
|
default: '${{ runner.arch }}'
|
||||||
|
outputs:
|
||||||
|
CACHE-PATH:
|
||||||
|
value: '${{ steps.flutter-action.outputs.CACHE-PATH }}'
|
||||||
|
CACHE-KEY:
|
||||||
|
value: '${{ steps.flutter-action.outputs.CACHE-KEY }}'
|
||||||
|
CHANNEL:
|
||||||
|
value: '${{ steps.flutter-action.outputs.CHANNEL }}'
|
||||||
|
VERSION:
|
||||||
|
value: '${{ steps.flutter-action.outputs.VERSION }}'
|
||||||
|
ARCHITECTURE:
|
||||||
|
value: '${{ steps.flutter-action.outputs.ARCHITECTURE }}'
|
||||||
|
PUB-CACHE-KEY:
|
||||||
|
value: '${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}'
|
||||||
|
PUB-CACHE-PATH:
|
||||||
|
value: '${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}'
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ inputs.flutter-version }}
|
- run: chmod +x $GITHUB_ACTION_PATH/setup.sh
|
||||||
|
shell: bash
|
||||||
|
- id: flutter-action
|
||||||
|
run: $GITHUB_ACTION_PATH/setup.sh -p -c '${{ inputs.cache-path }}' -k '${{ inputs.cache-key }}' -d '${{ inputs.pub-cache-key }}' -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }}
|
||||||
|
shell: bash
|
||||||
|
- if: ${{ inputs.cache == 'true' }}
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.flutter-action.outputs.CACHE-PATH }}
|
||||||
|
key: ${{ steps.flutter-action.outputs.CACHE-KEY }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ steps.flutter-action.outputs.CACHE-KEY }}
|
||||||
|
- if: ${{ inputs.cache == 'true' }}
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||||
|
key: ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||||
|
${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
||||||
|
- run: $GITHUB_ACTION_PATH/setup.sh -c '${{ steps.flutter-action.outputs.CACHE-PATH }}' -n '${{ steps.flutter-action.outputs.VERSION }}' -a '${{ steps.flutter-action.outputs.ARCHITECTURE }}' ${{ steps.flutter-action.outputs.CHANNEL }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -1,94 +1,194 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
check_command() {
|
||||||
|
command -v "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! check_command jq; then
|
||||||
|
echo "jq not found, please install it, https://stedolan.github.io/jq/download/"
|
||||||
|
exit 1
|
||||||
|
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)}')
|
||||||
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
|
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
|
||||||
MANIFEST_URL="${MANIFEST_BASE_URL}/releases_${OS_NAME}.json"
|
MANIFEST_JSON_PATH="releases_$OS_NAME.json"
|
||||||
|
MANIFEST_URL="$MANIFEST_BASE_URL/$MANIFEST_JSON_PATH"
|
||||||
|
|
||||||
# convert version like 2.5.x to 2.5
|
filter_by_channel() {
|
||||||
normalize_version() {
|
jq --arg channel "$1" '[.releases[] | select($channel == "any" or .channel == $channel)]'
|
||||||
if [[ $1 == *x ]]; then
|
|
||||||
echo ${1::-2}
|
|
||||||
else
|
|
||||||
echo $1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
latest_version() {
|
filter_by_arch() {
|
||||||
jq --arg channel "$1" '.releases | map(select(.channel==$channel)) | first'
|
jq --arg arch "$1" '[.[] | select(.dart_sdk_arch == $arch or ($arch == "x64" and (has("dart_sdk_arch") | not)))]'
|
||||||
}
|
}
|
||||||
|
|
||||||
wildcard_version() {
|
filter_by_version() {
|
||||||
if [[ $1 == any ]]; then
|
jq --arg version "$1" '.[].version |= gsub("^v"; "") | (if $version == "any" then .[0] else (map(select(.version == $version or (.version | startswith(($version | sub("\\.x$"; "")) + ".")) and .version != $version)) | .[0]) end)'
|
||||||
jq --arg version "^$2" '.releases | map(select(.version | test($version))) | first'
|
|
||||||
else
|
|
||||||
jq --arg channel "$1" --arg version "^$2" '.releases | map(select(.channel==$channel) | select(.version | test($version))) | first'
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_version() {
|
not_found_error() {
|
||||||
if [[ -z $2 ]]; then
|
echo "Unable to determine Flutter version for channel: $1 version: $2 architecture: $3"
|
||||||
latest_version $1
|
|
||||||
else
|
|
||||||
wildcard_version $1 $2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_version_manifest() {
|
transform_path() {
|
||||||
releases_manifest=$(curl --silent --connect-timeout 15 --retry 5 $MANIFEST_URL)
|
if [[ "$OS_NAME" == windows ]]; then
|
||||||
version_manifest=$(echo $releases_manifest | get_version $1 $(normalize_version $2))
|
echo "$1" | sed -e 's/^\///' -e 's/\//\\/g'
|
||||||
|
else
|
||||||
if [[ $version_manifest == null ]]; then
|
echo "$1"
|
||||||
# fallback through legacy version format
|
fi
|
||||||
echo $releases_manifest | wildcard_version $1 "v$(normalize_version $2)"
|
|
||||||
else
|
|
||||||
echo $version_manifest
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
download_archive() {
|
download_archive() {
|
||||||
archive_url="$MANIFEST_BASE_URL/$1"
|
archive_url="$MANIFEST_BASE_URL/$1"
|
||||||
archive_name=$(basename $1)
|
archive_name=$(basename "$1")
|
||||||
archive_local="$HOME/$archive_name"
|
archive_local="$RUNNER_TEMP/$archive_name"
|
||||||
|
|
||||||
curl --connect-timeout 15 --retry 5 $archive_url >$archive_local
|
curl --connect-timeout 15 --retry 5 "$archive_url" >"$archive_local"
|
||||||
|
|
||||||
if [[ $archive_name == *zip ]]; then
|
mkdir -p "$2"
|
||||||
unzip -o "$archive_local" -d "$2"
|
|
||||||
else
|
|
||||||
tar xf "$archive_local" -C "$2"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm $archive_local
|
if [[ "$archive_name" == *zip ]]; then
|
||||||
|
EXTRACT_PATH="$RUNNER_TEMP/_unzip_temp"
|
||||||
|
unzip -q -o "$archive_local" -d "$EXTRACT_PATH"
|
||||||
|
# Remove the folder again so that the move command can do a simple rename\
|
||||||
|
# instead of moving the content into the target folder.
|
||||||
|
# This is a little bit of a hack since the "mv --no-target-directory"
|
||||||
|
# linux option is not available here
|
||||||
|
rm -r "$2"
|
||||||
|
mv "$EXTRACT_PATH"/flutter "$2"
|
||||||
|
rm -r "$EXTRACT_PATH"
|
||||||
|
else
|
||||||
|
tar xf "$archive_local" -C "$2" --strip-components=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm "$archive_local"
|
||||||
}
|
}
|
||||||
|
|
||||||
CHANNEL="$1"
|
CACHE_PATH=""
|
||||||
VERSION="$2"
|
CACHE_KEY=""
|
||||||
|
PUB_CACHE_KEY=""
|
||||||
|
PRINT_ONLY=""
|
||||||
|
TEST_MODE=false
|
||||||
|
ARCH=""
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
if [[ $CHANNEL == master ]]; then
|
while getopts 'tc:k:d:pa:n:' flag; do
|
||||||
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter"
|
case "$flag" in
|
||||||
|
c) CACHE_PATH="$OPTARG" ;;
|
||||||
|
k) CACHE_KEY="$OPTARG" ;;
|
||||||
|
d) PUB_CACHE_KEY="$OPTARG" ;;
|
||||||
|
p) PRINT_ONLY=true ;;
|
||||||
|
t) TEST_MODE=true ;;
|
||||||
|
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
|
||||||
|
n) VERSION="$OPTARG" ;;
|
||||||
|
?) exit 2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ -z $ARCH ]] && ARCH="$ARCH_NAME"
|
||||||
|
|
||||||
|
ARR_CHANNEL=("${@:$OPTIND:1}")
|
||||||
|
CHANNEL="${ARR_CHANNEL[0]}"
|
||||||
|
|
||||||
|
[[ -z $CHANNEL ]] && CHANNEL=stable
|
||||||
|
[[ -z $VERSION ]] && VERSION=any
|
||||||
|
[[ -z $ARCH ]] && ARCH=x64
|
||||||
|
[[ -z $CACHE_PATH ]] && CACHE_PATH="$RUNNER_TEMP/flutter/:channel:-:version:-:arch:"
|
||||||
|
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:channel:-:version:-:arch:-:hash:"
|
||||||
|
[[ -z $PUB_CACHE_KEY ]] && PUB_CACHE_KEY="flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
|
||||||
|
# Here we specifically use `PUB_CACHE` (and not `PUB_CACHE_PATH`), because `PUB_CACHE` is what dart (and flutter) looks for in the environment
|
||||||
|
[[ -z $PUB_CACHE ]] && PUB_CACHE="$HOME/.pub-cache"
|
||||||
|
|
||||||
|
if [[ "$TEST_MODE" == true ]]; then
|
||||||
|
RELEASE_MANIFEST=$(cat "$(dirname -- "${BASH_SOURCE[0]}")/test/$MANIFEST_JSON_PATH")
|
||||||
else
|
else
|
||||||
VERSION_MANIFEST=$(get_version_manifest $CHANNEL $VERSION)
|
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
|
||||||
|
|
||||||
if [[ $VERSION_MANIFEST == null ]]; then
|
|
||||||
echo "Unable to determine Flutter version for $CHANNEL $VERSION"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive')
|
|
||||||
download_archive "$ARCHIVE_PATH" "$RUNNER_TOOL_CACHE"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $OS_NAME == windows ]]; then
|
if [[ "$CHANNEL" == "master" || "$CHANNEL" == "main" ]]; then
|
||||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter"
|
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$VERSION\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
|
||||||
PUBCACHE="${USERPROFILE}\\.pub-cache"
|
|
||||||
else
|
else
|
||||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}/flutter"
|
VERSION_MANIFEST=$(echo "$RELEASE_MANIFEST" | filter_by_channel "$CHANNEL" | filter_by_arch "$ARCH" | filter_by_version "$VERSION")
|
||||||
PUBCACHE="${HOME}/.pub-cache"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV
|
if [[ "$VERSION_MANIFEST" == *null* ]]; then
|
||||||
echo "PUB_CACHE=${PUBCACHE}" >>$GITHUB_ENV
|
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${FLUTTER_ROOT}/bin" >>$GITHUB_PATH
|
expand_key() {
|
||||||
echo "${FLUTTER_ROOT}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
|
version_channel=$(echo "$VERSION_MANIFEST" | jq -r '.channel')
|
||||||
echo "${PUBCACHE}/bin" >>$GITHUB_PATH
|
version_version=$(echo "$VERSION_MANIFEST" | jq -r '.version')
|
||||||
|
version_arch=$(echo "$VERSION_MANIFEST" | jq -r '.dart_sdk_arch // "x64"')
|
||||||
|
version_hash=$(echo "$VERSION_MANIFEST" | jq -r '.hash')
|
||||||
|
version_sha_256=$(echo "$VERSION_MANIFEST" | jq -r '.sha256')
|
||||||
|
|
||||||
|
expanded_key="${1/:channel:/$version_channel}"
|
||||||
|
expanded_key="${expanded_key/:version:/$version_version}"
|
||||||
|
expanded_key="${expanded_key/:arch:/$version_arch}"
|
||||||
|
expanded_key="${expanded_key/:hash:/$version_hash}"
|
||||||
|
expanded_key="${expanded_key/:sha256:/$version_sha_256}"
|
||||||
|
expanded_key="${expanded_key/:os:/$OS_NAME}"
|
||||||
|
|
||||||
|
echo "$expanded_key"
|
||||||
|
}
|
||||||
|
|
||||||
|
CACHE_KEY=$(expand_key "$CACHE_KEY")
|
||||||
|
PUB_CACHE_KEY=$(expand_key "$PUB_CACHE_KEY")
|
||||||
|
CACHE_PATH=$(expand_key "$(transform_path "$CACHE_PATH")")
|
||||||
|
|
||||||
|
if [[ "$PRINT_ONLY" == true ]]; then
|
||||||
|
version_info=$(echo "$VERSION_MANIFEST" | jq -j '.channel,":",.version,":",.dart_sdk_arch // "x64"')
|
||||||
|
|
||||||
|
info_channel=$(echo "$version_info" | awk -F ':' '{print $1}')
|
||||||
|
info_version=$(echo "$version_info" | awk -F ':' '{print $2}')
|
||||||
|
info_architecture=$(echo "$version_info" | awk -F ':' '{print $3}')
|
||||||
|
|
||||||
|
if [[ "$TEST_MODE" == true ]]; then
|
||||||
|
echo "CHANNEL=$info_channel"
|
||||||
|
echo "VERSION=$info_version"
|
||||||
|
echo "ARCHITECTURE=$info_architecture"
|
||||||
|
echo "CACHE-KEY=$CACHE_KEY"
|
||||||
|
echo "CACHE-PATH=$CACHE_PATH"
|
||||||
|
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
|
||||||
|
echo "PUB-CACHE-PATH=$PUB_CACHE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "CHANNEL=$info_channel"
|
||||||
|
echo "VERSION=$info_version"
|
||||||
|
echo "ARCHITECTURE=$info_architecture"
|
||||||
|
echo "CACHE-KEY=$CACHE_KEY"
|
||||||
|
echo "CACHE-PATH=$CACHE_PATH"
|
||||||
|
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
|
||||||
|
echo "PUB-CACHE-PATH=$PUB_CACHE"
|
||||||
|
} >>"$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$CACHE_PATH/bin/flutter" ]]; then
|
||||||
|
if [[ "$CHANNEL" == "master" || "$CHANNEL" == "main" ]]; then
|
||||||
|
git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$CACHE_PATH"
|
||||||
|
if [[ "$VERSION" != "any" ]]; then
|
||||||
|
git config --global --add safe.directory "$CACHE_PATH"
|
||||||
|
(cd "$CACHE_PATH" && git checkout "$VERSION")
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
archive_url=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
|
||||||
|
download_archive "$archive_url" "$CACHE_PATH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "FLUTTER_ROOT=$CACHE_PATH"
|
||||||
|
echo "PUB_CACHE=$PUB_CACHE"
|
||||||
|
} >>"$GITHUB_ENV"
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "$CACHE_PATH/bin"
|
||||||
|
echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
|
||||||
|
echo "$PUB_CACHE/bin"
|
||||||
|
} >>"$GITHUB_PATH"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user