mirror of
https://github.com/subosito/flutter-action.git
synced 2024-08-16 10:19:50 +02:00
add actions/cache support
This commit is contained in:
parent
3dae472464
commit
f95a8c953b
3 changed files with 50 additions and 14 deletions
19
.github/workflows/workflow.yml
vendored
19
.github/workflows/workflow.yml
vendored
|
@ -72,3 +72,22 @@ jobs:
|
|||
- name: Run flutter --version
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
test_with_cache:
|
||||
runs-on: ubuntu-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
|
||||
- name: Run dart --version
|
||||
shell: bash
|
||||
run: dart --version
|
||||
- name: Run flutter --version
|
||||
shell: bash
|
||||
run: flutter --version
|
||||
|
|
15
README.md
15
README.md
|
@ -146,3 +146,18 @@ jobs:
|
|||
- run: flutter build macos
|
||||
```
|
||||
|
||||
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
|
||||
- run: flutter --version
|
||||
```
|
||||
|
|
30
setup.sh
30
setup.sh
|
@ -64,20 +64,6 @@ download_archive() {
|
|||
CHANNEL="$1"
|
||||
VERSION="$2"
|
||||
|
||||
if [[ $CHANNEL == master ]]; then
|
||||
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter"
|
||||
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" "$RUNNER_TOOL_CACHE"
|
||||
fi
|
||||
|
||||
if [[ $OS_NAME == windows ]]; then
|
||||
FLUTTER_ROOT="${RUNNER_TOOL_CACHE}\\flutter"
|
||||
PUB_CACHE="${USERPROFILE}\\.pub-cache"
|
||||
|
@ -86,6 +72,22 @@ else
|
|||
PUB_CACHE="${HOME}/.pub-cache"
|
||||
fi
|
||||
|
||||
if [[ ! -x "${FLUTTER_ROOT}/bin/flutter" ]]; then
|
||||
if [[ $CHANNEL == master ]]; then
|
||||
git clone -b master https://github.com/flutter/flutter.git "$RUNNER_TOOL_CACHE/flutter"
|
||||
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" "$RUNNER_TOOL_CACHE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "FLUTTER_ROOT=${FLUTTER_ROOT}" >>$GITHUB_ENV
|
||||
echo "PUB_CACHE=${PUB_CACHE}" >>$GITHUB_ENV
|
||||
|
||||
|
|
Loading…
Reference in a new issue