Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5878a0492 | ||
|
|
31089a7435 | ||
|
|
4f5d1c6d12 | ||
|
|
03e576dcd6 |
14
.github/workflows/workflow.yml
vendored
14
.github/workflows/workflow.yml
vendored
@@ -72,19 +72,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: ./
|
||||
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
|
||||
|
||||
11
README.md
11
README.md
@@ -146,18 +146,17 @@ jobs:
|
||||
- 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: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
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
|
||||
```
|
||||
|
||||
18
action.yml
18
action.yml
@@ -12,8 +12,24 @@ inputs:
|
||||
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
|
||||
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 }}
|
||||
shell: bash
|
||||
|
||||
44
setup.sh
44
setup.sh
@@ -53,28 +53,48 @@ download_archive() {
|
||||
curl --connect-timeout 15 --retry 5 $archive_url >$archive_local
|
||||
|
||||
if [[ $archive_name == *zip ]]; then
|
||||
unzip -o "$archive_local" -d "$2"
|
||||
unzip -q -o "$archive_local" -d "$HOME"
|
||||
shopt -s dotglob
|
||||
mv ${HOME}/flutter/* "$2"
|
||||
shopt -u dotglob
|
||||
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
|
||||
}
|
||||
|
||||
SDK_CACHE=""
|
||||
|
||||
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
|
||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter"
|
||||
PUB_CACHE="${USERPROFILE}\\.pub-cache"
|
||||
else
|
||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}/flutter"
|
||||
PUB_CACHE="${HOME}/.pub-cache"
|
||||
fi
|
||||
|
||||
if [[ ! -x "${FLUTTER_ROOT}/bin/flutter" ]]; then
|
||||
mkdir -p "$SDK_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)
|
||||
|
||||
@@ -84,13 +104,13 @@ if [[ ! -x "${FLUTTER_ROOT}/bin/flutter" ]]; then
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user