Skip to content

Commit 9d48f4e

Browse files
author
Alif Rachmawadi
committed
use named arguments for version and arch
1 parent 6c2e035 commit 9d48f4e

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

.github/workflows/workflow.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,25 @@ jobs:
5555
shell: bash
5656
- run: ./setup.sh -t -p version master | grep -x 'master:master:x64|master:master:x64'
5757
shell: bash
58-
- run: ./setup.sh -t -p version stable 2 | grep -x 'stable:2:x64|stable:2.10.5:x64'
58+
- run: ./setup.sh -t -p version -n 2 stable | grep -x 'stable:2:x64|stable:2.10.5:x64'
5959
shell: bash
60-
- run: ./setup.sh -t -p version beta 2 | grep -x 'beta:2:x64|beta:2.13.0-0.4.pre:x64'
60+
- run: ./setup.sh -t -p version -n 2 beta | grep -x 'beta:2:x64|beta:2.13.0-0.4.pre:x64'
6161
shell: bash
62-
- run: ./setup.sh -t -p version any 2 | grep -x 'any:2:x64|beta:2.13.0-0.4.pre:x64'
62+
- run: ./setup.sh -t -p version -n 2 any | grep -x 'any:2:x64|beta:2.13.0-0.4.pre:x64'
6363
shell: bash
64-
- run: ./setup.sh -t -p version any 3 | grep -x 'any:3:x64|stable:3.0.5:x64'
64+
- run: ./setup.sh -t -p version -n 3 any | grep -x 'any:3:x64|stable:3.0.5:x64'
6565
shell: bash
66-
- run: ./setup.sh -t -p version any 3 arm64 | grep -x 'any:3:arm64|stable:3.0.5:arm64'
66+
- run: ./setup.sh -t -p version -n 3 -a arm64 any | grep -x 'any:3:arm64|stable:3.0.5:arm64'
6767
shell: bash
68-
- run: ./setup.sh -t -p version stable any arm64 | grep -x 'stable:any:arm64|stable:3.0.5:arm64'
68+
- run: ./setup.sh -t -p version -n any -a arm64 stable | grep -x 'stable:any:arm64|stable:3.0.5:arm64'
6969
shell: bash
70-
- run: ./setup.sh -t -p version stable 1 | grep -x 'stable:1:x64|stable:1.22.6:x64'
70+
- run: ./setup.sh -t -p version -n 1 stable | grep -x 'stable:1:x64|stable:1.22.6:x64'
7171
shell: bash
72-
- run: ./setup.sh -t -p version stable v1 | grep -x 'stable:v1:x64|stable:v1.12.13+hotfix.9:x64'
72+
- run: ./setup.sh -t -p version -n v1 stable | grep -x 'stable:v1:x64|stable:v1.12.13+hotfix.9:x64'
7373
shell: bash
74-
- run: ./setup.sh -t -p version any 0 | grep -x 'any:0:x64|beta:v0.11.13:x64'
74+
- run: ./setup.sh -t -p version -n 0 any | grep -x 'any:0:x64|beta:v0.11.13:x64'
7575
shell: bash
76-
- run: ./setup.sh -t -p version any v0 | grep -x 'any:v0:x64|beta:v0.11.13:x64'
76+
- run: ./setup.sh -t -p version -n v0 any | grep -x 'any:v0:x64|beta:v0.11.13:x64'
7777
shell: bash
7878
test_cache_key:
7979
runs-on: macos-latest
@@ -87,29 +87,29 @@ jobs:
8787
shell: bash
8888
- run: ./setup.sh -t -p cache-key master | grep -x 'flutter-macos-master-master-x64-master'
8989
shell: bash
90-
- run: ./setup.sh -t -p cache-key stable 2 | grep -x 'flutter-macos-stable-2.10.5-x64-5464c5bac742001448fe4fc0597be939379f88ea'
90+
- run: ./setup.sh -t -p cache-key -n 2 stable | grep -x 'flutter-macos-stable-2.10.5-x64-5464c5bac742001448fe4fc0597be939379f88ea'
9191
shell: bash
92-
- run: ./setup.sh -t -p cache-key beta 2 | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
92+
- run: ./setup.sh -t -p cache-key -n 2 beta | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
9393
shell: bash
94-
- run: ./setup.sh -t -p cache-key any 2 | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
94+
- run: ./setup.sh -t -p cache-key -n 2 any | grep -x 'flutter-macos-beta-2.13.0-0.4.pre-x64-25caf1461b8f643092a9f6f5b224453b5c057d10'
9595
shell: bash
96-
- run: ./setup.sh -t -p cache-key any 3 | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
96+
- run: ./setup.sh -t -p cache-key -n 3 any | grep -x 'flutter-macos-stable-3.0.5-x64-f1875d570e39de09040c8f79aa13cc56baab8db1'
9797
shell: bash
98-
- run: ./setup.sh -t -p cache-key any 3 arm64 | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
98+
- run: ./setup.sh -t -p cache-key -n 3 -a arm64 any | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
9999
shell: bash
100-
- run: ./setup.sh -t -p cache-key stable any arm64 | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
100+
- run: ./setup.sh -t -p cache-key -n any -a arm64 stable | grep -x 'flutter-macos-stable-3.0.5-arm64-f1875d570e39de09040c8f79aa13cc56baab8db1'
101101
shell: bash
102-
- run: ./setup.sh -t -p cache-key stable 1 | grep -x 'flutter-macos-stable-1.22.6-x64-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
102+
- run: ./setup.sh -t -p cache-key -n 1 stable | grep -x 'flutter-macos-stable-1.22.6-x64-9b2d32b605630f28625709ebd9d78ab3016b2bf6'
103103
shell: bash
104-
- run: ./setup.sh -t -p cache-key stable v1 | grep -x 'flutter-macos-stable-v1.12.13+hotfix.9-x64-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
104+
- run: ./setup.sh -t -p cache-key -n v1 stable | grep -x 'flutter-macos-stable-v1.12.13+hotfix.9-x64-f139b11009aeb8ed2a3a3aa8b0066e482709dde3'
105105
shell: bash
106-
- run: ./setup.sh -t -p cache-key any 0 | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
106+
- run: ./setup.sh -t -p cache-key -n 0 any | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
107107
shell: bash
108-
- run: ./setup.sh -p cache-key any v0 | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
108+
- run: ./setup.sh -t -p cache-key -n v0 any | grep -x 'flutter-macos-beta-v0.11.13-x64-58c8489fcdb4e4ef6c010117584c9b23d15221aa'
109109
shell: bash
110-
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:hash:' | grep -x 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
110+
- run: ./setup.sh -t -p cache-key -k 'custom-:channel:-:version:-:hash:' | grep -x 'custom-stable-3.0.5-f1875d570e39de09040c8f79aa13cc56baab8db1'
111111
shell: bash
112-
- run: ./setup.sh -p cache-key -k 'custom-:channel:-:version:-:sha256:' | grep -x 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
112+
- run: ./setup.sh -t -p cache-key -k 'custom-:channel:-:version:-:sha256:' | grep -x 'custom-stable-3.0.5-e79a04dcfd1b583e5831433fc200800ba0d1e9fe4567cb661479bd2542d4c685'
113113
shell: bash
114114
test_cache_path:
115115
runs-on: ubuntu-latest

