Compare commits

...

10 Commits

Author SHA1 Message Date
Alif Rachmawadi
31089a7435 update readme
Some checks failed
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_cache (macos-latest) (push) Failing after 3s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 6m31s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 10s
Main workflow / test_version (v1.12) (push) Failing after 25s
Main workflow / test_any_channel (push) Failing after 16s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 18s
Main workflow / test_version (1) (push) Failing after 9s
Main workflow / test_version (2.5.3) (push) Failing after 8s
Main workflow / test_version (2.x) (push) Failing after 9s
Main workflow / test_cache (ubuntu-latest) (push) Failing after 18s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_cache (windows-latest) (push) Has been cancelled
2022-01-13 11:02:57 +00:00
Alif Rachmawadi
4f5d1c6d12 add cache path option 2022-01-13 10:46:00 +00:00
Alif Rachmawadi
03e576dcd6 actions/cache integration
Some checks failed
Main workflow / test_channel (beta, macos-latest) (push) Failing after 1s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_cache (macos-latest) (push) Failing after 3s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 49s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 9s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 9s
Main workflow / test_version (1) (push) Failing after 8s
Main workflow / test_version (2.5.3) (push) Failing after 9s
Main workflow / test_version (2.x) (push) Failing after 9s
Main workflow / test_version (v1.12) (push) Failing after 20s
Main workflow / test_any_channel (push) Failing after 15s
Main workflow / test_cache (ubuntu-latest) (push) Failing after 10s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_cache (windows-latest) (push) Has been cancelled
2022-01-10 04:45:27 +00:00
Alif Rachmawadi
f95a8c953b add actions/cache support
Some checks failed
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 8s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 18s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 8s
Main workflow / test_version (2.5.3) (push) Failing after 33s
Main workflow / test_any_channel (push) Failing after 15s
Main workflow / test_version (1) (push) Failing after 2m16s
Main workflow / test_version (2.x) (push) Failing after 32s
Main workflow / test_version (v1.12) (push) Failing after 23s
Main workflow / test_with_cache (push) Failing after 1m15s
Main workflow / test_channel (beta, macos-latest) (push) Failing after 3s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
2022-01-07 04:54:02 +00:00
Alif Rachmawadi
3dae472464 update readme 2022-01-06 16:00:13 +00:00
Alif Rachmawadi
523b0faa40 update readme for linux desktop dependencies (closes #49) 2022-01-06 11:45:16 +00:00
Alif Rachmawadi
813937b170 update readme for desktop build (closes #86) 2022-01-06 11:17:49 +00:00
Alif Rachmawadi
8af4ab61aa update readme 2022-01-06 11:12:10 +00:00
Alif Rachmawadi
59a5481c7d fix PUB_CACHE env
Some checks failed
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 16s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 16s
Main workflow / test_version (1) (push) Failing after 7s
Main workflow / test_version (v1.12) (push) Failing after 14s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 19s
Main workflow / test_version (2.5.3) (push) Failing after 7s
Main workflow / test_version (2.x) (push) Failing after 14s
Main workflow / test_any_channel (push) Failing after 15s
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (stable, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
2022-01-06 10:46:35 +00:00
Alif Rachmawadi
4686a99fc5 update readme
Some checks failed
Main workflow / test_channel (stable, macos-latest) (push) Failing after 3s
Main workflow / test_channel (beta, macos-latest) (push) Failing after 2s
Main workflow / test_channel (dev, macos-latest) (push) Failing after 2s
Main workflow / test_channel (beta, ubuntu-latest) (push) Failing after 15s
Main workflow / test_channel (dev, ubuntu-latest) (push) Failing after 9s
Main workflow / test_channel (stable, ubuntu-latest) (push) Failing after 8s
Main workflow / test_version (1) (push) Failing after 7s
Main workflow / test_version (2.5.3) (push) Failing after 14s
Main workflow / test_version (2.x) (push) Failing after 8s
Main workflow / test_version (v1.12) (push) Failing after 8s
Main workflow / test_any_channel (push) Failing after 8s
Main workflow / test_channel (beta, windows-latest) (push) Has been cancelled
Main workflow / test_channel (dev, windows-latest) (push) Has been cancelled
Main workflow / test_channel (stable, windows-latest) (push) Has been cancelled
Main workflow / test_master_channel (push) Has been cancelled
2022-01-06 09:55:43 +00:00
4 changed files with 154 additions and 93 deletions

View File

@@ -16,9 +16,9 @@ jobs:
- name: Print FLUTTER_ROOT - name: Print FLUTTER_ROOT
shell: bash shell: bash
run: echo "FLUTTER_ROOT set to $FLUTTER_ROOT" run: echo "FLUTTER_ROOT set to $FLUTTER_ROOT"
- name: Print PUBCACHE - name: Print PUB_CACHE
shell: bash shell: bash
run: echo "PUBCACHE set to $PUBCACHE" run: echo "PUB_CACHE set to $PUB_CACHE"
- name: Run dart --version - name: Run dart --version
shell: bash shell: bash
run: dart --version run: dart --version
@@ -72,3 +72,24 @@ jobs:
- name: Run flutter --version - name: Run flutter --version
shell: bash shell: bash
run: flutter --version 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: ./
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
- name: Run flutter --version
shell: bash
run: flutter --version

132
README.md
View File

@@ -1,21 +1,19 @@
# flutter-action # 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 ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
flutter-version: '2.0.5' flutter-version: '2.8.0'
- run: flutter pub get channel: 'stable'
- run: flutter test - run: flutter --version
``` ```
Use latest release for particular channel: Use latest release for particular channel:
@@ -23,16 +21,10 @@ Use latest release for particular channel:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: 'stable' # or: 'beta', 'dev' or 'master' channel: 'stable' # or: 'beta', 'dev' or 'master'
- run: flutter pub get - run: flutter --version
- run: flutter test
- run: flutter build apk
``` ```
Use latest release for particular version and/or channel: Use latest release for particular version and/or channel:
@@ -40,16 +32,11 @@ Use latest release for particular version and/or channel:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
flutter-version: '1.22.x' # or, you can use 1.22 flutter-version: '1.22.x' # or, you can use 1.22
channel: 'dev' channel: 'dev'
- run: flutter pub get - run: flutter --version
- run: flutter test
``` ```
Use particular version on any channel: Use particular version on any channel:
@@ -57,16 +44,11 @@ Use particular version on any channel:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
flutter-version: '2.x' flutter-version: '2.x'
channel: 'any' channel: 'any'
- run: flutter pub get - run: flutter --version
- run: flutter test
``` ```
Build Android APK and app bundle: Build Android APK and app bundle:
@@ -80,14 +62,14 @@ steps:
java-version: '11' java-version: '11'
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
flutter-version: '2.0.5' flutter-version: '2.5.3'
- run: flutter pub get - run: flutter pub get
- run: flutter test - run: flutter test
- run: flutter build apk - run: flutter build apk
- run: flutter build appbundle - run: flutter build appbundle
``` ```
Build for iOS too (macOS only): Build for iOS (macOS only):
```yaml ```yaml
jobs: jobs:
@@ -95,16 +77,11 @@ jobs:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
flutter-version: '2.0.5' flutter-version: '2.5.3'
- run: flutter pub get - run: flutter pub get
- run: flutter test - run: flutter test
- run: flutter build apk
- run: flutter build ios --release --no-codesign - run: flutter build ios --release --no-codesign
``` ```
@@ -115,7 +92,7 @@ steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
flutter-version: '2.0.5' flutter-version: '2.5.3'
- run: flutter pub get - run: flutter pub get
- run: flutter test - run: flutter test
- run: flutter build web - run: flutter build web
@@ -124,37 +101,62 @@ steps:
Build for Windows: Build for Windows:
```yaml ```yaml
windows: jobs:
runs-on: windows-latest build:
steps: runs-on: windows-latest
- uses: actions/checkout@v2 steps:
- uses: subosito/flutter-action@v2 - uses: actions/checkout@v2
with: - uses: subosito/flutter-action@v2
channel: beta with:
- run: flutter config --enable-windows-desktop channel: beta
- run: flutter build windows - run: flutter config --enable-windows-desktop
- run: flutter build windows
``` ```
Matrix Testing: Build for Linux desktop:
```yaml ```yaml
jobs: jobs:
test: build:
name: Test on ${{ matrix.os }} runs-on: ubuntu-latest
runs-on: ${{ matrix.os }} steps:
strategy: - uses: actions/checkout@v2
matrix: - uses: subosito/flutter-action@v2
os: [ubuntu-latest, windows-latest, macos-latest] with:
steps: channel: beta
- uses: actions/checkout@v2 - run: |
- uses: actions/setup-java@v2 sudo apt-get update -y
with: sudo apt-get install -y ninja-build libgtk-3-dev
distribution: 'zulu' - run: flutter config --enable-linux-desktop
java-version: '11' - run: flutter build linux
- uses: subosito/flutter-action@v2 ```
with:
flutter-version: '1.20.2' Build for macOS desktop:
channel: 'beta'
- run: dart --version ```yaml
- run: flutter --version jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
channel: beta
- run: flutter config --enable-macos-desktop
- run: flutter build macos
```
Integration with `actions/cache`:
```yaml
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
flutter-version: 2.5.0
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
- run: flutter --version
``` ```

View File

@@ -12,8 +12,24 @@ inputs:
description: 'The Flutter build release channel' description: 'The Flutter build release channel'
required: false required: false
default: 'stable' 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
runs: runs:
using: 'composite' using: 'composite'
steps: 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 }}
shell: bash shell: bash

View File

@@ -53,42 +53,64 @@ download_archive() {
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 if [[ $archive_name == *zip ]]; then
unzip -o "$archive_local" -d "$2" unzip -o "$archive_local" -d "$HOME"
shopt -s dotglob
mv ${HOME}/flutter/* "$2"
shopt -u dotglob
else else
tar xf "$archive_local" -C "$2" tar xf "$archive_local" -C "$2" --strip-components=1
fi fi
rm $archive_local rm $archive_local
} }
CHANNEL="$1" transform_path() {
VERSION="$2" if [[ $OS_NAME == windows ]]; then
echo $1 | sed -e 's/^\///' -e 's/\//\\/g'
if [[ $CHANNEL == master ]]; then else
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter" echo $1
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 fi
}
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive') SDK_CACHE=""
download_archive "$ARCHIVE_PATH" "$RUNNER_TOOL_CACHE"
fi while getopts 'c:' flag; do
case "${flag}" in
c) SDK_CACHE="$(transform_path $OPTARG)" ;;
?) exit 2 ;;
esac
done
CHANNEL="${@:$OPTIND:1}"
VERSION="${@:$OPTIND+1:1}"
if [[ $OS_NAME == windows ]]; then if [[ $OS_NAME == windows ]]; then
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter" PUB_CACHE="${USERPROFILE}\\.pub-cache"
PUBCACHE="${USERPROFILE}\\.pub-cache"
else else
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}/flutter" PUB_CACHE="${HOME}/.pub-cache"
PUBCACHE="${HOME}/.pub-cache"
fi fi
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV mkdir -p "$SDK_CACHE"
echo "PUB_CACHE=${PUBCACHE}" >>$GITHUB_ENV
echo "${FLUTTER_ROOT}/bin" >>$GITHUB_PATH if [[ ! -x "${SDK_CACHE}/bin/flutter" ]]; then
echo "${FLUTTER_ROOT}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH if [[ $CHANNEL == master ]]; then
echo "${PUBCACHE}/bin" >>$GITHUB_PATH 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
fi
echo "FLUTTER_ROOT=${SDK_CACHE}" >>$GITHUB_ENV
echo "PUB_CACHE=${PUB_CACHE}" >>$GITHUB_ENV
echo "${SDK_CACHE}/bin" >>$GITHUB_PATH
echo "${SDK_CACHE}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
echo "${PUB_CACHE}/bin" >>$GITHUB_PATH