Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
184
.github/workflows/workflow.yml
vendored
184
.github/workflows/workflow.yml
vendored
@@ -1,93 +1,147 @@
|
||||
name: Main workflow
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
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: ./
|
||||
- uses: actions/checkout@v3
|
||||
- id: flutter-action
|
||||
uses: ./
|
||||
with:
|
||||
channel: ${{ matrix.channel }}
|
||||
- name: Print FLUTTER_ROOT
|
||||
- name: Echo outputs
|
||||
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 }}
|
||||
shell: bash
|
||||
run: echo "FLUTTER_ROOT set to $FLUTTER_ROOT"
|
||||
- name: Print PUB_CACHE
|
||||
- run: dart --version
|
||||
shell: bash
|
||||
run: echo "PUB_CACHE set to $PUB_CACHE"
|
||||
- name: Run dart --version
|
||||
- run: flutter --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_print_output:
|
||||
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 -t -p | grep 'stable'
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
- run: ./setup.sh -t -p | grep '3.0.5'
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
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
|
||||
- run: ./setup.sh -t -p | grep 'x64'
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
- run: ./setup.sh -t -p stable | grep 'stable'
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
test_with_cache:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ runner.tool_cache }}/flutter
|
||||
key: flutter-2.5.0-stable
|
||||
- uses: ./
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: 2.5.0
|
||||
- name: Run dart --version
|
||||
- run: ./setup.sh -t -p beta | grep 'beta'
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
- run: ./setup.sh -t -p beta | grep '3.1.0-9.0.pre'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p master | grep 'master'
|
||||
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 'stable'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 3 any | grep '3.0.5'
|
||||
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.0.5'
|
||||
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 v1 stable | grep 'v1.12.13+hotfix.9'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 0 any | grep 'beta'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 0 any | grep 'v0.11.13'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n v0 any | grep 'beta'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n v0 any | grep 'v0.11.13'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p | grep 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p stable | grep 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p beta | grep 'flutter-macos-beta-3.1.0-9.0.pre-x64-f28e570c8cb12a004fae2d796d0d9cd46603bde9'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p master | grep 'flutter-macos-master-master-x64-master'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 2 stable | grep 'flutter-macos-stable-2.10.5-x64-5464c5bac742001448fe4fc0597be939379f88ea'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 2 beta | grep 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
|
||||
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 3 any | grep 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 3 -a arm64 any | grep 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n any -a arm64 stable | grep 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 1 stable | grep 'flutter-macos-stable-1.22.6-x64-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n v1 stable | grep 'flutter-macos-stable-v1.12.13+hotfix.9-x64-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n 0 any | grep 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -n v0 any | grep 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p | grep '/Users/runner/work/_temp/flutter/stable-3.0.5-x64'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p stable | grep '/Users/runner/work/_temp/flutter/stable-3.0.5-x64'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p beta | grep '/Users/runner/work/_temp/flutter/beta-3.1.0-9.0.pre-x64'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p master | grep '/Users/runner/work/_temp/flutter/master-master-x64'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -k 'custom-:channel:-:version:-:hash:' | grep 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -k 'custom-:channel:-:version:-:sha256:' | grep 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p -c '/tmp/flutter/:channel:-:version:-:hash:' | grep '/tmp/flutter/stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
|
||||
78
README.md
78
README.md
@@ -8,10 +8,10 @@ Use specific version and channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '2.8.0'
|
||||
flutter-version: '3.0.5'
|
||||
channel: 'stable'
|
||||
- run: flutter --version
|
||||
```
|
||||
@@ -20,7 +20,7 @@ Use latest release for particular channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable' # or: 'beta', 'dev' or 'master'
|
||||
@@ -31,7 +31,7 @@ Use latest release for particular version and/or channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '1.22.x' # or, you can use 1.22
|
||||
@@ -43,7 +43,7 @@ Use particular version on any channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '2.x'
|
||||
@@ -55,14 +55,14 @@ 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.5.3'
|
||||
flutter-version: '3.0.5'
|
||||
- run: flutter pub get
|
||||
- run: flutter test
|
||||
- run: flutter build apk
|
||||
@@ -76,10 +76,11 @@ jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '2.5.3'
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: flutter pub get
|
||||
- run: flutter test
|
||||
- run: flutter build ios --release --no-codesign
|
||||
@@ -89,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.5.3'
|
||||
channel: 'stable'
|
||||
- run: flutter pub get
|
||||
- run: flutter test
|
||||
- run: flutter build web
|
||||
@@ -105,10 +106,10 @@ jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: beta
|
||||
channel: 'beta'
|
||||
- run: flutter config --enable-windows-desktop
|
||||
- run: flutter build windows
|
||||
```
|
||||
@@ -120,10 +121,10 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: beta
|
||||
channel: 'stable'
|
||||
- run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y ninja-build libgtk-3-dev
|
||||
@@ -138,26 +139,53 @@ jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: beta
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: flutter config --enable-macos-desktop
|
||||
- run: flutter build macos
|
||||
```
|
||||
|
||||
Integration with actions/cache:
|
||||
Integration with `actions/cache`:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ runner.tool_cache }}/flutter
|
||||
key: flutter-2.5.0-stable
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: 2.5.0
|
||||
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:`
|
||||
|
||||
Use outputs from `flutter-action`:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- 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 }}
|
||||
shell: bash
|
||||
```
|
||||
|
||||
38
action.yml
38
action.yml
@@ -8,12 +8,48 @@ 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
|
||||
default: 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 }}'
|
||||
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 }}'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ inputs.flutter-version }}
|
||||
- id: flutter-action
|
||||
run: $GITHUB_ACTION_PATH/setup.sh -p -c '${{ inputs.cache-path }}' -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }}
|
||||
shell: bash
|
||||
- if: ${{ inputs.cache == 'true' }}
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.flutter-action.outputs.cache-path }}
|
||||
key: ${{ steps.flutter-action.outputs.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
|
||||
|
||||
261
setup.sh
261
setup.sh
@@ -1,96 +1,225 @@
|
||||
#!/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="$(dirname -- "${BASH_SOURCE[0]}")/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
|
||||
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=""
|
||||
USE_TEST_FIXTURE=false
|
||||
ARCH=""
|
||||
VERSION=""
|
||||
|
||||
if [[ $OS_NAME == windows ]]; then
|
||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter"
|
||||
PUB_CACHE="${USERPROFILE}\\.pub-cache"
|
||||
else
|
||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}/flutter"
|
||||
PUB_CACHE="${HOME}/.pub-cache"
|
||||
while getopts 'tc:k:pa:n:' flag; do
|
||||
case "$flag" in
|
||||
c) CACHE_PATH="$OPTARG" ;;
|
||||
k) CACHE_KEY="$OPTARG" ;;
|
||||
p) PRINT_MODE=true ;;
|
||||
t) USE_TEST_FIXTURE=true ;;
|
||||
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
|
||||
n) VERSION="$OPTARG" ;;
|
||||
?) exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
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:"
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
if [[ "$PRINT_MODE" == true ]]; then
|
||||
if [[ "$USE_TEST_FIXTURE" == true ]]; then
|
||||
RELEASE_MANIFEST=$(cat "$MANIFEST_TEST_FIXTURE")
|
||||
else
|
||||
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
|
||||
fi
|
||||
|
||||
if [[ "$CHANNEL" == master ]]; then
|
||||
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$CHANNEL\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
|
||||
else
|
||||
VERSION_MANIFEST=$(get_version_manifest)
|
||||
fi
|
||||
|
||||
if [[ -z "$VERSION_MANIFEST" ]]; then
|
||||
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version_info=$(echo "$VERSION_MANIFEST" | jq -j '.channel,":",.version,":",.dart_sdk_arch')
|
||||
|
||||
if [[ "$version_info" == *null* ]]; then
|
||||
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "::set-output name=channel::$(echo "$version_info" | awk -F ':' '{print $1}')"
|
||||
echo "::set-output name=version::$(echo "$version_info" | awk -F ':' '{print $2}')"
|
||||
echo "::set-output name=architecture::$(echo "$version_info" | awk -F ':' '{print $3}')"
|
||||
|
||||
expanded_key=$(expand_key "$CACHE_KEY")
|
||||
echo "::set-output name=cache-key::$expanded_key"
|
||||
|
||||
cache_path=$(transform_path "$CACHE_PATH")
|
||||
expanded_path=$(expand_key "$cache_path")
|
||||
|
||||
echo "::set-output name=cache-path::$expanded_path"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -x "${FLUTTER_ROOT}/bin/flutter" ]]; then
|
||||
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)
|
||||
CACHE_PATH=$(transform_path "$CACHE_PATH")
|
||||
SDK_CACHE=$(expand_key "$CACHE_PATH")
|
||||
PUB_CACHE=$(expand_key "$SDK_CACHE/.pub-cache")
|
||||
|
||||
if [[ $VERSION_MANIFEST == null ]]; then
|
||||
echo "Unable to determine Flutter version for $CHANNEL $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
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)
|
||||
|
||||
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive')
|
||||
download_archive "$ARCHIVE_PATH" "$RUNNER_TOOL_CACHE"
|
||||
fi
|
||||
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"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV
|
||||
echo "PUB_CACHE=${PUB_CACHE}" >>$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 "${PUB_CACHE}/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