Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
145
.github/workflows/workflow.yml
vendored
145
.github/workflows/workflow.yml
vendored
@@ -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
157
README.md
@@ -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:`
|
||||
|
||||
30
action.yml
30
action.yml
@@ -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
284
setup.sh
@@ -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
4034
test/releases_linux.json
Normal file
File diff suppressed because it is too large
Load Diff
4166
test/releases_macos.json
Normal file
4166
test/releases_macos.json
Normal file
File diff suppressed because it is too large
Load Diff
4034
test/releases_windows.json
Normal file
4034
test/releases_windows.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user