mirror of
https://github.com/subosito/flutter-action.git
synced 2024-08-16 10:19:50 +02:00
dynamic cache path
This commit is contained in:
parent
472d887f68
commit
c30358aafe
4 changed files with 64 additions and 30 deletions
42
.github/workflows/workflow.yml
vendored
42
.github/workflows/workflow.yml
vendored
|
@ -79,35 +79,49 @@ jobs:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run: ./setup.sh -p cache-key | grep -x 'flutter-macos-x64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
- run: ./setup.sh -p cache-key | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key stable | grep -x 'flutter-macos-x64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
- run: ./setup.sh -p cache-key stable | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key beta | grep -x 'flutter-macos-x64-beta-3.1.0-9.0.pre-f28e570c8cb12a004fae2d796d0d9cd46603bde9'
|
- run: ./setup.sh -p cache-key beta | grep -x 'flutter-macos-beta-3.1.0-9.0.pre-x64-f28e570c8cb12a004fae2d796d0d9cd46603bde9'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key master | grep -x 'flutter-macos-x64-master-master-master'
|
- run: ./setup.sh -p cache-key master | grep -x 'flutter-macos-master-master-x64-master'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key stable 2 | grep -x 'flutter-macos-x64-stable-2.10.5-5464c5bac742001448fe4fc0597be939379f88ea'
|
- run: ./setup.sh -p cache-key stable 2 | grep -x 'flutter-macos-stable-2.10.5-x64-5464c5bac742001448fe4fc0597be939379f88ea'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key beta 2 | grep -x 'flutter-macos-x64-beta-2.13.0-0.4.pre-25caf1461b8f643092a9f6f5b224453b5c057d10'
|
- run: ./setup.sh -p cache-key beta 2 | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key any 2 | grep -x 'flutter-macos-x64-beta-2.13.0-0.4.pre-25caf1461b8f643092a9f6f5b224453b5c057d10'
|
- run: ./setup.sh -p cache-key any 2 | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key any 3 | grep -x 'flutter-macos-x64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
- run: ./setup.sh -p cache-key any 3 | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key any 3 arm64 | grep -x 'flutter-macos-arm64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
- run: ./setup.sh -p cache-key any 3 arm64 | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key stable any arm64 | grep -x 'flutter-macos-arm64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
- run: ./setup.sh -p cache-key stable any arm64 | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key stable 1 | grep -x 'flutter-macos-x64-stable-1.22.6-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
|
- run: ./setup.sh -p cache-key stable 1 | grep -x 'flutter-macos-stable-1.22.6-x64-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key stable v1 | grep -x 'flutter-macos-x64-stable-v1.12.13+hotfix.9-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
|
- run: ./setup.sh -p cache-key stable v1 | grep -x 'flutter-macos-stable-v1.12.13+hotfix.9-x64-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key any 0 | grep -x 'flutter-macos-x64-beta-v0.11.13-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
- run: ./setup.sh -p cache-key any 0 | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key any v0 | grep -x 'flutter-macos-x64-beta-v0.11.13-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
- run: ./setup.sh -p cache-key any v0 | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:hash:' | grep -x 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:hash:' | grep -x 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
shell: bash
|
shell: bash
|
||||||
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:sha256:' | grep -x 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
|
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:sha256:' | grep -x 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
test_cache_path:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: ./setup.sh -p cache-path | grep -x '/home/runner/work/_temp/flutter/stable-3.0.5-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -p cache-path stable | grep -x '/home/runner/work/_temp/flutter/stable-3.0.5-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -p cache-path beta | grep -x '/home/runner/work/_temp/flutter/beta-3.1.0-9.0.pre-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -p cache-path master | grep -x '/home/runner/work/_temp/flutter/master-master-x64'
|
||||||
|
shell: bash
|
||||||
|
- run: ./setup.sh -p cache-path -c '/tmp/flutter/:channel:-:version:-:hash:' | grep -x '/tmp/flutter/stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
|
||||||
|
shell: bash
|
||||||
|
|
|
@ -157,17 +157,17 @@ steps:
|
||||||
with:
|
with:
|
||||||
channel: 'stable'
|
channel: 'stable'
|
||||||
cache: true
|
cache: true
|
||||||
cache-key: 'flutter-:os:-:arch:-:channel:-:version:-:hash:' # optional, change this to force refresh cache
|
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:' # optional, change this to force refresh cache
|
||||||
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
|
cache-path: ${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch: # optional, change this to specify the cache path
|
||||||
architecture: x64 # optional, x64 or arm64
|
architecture: x64 # optional, x64 or arm64
|
||||||
- run: flutter --version
|
- run: flutter --version
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: `cache-key` has support for several dynamic values:
|
Note: `cache-key` and `cache-path` has support for several dynamic values:
|
||||||
|
|
||||||
- `:os:`
|
- `:os:`
|
||||||
- `:arch:`
|
|
||||||
- `:channel:`
|
- `:channel:`
|
||||||
- `:version:`
|
- `:version:`
|
||||||
|
- `:arch:`
|
||||||
- `:hash:`
|
- `:hash:`
|
||||||
- `:sha256:`
|
- `:sha256:`
|
||||||
|
|
11
action.yml
11
action.yml
|
@ -19,11 +19,11 @@ inputs:
|
||||||
cache-key:
|
cache-key:
|
||||||
description: 'Identifier for the Flutter SDK cache'
|
description: 'Identifier for the Flutter SDK cache'
|
||||||
required: false
|
required: false
|
||||||
default: 'flutter-:os:-:arch:-:channel:-:version:-:hash:'
|
default: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
|
||||||
cache-path:
|
cache-path:
|
||||||
description: 'Flutter SDK cache path'
|
description: 'Flutter SDK cache path'
|
||||||
required: false
|
required: false
|
||||||
default: ${{ runner.tool_cache }}/flutter
|
default: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
|
||||||
architecture:
|
architecture:
|
||||||
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
|
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
|
||||||
required: false
|
required: false
|
||||||
|
@ -31,6 +31,9 @@ inputs:
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
|
- id: flutter-action-cache-path-builder
|
||||||
|
run: echo "::set-output name=cache-path::$($GITHUB_ACTION_PATH/setup.sh -p cache-path -c '${{ inputs.cache-path }}' ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }})"
|
||||||
|
shell: bash
|
||||||
- if: ${{ inputs.cache == 'true' }}
|
- if: ${{ inputs.cache == 'true' }}
|
||||||
id: flutter-action-cache-key-builder
|
id: flutter-action-cache-key-builder
|
||||||
run: echo "::set-output name=cache-key::$($GITHUB_ACTION_PATH/setup.sh -p cache-key -k ${{ inputs.cache-key }} ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }})"
|
run: echo "::set-output name=cache-key::$($GITHUB_ACTION_PATH/setup.sh -p cache-key -k ${{ inputs.cache-key }} ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }})"
|
||||||
|
@ -38,7 +41,7 @@ runs:
|
||||||
- if: ${{ inputs.cache == 'true' }}
|
- if: ${{ inputs.cache == 'true' }}
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ inputs.cache-path }}
|
path: ${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}
|
||||||
key: ${{ steps.flutter-action-cache-key-builder.outputs.cache-key }}
|
key: ${{ steps.flutter-action-cache-key-builder.outputs.cache-key }}
|
||||||
- run: $GITHUB_ACTION_PATH/setup.sh -c "${{ inputs.cache-path }}" ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }}
|
- run: $GITHUB_ACTION_PATH/setup.sh -c '${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}' ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
33
setup.sh
33
setup.sh
|
@ -109,8 +109,8 @@ ARCH=$(echo "${ARR_ARCH[0]}" | awk '{print tolower($0)}')
|
||||||
[[ -z $CHANNEL ]] && CHANNEL=stable
|
[[ -z $CHANNEL ]] && CHANNEL=stable
|
||||||
[[ -z $VERSION ]] && VERSION=any
|
[[ -z $VERSION ]] && VERSION=any
|
||||||
[[ -z $ARCH ]] && ARCH=x64
|
[[ -z $ARCH ]] && ARCH=x64
|
||||||
[[ -z $CACHE_PATH ]] && CACHE_PATH=/tmp
|
[[ -z $CACHE_PATH ]] && CACHE_PATH="$RUNNER_TEMP/flutter/:channel:-:version:-:arch:"
|
||||||
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:arch:-:channel:-:version:-:hash:"
|
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:channel:-:version:-:arch:-:hash:"
|
||||||
|
|
||||||
RELEASE_MANIFEST=""
|
RELEASE_MANIFEST=""
|
||||||
VERSION_MANIFEST=""
|
VERSION_MANIFEST=""
|
||||||
|
@ -165,11 +165,20 @@ if [[ -n "$PRINT_MODE" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PRINT_MODE" == cache-key ]]; then
|
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$CHANNEL\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
|
||||||
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$CHANNEL\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
|
|
||||||
EXPANDED_KEY=$(expand_key "$CACHE_KEY")
|
|
||||||
|
|
||||||
echo "$EXPANDED_KEY"
|
if [[ "$PRINT_MODE" == cache-key ]]; then
|
||||||
|
expanded_key=$(expand_key "$CACHE_KEY")
|
||||||
|
|
||||||
|
echo "$expanded_key"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$PRINT_MODE" == cache-path ]]; then
|
||||||
|
cache_path=$(transform_path "$CACHE_PATH")
|
||||||
|
expanded_path=$(expand_key "$cache_path")
|
||||||
|
|
||||||
|
echo "$expanded_path"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -190,9 +199,17 @@ if [[ -n "$PRINT_MODE" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PRINT_MODE" == cache-key ]]; then
|
if [[ "$PRINT_MODE" == cache-key ]]; then
|
||||||
EXPANDED_KEY=$(expand_key "$CACHE_KEY")
|
expanded_key=$(expand_key "$CACHE_KEY")
|
||||||
|
|
||||||
echo "$EXPANDED_KEY"
|
echo "$expanded_key"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$PRINT_MODE" == cache-path ]]; then
|
||||||
|
cache_path=$(transform_path "$CACHE_PATH")
|
||||||
|
expanded_path=$(expand_key "$cache_path")
|
||||||
|
|
||||||
|
echo "$expanded_path"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue