Compare commits

...

9 Commits

Author SHA1 Message Date
Alif Rachmawadi
dbf1fa04f4 Replace set-output with $GITHUB_OUTPUT; fixes #192 (#194)
* replace set-output with $GITHUB_OUTPUT

* use stdout for test mode

* update readme
2022-10-13 06:31:27 +07:00
Adrien Padol
1e6ee87cb8 Added missing parameter for cache-key (#187) 2022-09-17 07:11:03 +07:00
Alif Rachmawadi
45dd344cec github sponsor 2022-09-08 11:37:17 +07:00
Alif Rachmawadi
de3cdb9a4b enhance set output 2022-09-08 09:12:35 +07:00
Alif Rachmawadi
1e952778af enhance set output 2022-09-08 00:57:19 +07:00
Alif Rachmawadi
9d48f4efd5 use named arguments for version and arch 2022-08-25 17:24:16 +07:00
Alif Rachmawadi
6c2e035f26 fix test manifest load 2022-07-26 17:47:54 +07:00
Alif Rachmawadi
c30358aafe dynamic cache path 2022-07-26 13:20:39 +07:00
Alif Rachmawadi
472d887f68 update readme 2022-07-26 11:56:47 +07:00
5 changed files with 163 additions and 94 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
github: [subosito]

View File

@@ -3,6 +3,7 @@ on:
push:
branches:
- main
- dev
pull_request:
paths:
- setup.sh
@@ -21,9 +22,18 @@ jobs:
channel: [stable, beta, master]
steps:
- uses: actions/checkout@v3
- uses: ./
- id: flutter-action
uses: ./
with:
channel: ${{ matrix.channel }}
- name: Echo outputs
run: |
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 }}
echo VERSION=${{ steps.flutter-action.outputs.VERSION }}
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
shell: bash
- run: dart --version
shell: bash
- run: flutter --version
@@ -43,71 +53,95 @@ jobs:
shell: bash
- run: flutter --version
shell: bash
test_version:
test_print_output:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: ./setup.sh -p version | grep -x 'stable:any:x64|stable:3.0.5:x64'
- run: ./setup.sh -t -p | grep 'stable'
shell: bash
- run: ./setup.sh -p version stable | grep -x 'stable:any:x64|stable:3.0.5:x64'
- run: ./setup.sh -t -p | grep '3.0.5'
shell: bash
- run: ./setup.sh -p version beta | grep -x 'beta:any:x64|beta:3.1.0-9.0.pre:x64'
- run: ./setup.sh -t -p | grep 'x64'
shell: bash
- run: ./setup.sh -p version master | grep -x 'master:master:x64|master:master:x64'
- run: ./setup.sh -t -p stable | grep 'stable'
shell: bash
- run: ./setup.sh -p version stable 2 | grep -x 'stable:2:x64|stable:2.10.5:x64'
- run: ./setup.sh -t -p beta | grep 'beta'
shell: bash
- run: ./setup.sh -p version beta 2 | grep -x 'beta:2:x64|beta:2.13.0-0.4.pre:x64'
- run: ./setup.sh -t -p beta | grep '3.1.0-9.0.pre'
shell: bash
- run: ./setup.sh -p version any 2 | grep -x 'any:2:x64|beta:2.13.0-0.4.pre:x64'
- run: ./setup.sh -t -p master | grep 'master'
shell: bash
- run: ./setup.sh -p version any 3 | grep -x 'any:3:x64|stable:3.0.5:x64'
- run: ./setup.sh -t -p -n 2 stable | grep '2.10.5'
shell: bash
- run: ./setup.sh -p version any 3 arm64 | grep -x 'any:3:arm64|stable:3.0.5:arm64'
- run: ./setup.sh -t -p -n 2 beta | grep '2.13.0-0.4.pre'
shell: bash
- run: ./setup.sh -p version stable any arm64 | grep -x 'stable:any:arm64|stable:3.0.5:arm64'
- run: ./setup.sh -t -p -n 2 any | grep 'beta'
shell: bash
- run: ./setup.sh -p version stable 1 | grep -x 'stable:1:x64|stable:1.22.6:x64'
- run: ./setup.sh -t -p -n 2 any | grep '2.13.0-0.4.pre'
shell: bash
- run: ./setup.sh -p version stable v1 | grep -x 'stable:v1:x64|stable:v1.12.13+hotfix.9:x64'
- run: ./setup.sh -t -p -n 3 any | grep 'stable'
shell: bash
- run: ./setup.sh -p version any 0 | grep -x 'any:0:x64|beta:v0.11.13:x64'
- run: ./setup.sh -t -p -n 3 any | grep '3.0.5'
shell: bash
- run: ./setup.sh -p version any v0 | grep -x 'any:v0:x64|beta:v0.11.13:x64'
- run: ./setup.sh -t -p -n 3 -a arm64 any | grep 'arm64'
shell: bash
test_cache_key:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- run: ./setup.sh -p cache-key | grep -x 'flutter-macos-x64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
- run: ./setup.sh -t -p -n any -a arm64 stable | grep 'stable'
shell: bash
- run: ./setup.sh -p cache-key stable | grep -x 'flutter-macos-x64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
- run: ./setup.sh -t -p -n any -a arm64 stable | grep '3.0.5'
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 -t -p -n any -a arm64 stable | grep 'arm64'
shell: bash
- run: ./setup.sh -p cache-key master | grep -x 'flutter-macos-x64-master-master-master'
- run: ./setup.sh -t -p -n 1 stable | grep '1.22.6'
shell: bash
- run: ./setup.sh -p cache-key stable 2 | grep -x 'flutter-macos-x64-stable-2.10.5-5464c5bac742001448fe4fc0597be939379f88ea'
- run: ./setup.sh -t -p -n v1 stable | grep 'v1.12.13+hotfix.9'
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 -t -p -n 0 any | grep 'beta'
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 -t -p -n 0 any | grep 'v0.11.13'
shell: bash
- run: ./setup.sh -p cache-key any 3 | grep -x 'flutter-macos-x64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
- run: ./setup.sh -t -p -n v0 any | grep 'beta'
shell: bash
- run: ./setup.sh -p cache-key any 3 arm64 | grep -x 'flutter-macos-arm64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
- run: ./setup.sh -t -p -n v0 any | grep 'v0.11.13'
shell: bash
- run: ./setup.sh -p cache-key stable any arm64 | grep -x 'flutter-macos-arm64-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
- run: ./setup.sh -t -p | grep 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -p cache-key stable 1 | grep -x 'flutter-macos-x64-stable-1.22.6-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
- run: ./setup.sh -t -p stable | grep 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
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 -t -p beta | grep 'flutter-macos-beta-3.1.0-9.0.pre-x64-f28e570c8cb12a004fae2d796d0d9cd46603bde9'
shell: bash
- run: ./setup.sh -p cache-key any 0 | grep -x 'flutter-macos-x64-beta-v0.11.13-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
- run: ./setup.sh -t -p master | grep 'flutter-macos-master-master-x64-master'
shell: bash
- run: ./setup.sh -p cache-key any v0 | grep -x 'flutter-macos-x64-beta-v0.11.13-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
- run: ./setup.sh -t -p -n 2 stable | grep 'flutter-macos-stable-2.10.5-x64-5464c5bac742001448fe4fc0597be939379f88ea'
shell: bash
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:hash:' | grep -x 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
- run: ./setup.sh -t -p -n 2 beta | grep 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
shell: bash
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:sha256:' | grep -x 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
- run: ./setup.sh -t -p -n 2 any | grep 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
shell: bash
- run: ./setup.sh -t -p -n 3 any | grep 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -t -p -n 3 -a arm64 any | grep 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -t -p -n any -a arm64 stable | grep 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -t -p -n 1 stable | grep 'flutter-macos-stable-1.22.6-x64-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
shell: bash
- run: ./setup.sh -t -p -n v1 stable | grep 'flutter-macos-stable-v1.12.13+hotfix.9-x64-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
shell: bash
- run: ./setup.sh -t -p -n 0 any | grep 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
shell: bash
- run: ./setup.sh -t -p -n v0 any | grep 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
shell: bash
- run: ./setup.sh -t -p | grep '/Users/runner/work/_temp/flutter/stable-3.0.5-x64'
shell: bash
- run: ./setup.sh -t -p stable | grep '/Users/runner/work/_temp/flutter/stable-3.0.5-x64'
shell: bash
- run: ./setup.sh -t -p beta | grep '/Users/runner/work/_temp/flutter/beta-3.1.0-9.0.pre-x64'
shell: bash
- run: ./setup.sh -t -p master | grep '/Users/runner/work/_temp/flutter/master-master-x64'
shell: bash
- run: ./setup.sh -t -p -k 'custom-:channel:-:version:-:hash:' | grep 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash
- run: ./setup.sh -t -p -k 'custom-:channel:-:version:-:sha256:' | grep 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
shell: bash
- run: ./setup.sh -t -p -c '/tmp/flutter/:channel:-:version:-:hash:' | grep '/tmp/flutter/stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
shell: bash