action.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ inputs:
1616
cache:
1717
description: 'Cache the Flutter SDK'
1818
required: false
19+
default: false
1920
cache-key:
2021
description: 'Identifier for the Flutter SDK cache'
2122
required: false
@@ -32,16 +33,16 @@ runs:
3233
using: 'composite'
3334
steps:
3435
- id: flutter-action-cache-path-builder
35-
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 }})"
36+
run: echo "::set-output name=cache-path::$($GITHUB_ACTION_PATH/setup.sh -p cache-path -c '${{ inputs.cache-path }}' -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }})"
3637
shell: bash
3738
- if: ${{ inputs.cache == 'true' }}
3839
id: flutter-action-cache-key-builder
39-
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 }})"
40+
run: echo "::set-output name=cache-key::$($GITHUB_ACTION_PATH/setup.sh -p cache-key -k ${{ inputs.cache-key }} -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }})"
4041
shell: bash
4142
- if: ${{ inputs.cache == 'true' }}
4243
uses: actions/cache@v3
4344
with:
4445
path: ${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}
4546
key: ${{ steps.flutter-action-cache-key-builder.outputs.cache-key }}
46-
- run: $GITHUB_ACTION_PATH/setup.sh -c '${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}' ${{ inputs.channel }} ${{ inputs.flutter-version }} ${{ inputs.architecture }}
47+
- run: $GITHUB_ACTION_PATH/setup.sh -c '${{ steps.flutter-action-cache-path-builder.outputs.cache-path }}' -n '${{ inputs.flutter-version }}' -a '${{ inputs.architecture }}' ${{ inputs.channel }}
4748
shell: bash

setup.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,23 @@ CACHE_PATH=""
8989
CACHE_KEY=""
9090
PRINT_MODE=""
9191
USE_TEST_FIXTURE=false
92+
ARCH=""
93+
VERSION=""
9294

93-
while getopts 'tc:k:p:' flag; do
95+
while getopts 'tc:k:p:a:n:' flag; do
9496
case "$flag" in
9597
c) CACHE_PATH="$OPTARG" ;;
9698
k) CACHE_KEY="$OPTARG" ;;
9799
p) PRINT_MODE="$OPTARG" ;;
98100
t) USE_TEST_FIXTURE=true ;;
101+
a) ARCH="$(echo "$OPTARG" | awk '{print tolower($0)}')" ;;
102+
n) VERSION="$OPTARG" ;;
99103
?) exit 2 ;;
100104
esac
101105
done
102106

103107
ARR_CHANNEL=("${@:$OPTIND:1}")
104-
ARR_VERSION=("${@:$OPTIND+1:1}")
105-
ARR_ARCH=("${@:$OPTIND+2:1}")
106-
107108
CHANNEL="${ARR_CHANNEL[0]}"
108-
VERSION="${ARR_VERSION[0]}"
109-
ARCH=$(echo "${ARR_ARCH[0]}" | awk '{print tolower($0)}')
110109

111110
[[ -z $CHANNEL ]] && CHANNEL=stable
112111
[[ -z $VERSION ]] && VERSION=any

0 commit comments

Comments
 (0)