From c85d84fd83973f695c56031a8cab6b894368f374 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 1 Apr 2024 02:41:21 +0200 Subject: [PATCH] enable shell options: `errexit` and `nounset` --- .github/workflows/workflow.yaml | 3 ++- setup.sh | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 7eb3ae32..21871f27 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -82,7 +82,8 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v4 - - run: | + - shell: bash + run: | echo "environment:\n flutter: 3.3.10" > pubspec.yaml ./setup.sh -t -p -f pubspec.yaml | grep '3.3.10' - run: ./setup.sh -t -p | grep 'stable' diff --git a/setup.sh b/setup.sh index 60deb618..7b0d104b 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -eu check_command() { command -v "$1" >/dev/null 2>&1 @@ -111,7 +112,7 @@ if [ -n "$VERSION_FILE" ]; then fi ARR_CHANNEL=("${@:$OPTIND:1}") -CHANNEL="${ARR_CHANNEL[0]}" +CHANNEL="${ARR_CHANNEL[0]:-}" [ -z "$CHANNEL" ] && CHANNEL=stable [ -z "$VERSION" ] && VERSION=any @@ -127,7 +128,7 @@ CHANNEL="${ARR_CHANNEL[0]}" # If `PUB_CACHE` is set already, then it should continue to be used. Otherwise, satisfy it # if the action requests a custom path, or set to the Dart default values depending # on the operating system. -if [ -z "$PUB_CACHE" ]; then +if [ -z "${PUB_CACHE:-}" ]; then if [ "$PUB_CACHE_PATH" != "default" ]; then PUB_CACHE="$PUB_CACHE_PATH" elif [ "$OS_NAME" = "windows" ]; then @@ -203,7 +204,7 @@ if [ "$PRINT_ONLY" = true ]; then echo "CACHE-PATH=$CACHE_PATH" echo "PUB-CACHE-KEY=$PUB_CACHE_KEY" echo "PUB-CACHE-PATH=$PUB_CACHE" - } >>"$GITHUB_OUTPUT" + } >>"${GITHUB_OUTPUT:-/dev/null}" exit 0 fi @@ -224,10 +225,10 @@ fi { echo "FLUTTER_ROOT=$CACHE_PATH" echo "PUB_CACHE=$PUB_CACHE" -} >>"$GITHUB_ENV" +} >>"${GITHUB_ENV:-/dev/null}" { echo "$CACHE_PATH/bin" echo "$CACHE_PATH/bin/cache/dart-sdk/bin" echo "$PUB_CACHE/bin" -} >>"$GITHUB_PATH" +} >>"${GITHUB_PATH:-/dev/null}"