View File

@@ -23,7 +23,7 @@ steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable' # or: 'beta' or 'master'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- run: flutter --version
```
@@ -157,17 +157,35 @@ steps:
with:
channel: 'stable'
cache: true
cache-key: 'flutter-:os:-:arch:-:channel:-:version:-:hash:' # optional, change this to force refresh cache
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
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
- 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:`
- `:arch:`
- `:channel:`
- `:version:`
- `:arch:`
- `:hash:`
- `:sha256:`
Use outputs from `flutter-action`:
```yaml
steps:
- uses: actions/checkout@v3
- id: flutter-action
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: |
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 }}
echo VERSION=${{ steps.flutter-action.outputs.VERSION }}
echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }}
shell: bash
```

View File

@@ -16,29 +16,40 @@ inputs:
cache:
description: 'Cache the Flutter SDK'
required: false
default: false
cache-key:
description: 'Identifier for the Flutter SDK cache'
required: false
default: 'flutter-:os:-:arch:-:channel:-:version:-:hash:'
default: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
cache-path:
description: 'Flutter SDK cache path'
required: false
default: ${{ runner.tool_cache }}/flutter
default: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
architecture:
description: 'The architecture of Flutter SDK executable (x64 or arm64)'
required: false
default: ${{ runner.arch }}
default: '${{ runner.arch }}'
outputs:
CACHE-PATH:
value: '${{ steps.flutter-action.outputs.CACHE-PATH }}'
CACHE-KEY:
value: '${{ steps.flutter-action.outputs.CACHE-KEY }}'
CHANNEL:
value: '${{ steps.flutter-action.outputs.CHANNEL }}'
VERSION:
value: '${{ steps.flutter-action.outputs.VERSION }}'
ARCHITECTURE:
value: '${{ steps.flutter-action.outputs.ARCHITECTURE }}'
runs:
using: 'composite'
steps:
- if: ${{ inputs.cache == 'true' }}
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 }})"
- 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 }}
shell: bash
- if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v3
with:
path: ${{ inputs.cache-path }}
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 }}
path: ${{ steps.flutter-action.outputs.CACHE-PATH }}
key: ${{ steps.flutter-action.outputs.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

View File

@@ -12,7 +12,7 @@ fi
OS_NAME=$(echo "$RUNNER_OS" | awk '{print tolower($0)}')
MANIFEST_BASE_URL="https://storage.googleapis.com/flutter_infra_release/releases"
MANIFEST_URL="$MANIFEST_BASE_URL/releases_$OS_NAME.json"
MANIFEST_TEST_FIXTURE="test/releases_$OS_NAME.json"
MANIFEST_TEST_FIXTURE="$(dirname -- "${BASH_SOURCE[0]}")/test/releases_$OS_NAME.json"
legacy_wildcard_version() {
if [[ $1 == any ]]; then
@@ -67,7 +67,6 @@ download_archive() {
curl --connect-timeout 15 --retry 5 "$archive_url" >"$archive_local"
# Create the target folder
mkdir -p "$2"
if [[ "$archive_name" == *zip ]]; then
@@ -88,29 +87,30 @@ download_archive() {
CACHE_PATH=""
CACHE_KEY=""
PRINT_MODE=""
USE_TEST_FIXTURE=false
ARCH=""
VERSION=""
while getopts 'c:k:p:' flag; do
while getopts 'tc:k:pa:n:' flag; do
case "$flag" in
c) CACHE_PATH="$OPTARG" ;;
k) CACHE_KEY="$OPTARG" ;;
p) PRINT_MODE="$OPTARG" ;;
p) PRINT_MODE=true ;;
t) USE_TEST_FIXTURE=true ;;
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
n) VERSION="$OPTARG" ;;
?) exit 2 ;;
esac
done
ARR_CHANNEL=("${@:$OPTIND:1}")
ARR_VERSION=("${@:$OPTIND+1:1}")
ARR_ARCH=("${@:$OPTIND+2:1}")
CHANNEL="${ARR_CHANNEL[0]}"
VERSION="${ARR_VERSION[0]}"
ARCH=$(echo "${ARR_ARCH[0]}" | awk '{print tolower($0)}')
[[ -z $CHANNEL ]] && CHANNEL=stable
[[ -z $VERSION ]] && VERSION=any
[[ -z $ARCH ]] && ARCH=x64
[[ -z $CACHE_PATH ]] && CACHE_PATH=/tmp
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:arch:-:channel:-:version:-:hash:"
[[ -z $CACHE_PATH ]] && CACHE_PATH="$RUNNER_TEMP/flutter/:channel:-:version:-:arch:"
[[ -z $CACHE_KEY ]] && CACHE_KEY="flutter-:os:-:channel:-:version:-:arch:-:hash:"
RELEASE_MANIFEST=""
VERSION_MANIFEST=""
@@ -153,50 +153,56 @@ expand_key() {
echo "$expanded_key"
}
print_version() {
version_debug=$(echo "$VERSION_MANIFEST" | jq -j '.channel,":",.version,":",.dart_sdk_arch')
echo "$CHANNEL:$VERSION:$ARCH|$version_debug"
}
if [[ -n "$PRINT_MODE" ]]; then
if [[ "$CHANNEL" == master ]]; then
if [[ "$PRINT_MODE" == version ]]; then
echo "master:master:$ARCH|master:master:$ARCH"
exit 0
fi
if [[ "$PRINT_MODE" == cache-key ]]; then
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$CHANNEL\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
EXPANDED_KEY=$(expand_key "$CACHE_KEY")
echo "$EXPANDED_KEY"
exit 0
fi
exit 1
if [[ "$PRINT_MODE" == true ]]; then
if [[ "$USE_TEST_FIXTURE" == true ]]; then
RELEASE_MANIFEST=$(cat "$MANIFEST_TEST_FIXTURE")
else
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
fi
RELEASE_MANIFEST=$(cat "$MANIFEST_TEST_FIXTURE")
VERSION_MANIFEST=$(get_version_manifest)
if [[ "$CHANNEL" == master ]]; then
VERSION_MANIFEST="{\"channel\":\"$CHANNEL\",\"version\":\"$CHANNEL\",\"dart_sdk_arch\":\"$ARCH\",\"hash\":\"$CHANNEL\",\"sha256\":\"$CHANNEL\"}"
else
VERSION_MANIFEST=$(get_version_manifest)
fi
if [[ -z "$VERSION_MANIFEST" ]]; then
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
exit 1
fi
if [[ "$PRINT_MODE" == version ]]; then
print_version
version_info=$(echo "$VERSION_MANIFEST" | jq -j '.channel,":",.version,":",.dart_sdk_arch')
if [[ "$version_info" == *null* ]]; then
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
exit 1
fi
info_channel=$(echo "$version_info" | awk -F ':' '{print $1}')
info_version=$(echo "$version_info" | awk -F ':' '{print $2}')
info_architecture=$(echo "$version_info" | awk -F ':' '{print $3}')
expanded_key=$(expand_key "$CACHE_KEY")
cache_path=$(transform_path "$CACHE_PATH")
expanded_path=$(expand_key "$cache_path")
if [[ "$USE_TEST_FIXTURE" == true ]]; then
echo "CHANNEL=$info_channel"
echo "VERSION=$info_version"
echo "ARCHITECTURE=$info_architecture"
echo "CACHE-KEY=$expanded_key"
echo "CACHE-PATH=$expanded_path"
exit 0
fi
if [[ "$PRINT_MODE" == cache-key ]]; then
EXPANDED_KEY=$(expand_key "$CACHE_KEY")
{
echo "CHANNEL=$info_channel"
echo "VERSION=$info_version"
echo "ARCHITECTURE=$info_architecture"
echo "CACHE-KEY=$expanded_key"
echo "CACHE-PATH=$expanded_path"
} >> "$GITHUB_OUTPUT"
echo "$EXPANDED_KEY"
exit 0
fi
exit 1
exit 0
fi
CACHE_PATH=$(transform_path "$CACHE_PATH")
@@ -217,7 +223,6 @@ if [[ ! -x "$SDK_CACHE/bin/flutter" ]]; then
ARCHIVE_PATH=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
download_archive "$ARCHIVE_PATH" "$SDK_CACHE"
print_version
fi
fi