mirror of
https://github.com/subosito/flutter-action.git
synced 2024-08-16 10:19:50 +02:00
shellcheck linter
This commit is contained in:
parent
54864698df
commit
becfb71246
2 changed files with 151 additions and 145 deletions
10
.github/workflows/workflow.yml
vendored
10
.github/workflows/workflow.yml
vendored
|
@ -4,9 +4,15 @@ on:
|
|||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- setup.sh
|
||||
- action.yml
|
||||
jobs:
|
||||
lint_shellcheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ludeeus/action-shellcheck@master
|
||||
test_channel:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
|
|
72
setup.sh
72
setup.sh
|
@ -2,8 +2,8 @@
|
|||
|
||||
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_PATH="test/releases_${OS_NAME}.json"
|
||||
MANIFEST_URL="$MANIFEST_BASE_URL/releases_$OS_NAME.json"
|
||||
MANIFEST_TEST_PATH="test/releases_$OS_NAME.json"
|
||||
RELEASE_MANIFEST=""
|
||||
VERSION_MANIFEST=null
|
||||
|
||||
|
@ -42,18 +42,18 @@ get_version() {
|
|||
if [[ $1 == any && $2 == any ]]; then
|
||||
latest_version
|
||||
elif [[ $2 == any ]]; then
|
||||
latest_channel_version $1
|
||||
latest_channel_version "$1"
|
||||
else
|
||||
wildcard_version $1 $2
|
||||
wildcard_version "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
get_version_manifest() {
|
||||
version_manifest=$(echo $RELEASE_MANIFEST | get_version $1 $(normalize_version $2))
|
||||
version_manifest=$(echo "$RELEASE_MANIFEST" | get_version "$1" "$(normalize_version "$2")")
|
||||
|
||||
if [[ $version_manifest == null ]]; then
|
||||
# fallback through legacy version format
|
||||
version_manifest=$(echo "$RELEASE_MANIFEST" | wildcard_version $1 "v$(normalize_version $2)")
|
||||
version_manifest=$(echo "$RELEASE_MANIFEST" | wildcard_version "$1" "v$(normalize_version "$2")")
|
||||
fi
|
||||
|
||||
version_arch=$(echo "$version_manifest" | jq -r '.dart_sdk_arch')
|
||||
|
@ -67,10 +67,10 @@ get_version_manifest() {
|
|||
|
||||
download_archive() {
|
||||
archive_url="$MANIFEST_BASE_URL/$1"
|
||||
archive_name=$(basename $1)
|
||||
archive_name=$(basename "$1")
|
||||
archive_local="$RUNNER_TEMP/$archive_name"
|
||||
|
||||
curl --connect-timeout 15 --retry 5 $archive_url >$archive_local
|
||||
curl --connect-timeout 15 --retry 5 "$archive_url" >"$archive_local"
|
||||
|
||||
# Create the target folder
|
||||
mkdir -p "$2"
|
||||
|
@ -82,12 +82,12 @@ download_archive() {
|
|||
# This is a little bit of a hack since the "mv --no-target-directory"
|
||||
# linux option is not available here
|
||||
rm -r "$2"
|
||||
mv ${RUNNER_TEMP}/flutter "$2"
|
||||
mv "$RUNNER_TEMP"/flutter "$2"
|
||||
else
|
||||
tar xf "$archive_local" -C "$2" --strip-components=1
|
||||
fi
|
||||
|
||||
rm $archive_local
|
||||
rm "$archive_local"
|
||||
}
|
||||
|
||||
transform_path() {
|
||||
|
@ -133,7 +133,7 @@ CACHE_KEY=""
|
|||
PRINT_MODE=""
|
||||
|
||||
while getopts 'c:k:p:' flag; do
|
||||
case "${flag}" in
|
||||
case "$flag" in
|
||||
c) CACHE_PATH="$OPTARG" ;;
|
||||
k) CACHE_KEY="$OPTARG" ;;
|
||||
p) PRINT_MODE="$OPTARG" ;;
|
||||
|
@ -141,9 +141,13 @@ while getopts 'c:k:p:' flag; do
|
|||
esac
|
||||
done
|
||||
|
||||
CHANNEL="${@:$OPTIND:1}"
|
||||
VERSION="${@:$OPTIND+1:1}"
|
||||
ARCH=$(echo "${@:$OPTIND+2:1}" | awk '{print tolower($0)}')
|
||||
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)}')
|
||||
|
||||
# default values
|
||||
[[ -z $CHANNEL ]] && CHANNEL=stable
|
||||
|
@ -160,17 +164,9 @@ if [[ -n "$PRINT_MODE" ]]; then
|
|||
fi
|
||||
|
||||
if [[ "$PRINT_MODE" == cache-key ]]; then
|
||||
# MASTER_HASH=$(git ls-remote https://github.com/flutter/flutter.git | head -n 1 | awk '{print $1}')
|
||||
|
||||
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"
|
||||
exit 0
|
||||
fi
|
||||
|
@ -179,10 +175,10 @@ if [[ -n "$PRINT_MODE" ]]; then
|
|||
fi
|
||||
|
||||
RELEASE_MANIFEST=$(cat "$MANIFEST_TEST_PATH")
|
||||
VERSION_MANIFEST=$(get_version_manifest $CHANNEL $VERSION)
|
||||
VERSION_MANIFEST=$(get_version_manifest "$CHANNEL" "$VERSION")
|
||||
|
||||
if [[ $VERSION_MANIFEST == null ]]; then
|
||||
not_found_error $CHANNEL $VERSION $ARCH
|
||||
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -205,26 +201,30 @@ fi
|
|||
|
||||
CACHE_PATH=$(transform_path "$CACHE_PATH")
|
||||
SDK_CACHE=$(expand_key "$CACHE_PATH")
|
||||
PUB_CACHE=$(expand_key "${SDK_CACHE}/.pub-cache")
|
||||
PUB_CACHE=$(expand_key "$SDK_CACHE/.pub-cache")
|
||||
|
||||
if [[ ! -x "${SDK_CACHE}/bin/flutter" ]]; then
|
||||
if [[ ! -x "$SDK_CACHE/bin/flutter" ]]; then
|
||||
if [[ $CHANNEL == master ]]; then
|
||||
git clone -b master https://github.com/flutter/flutter.git "$SDK_CACHE"
|
||||
else
|
||||
RELEASE_MANIFEST=$(curl --silent --connect-timeout 15 --retry 5 "$MANIFEST_URL")
|
||||
VERSION_MANIFEST=$(get_version_manifest $CHANNEL $VERSION)
|
||||
VERSION_MANIFEST=$(get_version_manifest "$CHANNEL" "$VERSION")
|
||||
if [[ $VERSION_MANIFEST == null ]]; then
|
||||
not_found_error $CHANNEL $VERSION $ARCH
|
||||
not_found_error "$CHANNEL" "$VERSION" "$ARCH"
|
||||
exit 1
|
||||
fi
|
||||
ARCHIVE_PATH=$(echo $VERSION_MANIFEST | jq -r '.archive')
|
||||
ARCHIVE_PATH=$(echo "$VERSION_MANIFEST" | jq -r '.archive')
|
||||
download_archive "$ARCHIVE_PATH" "$SDK_CACHE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "FLUTTER_ROOT=${SDK_CACHE}" >>$GITHUB_ENV
|
||||
echo "PUB_CACHE=${PUB_CACHE}" >>$GITHUB_ENV
|
||||
{
|
||||
echo "FLUTTER_ROOT=$SDK_CACHE"
|
||||
echo "PUB_CACHE=$PUB_CACHE"
|
||||
} >>"$GITHUB_ENV"
|
||||
|
||||
echo "${SDK_CACHE}/bin" >>$GITHUB_PATH
|
||||
echo "${SDK_CACHE}/bin/cache/dart-sdk/bin" >>$GITHUB_PATH
|
||||
echo "${PUB_CACHE}/bin" >>$GITHUB_PATH
|
||||
{
|
||||
echo "$SDK_CACHE/bin"
|
||||
echo "$SDK_CACHE/bin/cache/dart-sdk/bin"
|
||||
echo "$PUB_CACHE/bin"
|
||||
} >>"$GITHUB_PATH"
|
||||
|
|
Loading…
Reference in a new issue