Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
github: [subosito]
|
||||
170
.github/workflows/workflow.yml
vendored
170
.github/workflows/workflow.yml
vendored
@@ -1,95 +1,125 @@
|
||||
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]
|
||||
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
|
||||
strategy:
|
||||
matrix:
|
||||
version: [ 2.5.3, 2.x, 1, v1.12 ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: ${{ matrix.version }}
|
||||
- name: Run dart --version
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
test_master_channel:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
channel: master
|
||||
- name: Run dart --version
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
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
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
test_cache:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
matrix:
|
||||
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: 2.5.0
|
||||
cache: true
|
||||
cache-key: key-20220113
|
||||
cache-path: ${{ runner.tool_cache }}/flutter/2.5.0-stable
|
||||
- name: Run dart --version
|
||||
- run: dart --version
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
- run: flutter --version
|
||||
shell: bash
|
||||
test_print_output:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: ./setup.sh -t -p | grep 'stable'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p | grep '3.7.7'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p | grep 'x64'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p stable | grep 'stable'
|
||||
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 -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 -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
|
||||
run: flutter --version
|
||||
|
||||
77
README.md
77
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.7.7'
|
||||
channel: 'stable'
|
||||
- run: flutter --version
|
||||
```
|
||||
@@ -20,10 +20,10 @@ 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'
|
||||
channel: 'stable' # or: 'beta' or 'dev'
|
||||
- run: flutter --version
|
||||
```
|
||||
|
||||
@@ -31,10 +31,10 @@ 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
|
||||
flutter-version: '1.22.x'
|
||||
channel: 'dev'
|
||||
- run: flutter --version
|
||||
```
|
||||
@@ -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.7.7'
|
||||
- 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,10 +139,11 @@ 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
|
||||
```
|
||||
@@ -150,13 +152,40 @@ Integration with `actions/cache`:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: 2.5.0
|
||||
channel: stable
|
||||
channel: 'stable'
|
||||
cache: true
|
||||
cache-key: flutter # optional, change this to force refresh cache
|
||||
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
|
||||
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
|
||||
```
|
||||
|
||||
39
action.yml
39
action.yml
@@ -8,6 +8,7 @@ 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
|
||||
@@ -15,21 +16,43 @@ inputs:
|
||||
cache:
|
||||
description: 'Cache the Flutter SDK'
|
||||
required: false
|
||||
default: false
|
||||
cache-key:
|
||||
description: 'Identifier for the Flutter SDK cache'
|
||||
required: false
|
||||
default: 'flutter'
|
||||
default: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
|
||||
cache-path:
|
||||
description: 'Flutter SDK cache path'
|
||||
required: false
|
||||
default: ${{ runner.tool_cache }}/flutter
|
||||
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:
|
||||
- if: ${{ inputs.cache == 'true' }}
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ inputs.cache-path }}
|
||||
key: ${{ inputs.cache-key }}-${{ inputs.channel }}-${{ inputs.flutter-version }}
|
||||
- run: $GITHUB_ACTION_PATH/setup.sh -c "${{ inputs.cache-path }}" ${{ inputs.channel }} ${{ inputs.flutter-version }}
|
||||
- id: flutter-action
|
||||
run: $GITHUB_ACTION_PATH/setup.sh -p -c '${{ inputs.cache-path }}' -k '${{ inputs.cache-key }}' -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 }}-${{ hashFiles('**/pubspec.lock') }}
|
||||
restore-keys: |
|
||||
${{ steps.flutter-action.outputs.CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||
${{ 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
|
||||
|
||||
229
setup.sh
229
setup.sh
@@ -1,116 +1,167 @@
|
||||
#!/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_JSON_PATH="releases_$OS_NAME.json"
|
||||
MANIFEST_URL="$MANIFEST_BASE_URL/$MANIFEST_JSON_PATH"
|
||||
|
||||
# convert version like 2.5.x to 2.5
|
||||
normalize_version() {
|
||||
if [[ $1 == *x ]]; then
|
||||
echo ${1::-2}
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
filter_by_channel() {
|
||||
jq --arg channel "$1" '[.releases[] | select($channel == "any" or .channel == $channel)]'
|
||||
}
|
||||
|
||||
latest_version() {
|
||||
jq --arg channel "$1" '.releases | map(select(.channel==$channel)) | first'
|
||||
filter_by_arch() {
|
||||
jq --arg arch "$1" '[.[] | select(.dart_sdk_arch == $arch or ($arch == "x64" and (has("dart_sdk_arch") | not)))]'
|
||||
}
|
||||
|
||||
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
|
||||
filter_by_version() {
|
||||
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)'
|
||||
}
|
||||
|
||||
get_version() {
|
||||
if [[ -z $2 ]]; then
|
||||
latest_version $1
|
||||
else
|
||||
wildcard_version $1 $2
|
||||
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))
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
download_archive() {
|
||||
archive_url="$MANIFEST_BASE_URL/$1"
|
||||
archive_name=$(basename $1)
|
||||
archive_local="$HOME/$archive_name"
|
||||
|
||||
curl --connect-timeout 15 --retry 5 $archive_url >$archive_local
|
||||
|
||||
if [[ $archive_name == *zip ]]; then
|
||||
unzip -o "$archive_local" -d "$HOME"
|
||||
shopt -s dotglob
|
||||
mv ${HOME}/flutter/* "$2"
|
||||
shopt -u dotglob
|
||||
else
|
||||
tar xf "$archive_local" -C "$2" --strip-components=1
|
||||
fi
|
||||
|
||||
rm $archive_local
|
||||
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
|
||||
if [[ "$OS_NAME" == windows ]]; then
|
||||
echo "$1" | sed -e 's/^\///' -e 's/\//\\/g'
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
SDK_CACHE=""
|
||||
download_archive() {
|
||||
archive_url="$MANIFEST_BASE_URL/$1"
|
||||
archive_name=$(basename "$1")
|
||||
archive_local="$RUNNER_TEMP/$archive_name"
|
||||
|
||||
while getopts 'c:' flag; do
|
||||
case "${flag}" in
|
||||
c) SDK_CACHE="$(transform_path $OPTARG)" ;;
|
||||
?) exit 2 ;;
|
||||
esac
|
||||
curl --connect-timeout 15 --retry 5 "$archive_url" >"$archive_local"
|
||||
|
||||
mkdir -p "$2"
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
CACHE_PATH=""
|
||||
CACHE_KEY=""
|
||||
PRINT_ONLY=""
|
||||
TEST_MODE=false
|
||||
ARCH=""
|
||||
VERSION=""
|
||||
|
||||
while getopts 'tc:k:pa:n:' flag; do
|
||||
case "$flag" in
|
||||
c) CACHE_PATH="$OPTARG" ;;
|
||||
k) 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
|
||||
|
||||
CHANNEL="${@:$OPTIND:1}"
|
||||
VERSION="${@:$OPTIND+1:1}"
|
||||
ARR_CHANNEL=("${@:$OPTIND:1}")
|
||||
CHANNEL="${ARR_CHANNEL[0]}"
|
||||
|
||||
if [[ $OS_NAME == windows ]]; then
|
||||
PUB_CACHE="${USERPROFILE}\\.pub-cache"
|
||||
[[ -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:"
|
||||
|
||||
if [[ "$TEST_MODE" == true ]]; then
|
||||
RELEASE_MANIFEST=$(cat "$(dirname -- "${BASH_SOURCE[0]}")/test/$MANIFEST_JSON_PATH")
|
||||
else
|
||||
PUB_CACHE="${HOME}/.pub-cache"
|
||||
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
|
||||
fi
|
||||
|
||||
mkdir -p "$SDK_CACHE"
|
||||
VERSION_MANIFEST=$(echo "$RELEASE_MANIFEST" | filter_by_channel "$CHANNEL" | filter_by_arch "$ARCH" | filter_by_version "$VERSION")
|
||||
|
||||
if [[ ! -x "${SDK_CACHE}/bin/flutter" ]]; then
|
||||
if [[ $CHANNEL == master ]]; then
|
||||
git clone -b master https://github.com/flutter/flutter.git "$SDK_CACHE"
|
||||
else
|
||||
VERSION_MANIFEST=$(get_version_manifest $CHANNEL $VERSION)
|
||||
|
||||
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" "$SDK_CACHE"
|
||||
fi
|
||||
if [[ "$VERSION_MANIFEST" == *null* ]]; then
|
||||
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "FLUTTER_ROOT=${SDK_CACHE}" >>$GITHUB_ENV
|
||||
echo "PUB_CACHE=${PUB_CACHE}" >>$GITHUB_ENV
|
||||
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 // "x64"')
|
||||
version_hash=$(echo "$VERSION_MANIFEST" | jq -r '.hash')
|
||||
version_sha_256=$(echo "$VERSION_MANIFEST" | jq -r '.sha256')
|
||||
|
||||
echo "${SDK_CACHE}/bin" >>$GITHUB_PATH
|
||||
echo "${SDK_CACHE}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
|
||||
echo "${PUB_CACHE}/bin" >>$GITHUB_PATH
|
||||
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")
|
||||
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"
|
||||
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"
|
||||
} >>"$GITHUB_OUTPUT"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -x "$CACHE_PATH/bin/flutter" ]]; then
|
||||
archive_url=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
|
||||
download_archive "$archive_url" "$CACHE_PATH"
|
||||
fi
|
||||
|
||||
{
|
||||
echo "FLUTTER_ROOT=$CACHE_PATH"
|
||||
echo "PUB_CACHE=$CACHE_PATH/.pub-cache"
|
||||
} >>"$GITHUB_ENV"
|
||||
|
||||
{
|
||||
echo "$CACHE_PATH/bin"
|
||||
echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
|
||||
echo "$CACHE_PATH/.pub-cache/bin"
|
||||
} >>"$GITHUB_PATH"
|
||||
|
||||
4414
test/releases_linux.json
Normal file
4414
test/releases_linux.json
Normal file
File diff suppressed because it is too large
Load Diff
4896
test/releases_macos.json
Normal file
4896
test/releases_macos.json
Normal file
File diff suppressed because it is too large
Load Diff
4414
test/releases_windows.json
Normal file
4414
test/releases_windows.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user