Compare commits

...

16 Commits

Author SHA1 Message Date
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
5 changed files with 124 additions and 66 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
open_collective: flutter-action

View File

@@ -1,15 +1,21 @@
name: Main workflow
on: [push]
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
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: actions/checkout@v3
- uses: ./
with:
channel: ${{ matrix.channel }}
@@ -32,7 +38,7 @@ jobs:
version: [ 2.5.3, 2.x, 1, v1.12 ]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: ./
with:
channel: stable
@@ -47,7 +53,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: ./
with:
channel: master
@@ -61,7 +67,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: ./
with:
channel: any
@@ -72,19 +78,21 @@ jobs:
- name: Run flutter --version
shell: bash
run: flutter --version
test_with_cache:
runs-on: ubuntu-latest
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/cache@v2
with:
path: ${{ runner.tool_cache }}/flutter
key: flutter-2.5.0-stable
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
shell: bash
run: dart --version

View File

@@ -8,7 +8,7 @@ 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'
@@ -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 'master'
- run: flutter --version
```
@@ -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: '2.10.4'
- 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'
flutter-version: '2.10.4'
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'
flutter-version: '2.10.4'
- 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: 'beta'
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev
@@ -138,26 +139,27 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: beta
channel: 'beta'
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
flutter-version: '2.10.x'
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
architecture: x64 # optional, x64 or arm64
- run: flutter --version
```

View File

@@ -8,12 +8,33 @@ 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'
cache-path:
description: 'Flutter SDK cache path'
required: false
default: ${{ runner.tool_cache }}/flutter
architecture:
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
required: false
default: 'x64'
runs:
using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/setup.sh ${{ inputs.channel }} ${{ inputs.flutter-version }}
- 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 }} ${{ inputs.architecture }}
shell: bash

View File

@@ -14,19 +14,25 @@ normalize_version() {
}
latest_version() {
jq --arg channel "$1" '.releases | map(select(.channel==$channel)) | first'
jq --arg channel "$1" --arg arch "$ARCH" '.releases | map(select(.channel==$channel) | select(.dart_sdk_arch == null or .dart_sdk_arch == $arch)) | first'
}
wildcard_version() {
if [[ $1 == any ]]; then
jq --arg version "^$2" '.releases | map(select(.version | test($version))) | first'
if [ $2 == *"v"* ]; then # is legacy version format
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
elif [[ $1 == any ]]; then
jq --arg version "$2" --arg arch "$ARCH" '.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" '.releases | map(select(.channel==$channel) | select(.version | test($version))) | first'
jq --arg channel "$1" --arg version "$2" --arg arch "$ARCH" '.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
if [[ $2 == any ]]; then
latest_version $1
else
wildcard_version $1 $2
@@ -48,49 +54,69 @@ get_version_manifest() {
download_archive() {
archive_url="$MANIFEST_BASE_URL/$1"
archive_name=$(basename $1)
archive_local="$HOME/$archive_name"
archive_local="$RUNNER_TEMP/$archive_name"
curl --connect-timeout 15 --retry 5 $archive_url >$archive_local
# Create the target folder
mkdir -p "$2"
if [[ $archive_name == *zip ]]; then
unzip -o "$archive_local" -d "$2"
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"
tar xf "$archive_local" -C "$2" --strip-components=1
fi
rm $archive_local
}
CHANNEL="$1"
VERSION="$2"
transform_path() {
if [[ $OS_NAME == windows ]]; then
echo $1 | sed -e 's/^\///' -e 's/\//\\/g'
else
echo $1
fi
}
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"
fi
CACHE_PATH=""
if [[ ! -x "${FLUTTER_ROOT}/bin/flutter" ]]; then
while getopts 'c:' flag; do
case "${flag}" in
c) CACHE_PATH="$OPTARG" ;;
?) exit 2 ;;
esac
done
CHANNEL="${@:$OPTIND:1}"
VERSION="${@:$OPTIND+1:1}"
ARCH="${@:$OPTIND+2:1}"
SDK_CACHE="$(transform_path ${CACHE_PATH})"
PUB_CACHE="$(transform_path ${CACHE_PATH}/.pub-cache)"
if [[ ! -x "${SDK_CACHE}/bin/flutter" ]]; then
if [[ $CHANNEL == master ]]; then
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter"
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"
echo "Unable to determine Flutter version for channel: $CHANNEL version: $VERSION architecture: $ARCH"
exit 1
fi
fi
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive')
download_archive "$ARCHIVE_PATH" "$RUNNER_TOOL_CACHE"
download_archive "$ARCHIVE_PATH" "$SDK_CACHE"
fi
fi
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV
echo "FLUTTER_ROOT=${SDK_CACHE}" >>$GITHUB_ENV
echo "PUB_CACHE=${PUB_CACHE}" >>$GITHUB_ENV
echo "${FLUTTER_ROOT}/bin" >>$GITHUB_PATH
echo "${FLUTTER_ROOT}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
echo "${SDK_CACHE}/bin" >>$GITHUB_PATH
echo "${SDK_CACHE}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
echo "${PUB_CACHE}/bin" >>$GITHUB_PATH