Compare commits

...

38 Commits

Author SHA1 Message Date
Alif Rachmawadi
c30358aafe dynamic cache path 2022-07-26 13:20:39 +07:00
Alif Rachmawadi
472d887f68 update readme 2022-07-26 11:56:47 +07:00
Alif Rachmawadi
b1d33bca25 print version 2022-07-25 19:47:52 +07:00
Alif Rachmawadi
e5fb13927b update readme 2022-07-25 19:36:41 +07:00
Alif Rachmawadi
ebff0a3874 tidy up 2022-07-25 19:15:22 +07:00
Alif Rachmawadi
d8cf9a8ccc tidy up 2022-07-25 18:58:09 +07:00
Alif Rachmawadi
e09ab0131a remove opencollective 2022-07-24 21:17:47 +07:00
Alif Rachmawadi
becfb71246 shellcheck linter 2022-07-24 19:30:59 +07:00
Alif Rachmawadi
54864698df test mode and cache key builder (#175) 2022-07-24 19:19:31 +07:00
Alif Rachmawadi
ea686d7c56 check jq 2022-07-19 12:00:34 +07:00
Alif Rachmawadi
9c6ea81337 check jq, fixes #170 2022-07-19 06:32:29 +07:00
Jiun Kim
29ad5bdaf4 Update for any-version on any-channel (#155)
* Update for testing any-version on any-channel

* Update `latest_version` and Add `latest_channel_version`
2022-06-05 16:06:25 +07:00
Jiun Kim
0c3f14223a Update cache-key with Runner.os and Arch (#152)
* Add `${{ runner.os }}` on cache-key

* Add `${{ inputs.architecture }}` as Cache-key
2022-04-29 09:03:21 +07:00
Jiun Kim
0f2cd3391b Update architecture default as runner.arch (#153)
* Update architecture default as `runner.arch`

* Update to convert `ARCH` as lowercase

* Refactor for `ARCH` variable
2022-04-29 07:52:26 +07:00
Jiun Kim
cf0b7b2cac Update for actions/cache version to 3 (#150) 2022-04-27 10:24:59 +07:00
Alif Rachmawadi
d8687e6979 add open collective funding 2022-04-20 06:42:47 +07:00
Goooler
2fcd5629bc Bump actions/checkout to v3 (#145) 2022-04-19 17:54:50 +07:00
菘菘
6a13bd0836 feat: support to set architecture of SDK executable (#147)
* feat: support to set architecture of SDK executable

* docs: update

* fix: try fix tests

* ci: set `fail-fast` to false

* fix: get latest version sdk

* fix: test any version

* fix: legacy version format

* fix: tests

* revert changes for `.github/workflows/workflow.yml`

* Update workflow.yml

* rename `ARCHITECTURE` to `ARCH`

* follow the existing spacing

* style: simplified code

* Update setup.sh

* style
2022-04-19 16:08:46 +07:00
Alif Rachmawadi
f0cc0311e0 update .pub-cache location 2022-03-31 12:45:08 +07:00
Alif Rachmawadi
5e1529bc12 update readme 2022-02-07 23:42:26 +00:00
Alif Rachmawadi
99cf4656b5 Merge pull request #134 from kuhnroyal/temp-folder-windows
Fix temp folder handling on windows
2022-02-04 23:44:20 +07:00
Peter Leibiger
b3c14e7ecc Fix temp folder handling on windows
Something with the globing seems not work but not sure exactly. Now using a simple way of ensure that the target folder never exists when calling `mv` so that it behaves as a rename instead of a move into. The folder still needs to be created first so that parent folders (in case of a custom cache path) are created.
2022-02-04 17:30:43 +01:00
Alif Rachmawadi
05b7251cb1 Merge pull request #133 from davidmigloz/main
Remove dev channel mentions
2022-02-04 18:19:49 +07:00
David Miguel Lozano
2d3283596d Remove dev channel 2022-02-04 12:04:07 +01:00
Alif Rachmawadi
b5a1c34304 run workflow on pull request 2022-02-04 10:30:09 +00:00
Alif Rachmawadi
77740fc108 Merge pull request #132 from kuhnroyal/temp-folder
Download and unzip to temp folder and not $HOME
2022-02-04 17:24:54 +07:00
Peter Leibiger
36e70a6528 Download and unzip to temp folder and not $HOME 2022-02-03 23:50:13 +01:00
Alif Rachmawadi
d5878a0492 quiet unzip (fixes #130)
Some checks failed
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_cache (macos-latest) (push) Failing after 3s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 33s
Main workflow / test_version (2.5.3) (push) Failing after 33s
Main workflow / test_cache (ubuntu-latest) (push) Failing after 17s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 17s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 1m38s
Main workflow / test_version (1) (push) Failing after 32s
Main workflow / test_version (2.x) (push) Failing after 32s
Main workflow / test_version (v1.12) (push) Failing after 6m16s
Main workflow / test_any_channel (push) Failing after 8s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_cache (windows-latest) (push) Has been cancelled
2022-01-24 04:44:12 +00:00
Alif Rachmawadi
31089a7435 update readme
Some checks failed
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_cache (macos-latest) (push) Failing after 3s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 6m31s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 10s
Main workflow / test_version (v1.12) (push) Failing after 25s
Main workflow / test_any_channel (push) Failing after 16s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 18s
Main workflow / test_version (1) (push) Failing after 9s
Main workflow / test_version (2.5.3) (push) Failing after 8s
Main workflow / test_version (2.x) (push) Failing after 9s
Main workflow / test_cache (ubuntu-latest) (push) Failing after 18s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_cache (windows-latest) (push) Has been cancelled
2022-01-13 11:02:57 +00:00
Alif Rachmawadi
4f5d1c6d12 add cache path option 2022-01-13 10:46:00 +00:00
Alif Rachmawadi
03e576dcd6 actions/cache integration
Some checks failed
Main workflow / test_channel (beta, macos-latest) (push) Failing after 1s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_cache (macos-latest) (push) Failing after 3s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 49s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 9s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 9s
Main workflow / test_version (1) (push) Failing after 8s
Main workflow / test_version (2.5.3) (push) Failing after 9s
Main workflow / test_version (2.x) (push) Failing after 9s
Main workflow / test_version (v1.12) (push) Failing after 20s
Main workflow / test_any_channel (push) Failing after 15s
Main workflow / test_cache (ubuntu-latest) (push) Failing after 10s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_cache (windows-latest) (push) Has been cancelled
2022-01-10 04:45:27 +00:00
Alif Rachmawadi
f95a8c953b add actions/cache support
Some checks failed
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 8s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 18s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 8s
Main workflow / test_version (2.5.3) (push) Failing after 33s
Main workflow / test_any_channel (push) Failing after 15s
Main workflow / test_version (1) (push) Failing after 2m16s
Main workflow / test_version (2.x) (push) Failing after 32s
Main workflow / test_version (v1.12) (push) Failing after 23s
Main workflow / test_with_cache (push) Failing after 1m15s
Main workflow / test_channel (beta, macos-latest) (push) Failing after 3s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
2022-01-07 04:54:02 +00:00
Alif Rachmawadi
3dae472464 update readme 2022-01-06 16:00:13 +00:00
Alif Rachmawadi
523b0faa40 update readme for linux desktop dependencies (closes #49) 2022-01-06 11:45:16 +00:00
Alif Rachmawadi
813937b170 update readme for desktop build (closes #86) 2022-01-06 11:17:49 +00:00
Alif Rachmawadi
8af4ab61aa update readme 2022-01-06 11:12:10 +00:00
Alif Rachmawadi
59a5481c7d fix PUB_CACHE env
Some checks failed
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 16s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 16s
Main workflow / test_version (1) (push) Failing after 7s
Main workflow / test_version (v1.12) (push) Failing after 14s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 19s
Main workflow / test_version (2.5.3) (push) Failing after 7s
Main workflow / test_version (2.x) (push) Failing after 14s
Main workflow / test_any_channel (push) Failing after 15s
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
2022-01-06 10:46:35 +00:00
Alif Rachmawadi
4686a99fc5 update readme
Some checks failed
Main workflow / test_channel (stable, macos-latest) (push) Failing after 3s
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 15s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 9s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 8s
Main workflow / test_version (1) (push) Failing after 7s
Main workflow / test_version (2.5.3) (push) Failing after 14s
Main workflow / test_version (2.x) (push) Failing after 8s
Main workflow / test_version (v1.12) (push) Failing after 8s
Main workflow / test_any_channel (push) Failing after 8s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
2022-01-06 09:55:43 +00:00
7 changed files with 12667 additions and 183 deletions

View File

@@ -1,74 +1,127 @@
name: Main workflow
on: [push]
on:
push:
branches:
- main
pull_request:
paths:
- setup.sh
- action.yml
jobs:
lint_shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ludeeus/action-shellcheck@master
test_channel:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
channel: [stable, beta, dev]
channel: [stable, beta, master]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
channel: ${{ matrix.channel }}
- name: Print FLUTTER_ROOT
- run: dart --version
shell: bash
run: echo "FLUTTER_ROOT set to $FLUTTER_ROOT"
- name: Print PUBCACHE
- run: flutter --version
shell: bash
run: echo "PUBCACHE set to $PUBCACHE"
- name: Run dart --version
shell: bash
run: dart --version
- name: Run flutter --version
shell: bash
run: flutter --version
test_version:
runs-on: ubuntu-latest
test_cache:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
version: [ 2.5.3, 2.x, 1, v1.12 ]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ./
with:
channel: stable
flutter-version: ${{ matrix.version }}
- name: Run dart --version
cache: true
- run: dart --version
shell: bash
run: dart --version
- name: Run flutter --version
- run: flutter --version
shell: bash
run: flutter --version
test_master_channel:
runs-on: windows-latest
test_version:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ./
with:
channel: master
- name: Run dart --version
- uses: actions/checkout@v3
- run: ./setup.sh -p version | grep -x 'stable:any:x64|stable:3.0.5:x64'
shell: bash
run: dart --version
- name: Run flutter --version
- run: ./setup.sh -p version stable | grep -x 'stable:any:x64|stable:3.0.5:x64'
shell: bash
run: flutter --version
test_any_channel:
- run: ./setup.sh -p version beta | grep -x 'beta:any:x64|beta:3.1.0-9.0.pre:x64'
shell: bash
- run: ./setup.sh -p version master | grep -x 'master:master:x64|master:master:x64'
shell: bash
- run: ./setup.sh -p version stable 2 | grep -x 'stable:2:x64|stable:2.10.5:x64'
shell: bash
- run: ./setup.sh -p version beta 2 | grep -x 'beta:2:x64|beta:2.13.0-0.4.pre:x64'
shell: bash
- run: ./setup.sh -p version any 2 | grep -x 'any:2:x64|beta:2.13.0-0.4.pre:x64'
shell: bash
- run: ./setup.sh -p version any 3 | grep -x 'any:3:x64|stable:3.0.5:x64'
shell: bash
- run: ./setup.sh -p version any 3 arm64 | grep -x 'any:3:arm64|stable:3.0.5:arm64'
shell: bash
- run: ./setup.sh -p version stable any arm64 | grep -x 'stable:any:arm64|stable:3.0.5:arm64'
shell: bash
- run: ./setup.sh -p version stable 1 | grep -x 'stable:1:x64|stable:1.22.6:x64'
shell: bash
- run: ./setup.sh -p version stable v1 | grep -x 'stable:v1:x64|stable:v1.12.13+hotfix.9:x64'
shell: bash
- run: ./setup.sh -p version any 0 | grep -x 'any:0:x64|beta:v0.11.13:x64'
shell: bash
- run: ./setup.sh -p version any v0 | grep -x 'any:v0:x64|beta:v0.11.13:x64'
shell: bash
test_cache_key:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: ./setup.sh -p cache-key | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key stable | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key beta | grep -x 'flutter-macos-beta-3.1.0-9.0.pre-x64-f28e570c8cb12a004fae2d796d0d9cd46603bde9'
shell: bash
- run: ./setup.sh -p cache-key master | grep -x 'flutter-macos-master-master-x64-master'
shell: bash
- run: ./setup.sh -p cache-key stable 2 | grep -x 'flutter-macos-stable-2.10.5-x64-5464c5bac742001448fe4fc0597be939379f88ea'
shell: bash
- run: ./setup.sh -p cache-key beta 2 | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
shell: bash
- run: ./setup.sh -p cache-key any 2 | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
shell: bash
- run: ./setup.sh -p cache-key any 3 | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key any 3 arm64 | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key stable any arm64 | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key stable 1 | grep -x 'flutter-macos-stable-1.22.6-x64-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
shell: bash
- run: ./setup.sh -p cache-key stable v1 | grep -x 'flutter-macos-stable-v1.12.13+hotfix.9-x64-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
shell: bash
- run: ./setup.sh -p cache-key any 0 | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
shell: bash
- run: ./setup.sh -p cache-key any v0 | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
shell: bash
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:hash:' | grep -x 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:sha256:' | grep -x 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
shell: bash
test_cache_path:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: ./
with:
channel: any
flutter-version: 2
- name: Run dart --version
- uses: actions/checkout@v3
- run: ./setup.sh -p cache-path | grep -x '/home/runner/work/_temp/flutter/stable-3.0.5-x64'
shell: bash
run: dart --version
- name: Run flutter --version
- run: ./setup.sh -p cache-path stable | grep -x '/home/runner/work/_temp/flutter/stable-3.0.5-x64'
shell: bash
- run: ./setup.sh -p cache-path beta | grep -x '/home/runner/work/_temp/flutter/beta-3.1.0-9.0.pre-x64'
shell: bash
- run: ./setup.sh -p cache-path master | grep -x '/home/runner/work/_temp/flutter/master-master-x64'
shell: bash
- run: ./setup.sh -p cache-path -c '/tmp/flutter/:channel:-:version:-:hash:' | grep -x '/tmp/flutter/stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
run: flutter --version

157
README.md
View File

@@ -1,110 +1,88 @@
# 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
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
- run: flutter pub get
- run: flutter test
flutter-version: '3.0.5'
channel: 'stable'
- run: flutter --version
```
Use latest release for particular channel:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable' # or: 'beta', 'dev' or 'master'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
- run: flutter --version
```
Use latest release for particular version and/or channel:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '1.22.x' # or, you can use 1.22
channel: 'dev'
- run: flutter pub get
- run: flutter test
- run: flutter --version
```
Use particular version on any channel:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.x'
channel: 'any'
- run: flutter pub get
- run: flutter test
- run: flutter --version
```
Build Android APK and app bundle:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
flutter-version: '3.0.5'
- run: flutter pub get
- run: flutter test
- run: flutter build apk
- run: flutter build appbundle
```
Build for iOS too (macOS only):
Build for iOS (macOS only):
```yaml
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
channel: 'stable'
architecture: x64
- run: flutter pub get
- run: flutter test
- run: flutter build apk
- run: flutter build ios --release --no-codesign
```
@@ -112,10 +90,10 @@ Build for the web:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.0.5'
channel: 'stable'
- run: flutter pub get
- run: flutter test
- run: flutter build web
@@ -124,37 +102,72 @@ steps:
Build for Windows:
```yaml
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
channel: beta
- run: flutter config --enable-windows-desktop
- run: flutter build windows
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'beta'
- run: flutter config --enable-windows-desktop
- run: flutter build windows
```
Matrix Testing:
Build for Linux desktop:
```yaml
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '1.20.2'
channel: 'beta'
- run: dart --version
- run: flutter --version
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev
- run: flutter config --enable-linux-desktop
- run: flutter build linux
```
Build for macOS desktop:
```yaml
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
- run: flutter config --enable-macos-desktop
- run: flutter build macos
```
Integration with `actions/cache`:
```yaml
steps:
- uses: actions/checkout@v3
- 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
architecture: x64 # optional, x64 or arm64
- run: flutter --version
```
Note: `cache-key` and `cache-path` has support for several dynamic values:
- `:os:`
- `:channel:`
- `:version:`
- `:arch:`
- `:hash:`
- `:sha256:`

View File

@@ -8,12 +8,40 @@ inputs:
flutter-version:
description: 'The Flutter version to make available on the path'
required: false
default: 'any'
channel:
description: 'The Flutter build release channel'
required: false
default: 'stable'
cache:
description: 'Cache the Flutter SDK'
required: false
cache-key:
description: 'Identifier for the Flutter SDK cache'
required: false
default: 'flutter-: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 }}
runs:
using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ inputs.flutter-version }}
- id: flutter-action-cache-path-builder
run: echo "::set-output name=cache-path::$($GITHUB_ACTION_PATH/setup.sh -p cache-path -c '${{ inputs.cache-path }}' ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }})"
shell: bash
- if: ${{ inputs.cache == 'true' }}
id: flutter-action-cache-key-builder
run: echo "::set-output name=cache-key::$($GITHUB_ACTION_PATH/setup.sh -p cache-key -k ${{ inputs.cache-key }} ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }})"
shell: bash
- if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v3
with:
path: ${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}
key: ${{ steps.flutter-action-cache-key-builder.outputs.cache-key }}
- run: $GITHUB_ACTION_PATH/setup.sh -c '${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}' ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }}
shell: bash

284
setup.sh
View File

@@ -1,94 +1,250 @@
#!/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)}')
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
MANIFEST_URL="${MANIFEST_BASE_URL}/releases_${OS_NAME}.json"
MANIFEST_URL="$MANIFEST_BASE_URL/releases_$OS_NAME.json"
MANIFEST_TEST_FIXTURE="test/releases_$OS_NAME.json"
# convert version like 2.5.x to 2.5
normalize_version() {
if [[ $1 == *x ]]; then
echo ${1::-2}
else
echo $1
fi
}
latest_version() {
jq --arg channel "$1" '.releases | map(select(.channel==$channel)) | first'
legacy_wildcard_version() {
if [[ $1 == any ]]; then
jq --arg version "$2" '.releases | map(select(.version | startswith($version) )) | first'
else
jq --arg channel "$1" --arg version "$2" '.releases | map(select(.channel==$channel) | select(.version | startswith($version) )) | first'
fi
}
wildcard_version() {
if [[ $1 == any ]]; then
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
if [[ $1 == any ]]; then
jq --arg version "$2" --arg arch "$3" '.releases | map(select(.version | startswith($version)) | select(.dart_sdk_arch == null or .dart_sdk_arch == $arch)) | first'
else
jq --arg channel "$1" --arg version "$2" --arg arch "$3" '.releases | map(select(.channel==$channel) | select(.version | startswith($version) ) | select(.dart_sdk_arch == null or .dart_sdk_arch == $arch)) | first'
fi
}
get_version() {
if [[ -z $2 ]]; then
latest_version $1
else
wildcard_version $1 $2
fi
if [[ "$1" == any && "$2" == any ]]; then # latest_version
jq --arg arch "$3" '.releases | map(select(.dart_sdk_arch == null or .dart_sdk_arch == $arch)) | first'
elif [[ "$2" == any ]]; then # latest channel version
jq --arg channel "$1" --arg arch "$3" '.releases | map(select(.channel==$channel) | select(.dart_sdk_arch == null or .dart_sdk_arch == $arch)) | first'
else
wildcard_version "$1" "$2" "$3"
fi
}
get_version_manifest() {
releases_manifest=$(curl --silent --connect-timeout 15 --retry 5 $MANIFEST_URL)
version_manifest=$(echo $releases_manifest | get_version $1 $(normalize_version $2))
normalize_version() {
if [[ "$1" == *.x ]]; then
echo "${1/.x/}"
else
echo "$1"
fi
}
if [[ $version_manifest == null ]]; then
# fallback through legacy version format
echo $releases_manifest | wildcard_version $1 "v$(normalize_version $2)"
else
echo $version_manifest
fi
not_found_error() {
echo "Unable to determine Flutter version for channel: $1 version: $2 architecture: $3"
}
transform_path() {
if [[ "$OS_NAME" == windows ]]; then
echo "$1" | sed -e 's/^\///' -e 's/\//\\/g'
else
echo "$1"
fi
}
download_archive() {
archive_url="$MANIFEST_BASE_URL/$1"
archive_name=$(basename $1)
archive_local="$HOME/$archive_name"
archive_url="$MANIFEST_BASE_URL/$1"
archive_name=$(basename "$1")
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
unzip -o "$archive_local" -d "$2"
else
tar xf "$archive_local" -C "$2"
fi
# Create the target folder
mkdir -p "$2"
rm $archive_local
if [[ "$archive_name" == *zip ]]; then
unzip -q -o "$archive_local" -d "$RUNNER_TEMP"
# 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 "$RUNNER_TEMP"/flutter "$2"
else
tar xf "$archive_local" -C "$2" --strip-components=1
fi
rm "$archive_local"
}
CHANNEL="$1"
VERSION="$2"
CACHE_PATH=""
CACHE_KEY=""
PRINT_MODE=""
if [[ $CHANNEL == master ]]; then
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter"
else
VERSION_MANIFEST=$(get_version_manifest $CHANNEL $VERSION)
while getopts 'c:k:p:' flag; do
case "$flag" in
c) CACHE_PATH="$OPTARG" ;;
k) CACHE_KEY="$OPTARG" ;;
p) PRINT_MODE="$OPTARG" ;;
?) exit 2 ;;
esac
done
if [[ $VERSION_MANIFEST == null ]]; then
echo "Unable to determine Flutter version for $CHANNEL $VERSION"
exit 1
fi
ARR_CHANNEL=("${@:$OPTIND:1}")
ARR_VERSION=("${@:$OPTIND+1:1}")
ARR_ARCH=("${@:$OPTIND+2:1}")
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive')
download_archive "$ARCHIVE_PATH" "$RUNNER_TOOL_CACHE"
CHANNEL="${ARR_CHANNEL[0]}"
VERSION="${ARR_VERSION[0]}"
ARCH=$(echo "${ARR_ARCH[0]}" | awk '{print tolower($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:"
RELEASE_MANIFEST=""
VERSION_MANIFEST=""
get_version_manifest() {
version_normalized=$(normalize_version "$VERSION")
version_manifest=$(echo "$RELEASE_MANIFEST" | get_version "$CHANNEL" "$version_normalized" "$ARCH")
if [[ "$version_manifest" == null ]]; then
version_manifest=$(echo "$RELEASE_MANIFEST" | legacy_wildcard_version "$CHANNEL" "v$version_normalized")
fi
version_arch=$(echo "$version_manifest" | jq -r '.dart_sdk_arch')
if [[ "$version_arch" == null ]]; then
if [[ "$ARCH" == x64 ]]; then
echo "$version_manifest" | jq --arg dart_sdk_arch x64 '.+={dart_sdk_arch:$dart_sdk_arch}'
else
echo ""
fi
else
echo "$version_manifest"
fi
}
expand_key() {
version_channel=$(echo "$VERSION_MANIFEST" | jq -r '.channel')
version_version=$(echo "$VERSION_MANIFEST" | jq -r '.version')
version_arch=$(echo "$VERSION_MANIFEST" | jq -r '.dart_sdk_arch')
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"
}
print_version() {
version_debug=$(echo "$VERSION_MANIFEST" | jq -j '.channel,":",.version,":",.dart_sdk_arch')
echo "$CHANNEL:$VERSION:$ARCH|$version_debug"
}
if [[ -n "$PRINT_MODE" ]]; then
if [[ "$CHANNEL" == master ]]; then
if [[ "$PRINT_MODE" == version ]]; then
echo "master:master:$ARCH|master:master:$ARCH"
exit 0
fi
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$CHANNEL\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
if [[ "$PRINT_MODE" == cache-key ]]; then
expanded_key=$(expand_key "$CACHE_KEY")
echo "$expanded_key"
exit 0
fi
if [[ "$PRINT_MODE" == cache-path ]]; then
cache_path=$(transform_path "$CACHE_PATH")
expanded_path=$(expand_key "$cache_path")
echo "$expanded_path"
exit 0
fi
exit 1
fi
RELEASE_MANIFEST=$(cat "$MANIFEST_TEST_FIXTURE")
VERSION_MANIFEST=$(get_version_manifest)
if [[ -z "$VERSION_MANIFEST" ]]; then
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
exit 1
fi
if [[ "$PRINT_MODE" == version ]]; then
print_version
exit 0
fi
if [[ "$PRINT_MODE" == cache-key ]]; then
expanded_key=$(expand_key "$CACHE_KEY")
echo "$expanded_key"
exit 0
fi
if [[ "$PRINT_MODE" == cache-path ]]; then
cache_path=$(transform_path "$CACHE_PATH")
expanded_path=$(expand_key "$cache_path")
echo "$expanded_path"
exit 0
fi
exit 1
fi
if [[ $OS_NAME == windows ]]; then
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter"
PUBCACHE="${USERPROFILE}\\.pub-cache"
else
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}/flutter"
PUBCACHE="${HOME}/.pub-cache"
CACHE_PATH=$(transform_path "$CACHE_PATH")
SDK_CACHE=$(expand_key "$CACHE_PATH")
PUB_CACHE=$(expand_key "$SDK_CACHE/.pub-cache")
if [[ ! -x "$SDK_CACHE/bin/flutter" ]]; then
if [[ $CHANNEL == master ]]; then
git clone -b master https://github.com/flutter/flutter.git "$SDK_CACHE"
else
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
VERSION_MANIFEST=$(get_version_manifest)
if [[ -z "$VERSION_MANIFEST" ]]; then
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
exit 1
fi
ARCHIVE_PATH=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
download_archive "$ARCHIVE_PATH" "$SDK_CACHE"
print_version
fi
fi
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV
echo "PUB_CACHE=${PUBCACHE}" >>$GITHUB_ENV
{
echo "FLUTTER_ROOT=$SDK_CACHE"
echo "PUB_CACHE=$PUB_CACHE"
} >>"$GITHUB_ENV"
echo "${FLUTTER_ROOT}/bin" >>$GITHUB_PATH
echo "${FLUTTER_ROOT}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
echo "${PUBCACHE}/bin" >>$GITHUB_PATH
{
echo "$SDK_CACHE/bin"
echo "$SDK_CACHE/bin/cache/dart-sdk/bin"
echo "$PUB_CACHE/bin"
} >>"$GITHUB_PATH"

4034
test/releases_linux.json Normal file

File diff suppressed because it is too large Load Diff

4166
test/releases_macos.json Normal file

File diff suppressed because it is too large Load Diff

4034
test/releases_windows.json Normal file

File diff suppressed because it is too large Load Diff