Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c5eb12d81 | ||
|
|
62f096cacd | ||
|
|
844082558d | ||
|
|
14bf5302ef | ||
|
|
02b923c0e1 | ||
|
|
aa6d9b9844 |
15
.github/workflows/workflow.yml
vendored
15
.github/workflows/workflow.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
lint_shellcheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ludeeus/action-shellcheck@master
|
||||
test_channel:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
@@ -20,14 +20,20 @@ jobs:
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||
channel: [stable, beta, master]
|
||||
include:
|
||||
- operating-system: ubuntu-latest
|
||||
channel: main
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- id: flutter-action
|
||||
uses: ./
|
||||
with:
|
||||
channel: ${{ matrix.channel }}
|
||||
- name: Echo outputs
|
||||
run: |
|
||||
echo RUNNER-OS=${{ runner.os }}
|
||||
echo RUNNER-ARCH=${{ runner.arch }}
|
||||
|
||||
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 }}
|
||||
@@ -44,10 +50,11 @@ jobs:
|
||||
matrix:
|
||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./
|
||||
with:
|
||||
channel: stable
|
||||
flutter-version: '3.10.6'
|
||||
cache: true
|
||||
- run: dart --version
|
||||
shell: bash
|
||||
@@ -56,7 +63,7 @@ jobs:
|
||||
test_print_output:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- run: ./setup.sh -t -p | grep 'stable'
|
||||
shell: bash
|
||||
- run: ./setup.sh -t -p | grep '3.7.7'
|
||||
|
||||
52
README.md
52
README.md
@@ -8,10 +8,10 @@ Use specific version and channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.7.7'
|
||||
flutter-version: '3.16.9'
|
||||
channel: 'stable'
|
||||
- run: flutter --version
|
||||
```
|
||||
@@ -20,10 +20,10 @@ Use latest release for particular channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable' # or: 'beta', 'dev' or 'master'
|
||||
channel: 'stable' # or: 'beta', 'dev', 'master' (or 'main')
|
||||
- run: flutter --version
|
||||
```
|
||||
|
||||
@@ -31,7 +31,7 @@ Use latest release for particular version and/or channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '1.22.x'
|
||||
@@ -43,10 +43,10 @@ Use particular version on any channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '2.x'
|
||||
flutter-version: '3.x'
|
||||
channel: 'any'
|
||||
- run: flutter --version
|
||||
```
|
||||
@@ -55,7 +55,7 @@ Use particular git reference on master channel:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '5b12b74' # tag, commit or branch
|
||||
@@ -67,14 +67,10 @@ Build Android APK and app bundle:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.7.7'
|
||||
flutter-version: '3.16.9'
|
||||
- run: flutter pub get
|
||||
- run: flutter test
|
||||
- run: flutter build apk
|
||||
@@ -88,11 +84,10 @@ jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: flutter pub get
|
||||
- run: flutter test
|
||||
- run: flutter build ios --release --no-codesign
|
||||
@@ -102,7 +97,7 @@ Build for the web:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
@@ -118,11 +113,10 @@ jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'beta'
|
||||
- run: flutter config --enable-windows-desktop
|
||||
channel: 'stable'
|
||||
- run: flutter build windows
|
||||
```
|
||||
|
||||
@@ -133,14 +127,13 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
```
|
||||
|
||||
@@ -151,12 +144,10 @@ jobs:
|
||||
build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
architecture: x64
|
||||
- run: flutter config --enable-macos-desktop
|
||||
- run: flutter build macos
|
||||
```
|
||||
|
||||
@@ -164,18 +155,19 @@ Integration with `actions/cache`:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- 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
|
||||
pub-cache-key: 'flutter-pub:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache of dart pub get dependencies
|
||||
pub-cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path
|
||||
- run: flutter --version
|
||||
```
|
||||
|
||||
Note: `cache-key` and `cache-path` has support for several dynamic values:
|
||||
Note: `cache-key`, `pub-cache-key`, and `cache-path` has support for several dynamic values:
|
||||
|
||||
- `:os:`
|
||||
- `:channel:`
|
||||
@@ -188,7 +180,7 @@ Use outputs from `flutter-action`:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- id: flutter-action
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
@@ -199,5 +191,7 @@ steps:
|
||||
echo CHANNEL=${{ steps.flutter-action.outputs.CHANNEL }}
|
||||
echo VERSION=${{ steps.flutter-action.outputs.VERSION }}
|
||||
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
|
||||
echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||
echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}
|
||||
shell: bash
|
||||
```
|
||||
|
||||
29
action.yml
29
action.yml
@@ -16,15 +16,23 @@ inputs:
|
||||
cache:
|
||||
description: 'Cache the Flutter SDK'
|
||||
required: false
|
||||
default: false
|
||||
default: 'false'
|
||||
cache-key:
|
||||
description: 'Identifier for the Flutter SDK cache'
|
||||
required: false
|
||||
default: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
|
||||
pub-cache-key:
|
||||
description: 'Identifier for the Dart .pub-cache cache'
|
||||
required: false
|
||||
default: 'flutter-pub:os:-:channel:-:version:-:arch:-:hash:'
|
||||
cache-path:
|
||||
description: 'Flutter SDK cache path'
|
||||
required: false
|
||||
default: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
|
||||
pub-cache-path:
|
||||
description: 'Flutter pub cache path'
|
||||
required: false
|
||||
default: 'default'
|
||||
architecture:
|
||||
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
|
||||
required: false
|
||||
@@ -40,21 +48,32 @@ outputs:
|
||||
value: '${{ steps.flutter-action.outputs.VERSION }}'
|
||||
ARCHITECTURE:
|
||||
value: '${{ steps.flutter-action.outputs.ARCHITECTURE }}'
|
||||
PUB-CACHE-KEY:
|
||||
value: '${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}'
|
||||
PUB-CACHE-PATH:
|
||||
value: '${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}'
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- run: chmod +x $GITHUB_ACTION_PATH/setup.sh
|
||||
shell: bash
|
||||
- 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 }}
|
||||
run: $GITHUB_ACTION_PATH/setup.sh -p -c '${{ inputs.cache-path }}' -k '${{ inputs.cache-key }}' -d '${{ inputs.pub-cache-path }}' -l '${{ inputs.pub-cache-key }}' -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }}
|
||||
shell: bash
|
||||
- if: ${{ inputs.cache == 'true' }}
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.flutter-action.outputs.CACHE-PATH }}
|
||||
key: ${{ steps.flutter-action.outputs.CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||
key: ${{ steps.flutter-action.outputs.CACHE-KEY }}
|
||||
restore-keys: |
|
||||
${{ steps.flutter-action.outputs.CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||
${{ steps.flutter-action.outputs.CACHE-KEY }}
|
||||
- if: ${{ inputs.cache == 'true' }}
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}
|
||||
key: ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||
restore-keys: |
|
||||
${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
|
||||
${{ steps.flutter-action.outputs.PUB-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
|
||||
|
||||
44
setup.sh
44
setup.sh
@@ -10,6 +10,7 @@ if ! check_command jq; then
|
||||
fi
|
||||
|
||||
OS_NAME=$(echo "$RUNNER_OS" | awk '{print tolower($0)}')
|
||||
ARCH_NAME=$(echo "$RUNNER_ARCH" | awk '{print tolower($0)}')
|
||||
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
|
||||
MANIFEST_JSON_PATH="releases_$OS_NAME.json"
|
||||
MANIFEST_URL="$MANIFEST_BASE_URL/$MANIFEST_JSON_PATH"
|
||||
@@ -50,7 +51,7 @@ download_archive() {
|
||||
if [[ "$archive_name" == *zip ]]; then
|
||||
EXTRACT_PATH="$RUNNER_TEMP/_unzip_temp"
|
||||
unzip -q -o "$archive_local" -d "$EXTRACT_PATH"
|
||||
# Remove the folder again so that the move command can do a simple rename\
|
||||
# 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
|
||||
@@ -66,15 +67,19 @@ download_archive() {
|
||||
|
||||
CACHE_PATH=""
|
||||
CACHE_KEY=""
|
||||
PUB_CACHE_PATH=""
|
||||
PUB_CACHE_KEY=""
|
||||
PRINT_ONLY=""
|
||||
TEST_MODE=false
|
||||
ARCH=""
|
||||
VERSION=""
|
||||
|
||||
while getopts 'tc:k:pa:n:' flag; do
|
||||
while getopts 'tc:k:d:l:pa:n:' flag; do
|
||||
case "$flag" in
|
||||
c) CACHE_PATH="$OPTARG" ;;
|
||||
k) CACHE_KEY="$OPTARG" ;;
|
||||
d) PUB_CACHE_PATH="$OPTARG" ;;
|
||||
l) PUB_CACHE_KEY="$OPTARG" ;;
|
||||
p) PRINT_ONLY=true ;;
|
||||
t) TEST_MODE=true ;;
|
||||
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
|
||||
@@ -83,6 +88,8 @@ while getopts 'tc:k:pa:n:' flag; do
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -z $ARCH ]] && ARCH="$ARCH_NAME"
|
||||
|
||||
ARR_CHANNEL=("${@:$OPTIND:1}")
|
||||
CHANNEL="${ARR_CHANNEL[0]}"
|
||||
|
||||
@@ -91,6 +98,24 @@ CHANNEL="${ARR_CHANNEL[0]}"
|
||||
[[ -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:"
|
||||
[[ -z $PUB_CACHE_KEY ]] && PUB_CACHE_KEY="flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
|
||||
[[ -z $PUB_CACHE_PATH ]] && PUB_CACHE_PATH="default"
|
||||
|
||||
# `PUB_CACHE` is what Dart and Flutter looks for in the environment, while
|
||||
# `PUB_CACHE_PATH` is passed in from the action.
|
||||
#
|
||||
# If `PUB_CACHE` is set already, then it should continue to be used. Otherwise, satisfy it
|
||||
# if the action requests a custom path, or set to the Dart default values depending
|
||||
# on the operating system.
|
||||
if [ -z "$PUB_CACHE" ]; then
|
||||
if [ "$PUB_CACHE_PATH" != "default" ]; then
|
||||
PUB_CACHE="$PUB_CACHE_PATH"
|
||||
elif [ "$OS_NAME" == "windows" ]; then
|
||||
PUB_CACHE="$LOCALAPPDATA\\Pub\\Cache"
|
||||
else
|
||||
PUB_CACHE="$HOME/.pub-cache"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$TEST_MODE" == true ]]; then
|
||||
RELEASE_MANIFEST=$(cat "$(dirname -- "${BASH_SOURCE[0]}")/test/$MANIFEST_JSON_PATH")
|
||||
@@ -98,7 +123,7 @@ else
|
||||
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
|
||||
fi
|
||||
|
||||
if [[ "$CHANNEL" == "master" ]]; then
|
||||
if [[ "$CHANNEL" == "master" || "$CHANNEL" == "main" ]]; then
|
||||
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$VERSION\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
|
||||
else
|
||||
VERSION_MANIFEST=$(echo "$RELEASE_MANIFEST" | filter_by_channel "$CHANNEL" | filter_by_arch "$ARCH" | filter_by_version "$VERSION")
|
||||
@@ -127,6 +152,7 @@ expand_key() {
|
||||
}
|
||||
|
||||
CACHE_KEY=$(expand_key "$CACHE_KEY")
|
||||
PUB_CACHE_KEY=$(expand_key "$PUB_CACHE_KEY")
|
||||
CACHE_PATH=$(expand_key "$(transform_path "$CACHE_PATH")")
|
||||
|
||||
if [[ "$PRINT_ONLY" == true ]]; then
|
||||
@@ -142,6 +168,8 @@ if [[ "$PRINT_ONLY" == true ]]; then
|
||||
echo "ARCHITECTURE=$info_architecture"
|
||||
echo "CACHE-KEY=$CACHE_KEY"
|
||||
echo "CACHE-PATH=$CACHE_PATH"
|
||||
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
|
||||
echo "PUB-CACHE-PATH=$PUB_CACHE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -151,14 +179,16 @@ if [[ "$PRINT_ONLY" == true ]]; then
|
||||
echo "ARCHITECTURE=$info_architecture"
|
||||
echo "CACHE-KEY=$CACHE_KEY"
|
||||
echo "CACHE-PATH=$CACHE_PATH"
|
||||
echo "PUB-CACHE-KEY=$PUB_CACHE_KEY"
|
||||
echo "PUB-CACHE-PATH=$PUB_CACHE"
|
||||
} >>"$GITHUB_OUTPUT"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -x "$CACHE_PATH/bin/flutter" ]]; then
|
||||
if [[ "$CHANNEL" == "master" ]]; then
|
||||
git clone -b master https://github.com/flutter/flutter.git "$CACHE_PATH"
|
||||
if [[ "$CHANNEL" == "master" || "$CHANNEL" == "main" ]]; then
|
||||
git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$CACHE_PATH"
|
||||
if [[ "$VERSION" != "any" ]]; then
|
||||
git config --global --add safe.directory "$CACHE_PATH"
|
||||
(cd "$CACHE_PATH" && git checkout "$VERSION")
|
||||
@@ -171,11 +201,11 @@ fi
|
||||
|
||||
{
|
||||
echo "FLUTTER_ROOT=$CACHE_PATH"
|
||||
echo "PUB_CACHE=$CACHE_PATH/.pub-cache"
|
||||
echo "PUB_CACHE=$PUB_CACHE"
|
||||
} >>"$GITHUB_ENV"
|
||||
|
||||
{
|
||||
echo "$CACHE_PATH/bin"
|
||||
echo "$CACHE_PATH/bin/cache/dart-sdk/bin"
|
||||
echo "$CACHE_PATH/.pub-cache/bin"
|
||||
echo "$PUB_CACHE/bin"
|
||||
} >>"$GITHUB_PATH"
|
||||
|
||||
Reference in New Issue
Block a user