Commit c0ba3610 authored by Alexis Deruelle's avatar Alexis Deruelle Committed by Alexis Deruelle
Browse files

fix: simplify release config file parsing

Here-string syntax <<< is not compatible with ash/dash shells, for better portability:

  - get rid of the loop and here-string to keep variable in scope for update
  - use command substitution to record `yp` output
  - use more precise yq expression to extract plugin references

Explanation of the new yq expression:

  - `.plugins[]`: select elements of the `plugins` sequence (scalar or sequence)
  - `select(kind == "scalar")`: return scalar values (plugin without config)
  - `//`: else, when not a scalar, assume this is a sequence
  - `.[0]`: the first element of the sequence should be the plugin reference
parent 4e2da70b
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -601,12 +601,8 @@ stages:
      done < "${SEMREL_REQUIRED_PLUGINS_FILE}"
    fi

    # shellcheck disable=SC2046
    while IFS= read -r line || [[ -n "$line" ]]
    do
      plugin=$(echo "$line" | cut -d\" -f2)
      required_plugins="${required_plugins} $plugin"
    done <<< $(yq eval ".plugins[]" "${semrelConfigFile}" -o=json --indent 0)
    semrel_config_plugins=$(yq eval '.plugins[] | select(kind == "scalar") // .[0]' "${semrelConfigFile}" | xargs)
    required_plugins="${required_plugins} ${semrel_config_plugins}"

    # shellcheck disable=SC2086
    npm install --global "semantic-release@${SEMREL_VERSION}" ${required_plugins}