diff --git a/get-tool-version.sh b/get-tool-version.sh index 8e566b8..60486a1 100755 --- a/get-tool-version.sh +++ b/get-tool-version.sh @@ -1,6 +1,9 @@ #! /bin/bash # Resolve the tool release version from go.mod # without requiring go to be installed. +# +# Notice that when executed on github runner, this folder +# is not a git directory. So usual git commands are not available. tool=${1?-Tool name is a required argument} @@ -20,5 +23,5 @@ case "${tool}" in ;; esac -root=$(git rev-parse --show-toplevel) +root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" grep "${GO_IMPORT_PATH}" "${root}"/go.mod|xargs|cut -d' ' -f2 diff --git a/install/go-ctrf-json-reporter/action.yml b/install/go-ctrf-json-reporter/action.yml index 6703c48..f9bd415 100644 --- a/install/go-ctrf-json-reporter/action.yml +++ b/install/go-ctrf-json-reporter/action.yml @@ -35,7 +35,7 @@ runs: VERSION_RESOLVER: '${{ github.action_path }}/../../get-tool-version.sh' run: | if [[ '${{ !inputs.version }}' == 'true' || '${{ inputs.version }}' == 'auto' ]] ; then - VERSION=$("${VERSION_RESOLVER}" "${TOOL}") + VERSION=$("${VERSION_RESOLVER}" "${TOOL}") else VERSION='${{ inputs.version }}' fi diff --git a/install/go-junit-report/action.yml b/install/go-junit-report/action.yml index 72e5ee6..6d1f110 100644 --- a/install/go-junit-report/action.yml +++ b/install/go-junit-report/action.yml @@ -74,13 +74,23 @@ runs: set -x # e.g. go-junit-report-v2.1.0-darwin-arm64.tar.gz + ARCHIVE_FORMAT=".tar.gz" + if [[ '${{ runner.os }}' == 'Windows' ]] ; then + ARCHIVE_FORMAT=".zip" + fi + gh release download "${VERSION}" \ --repo "${REPO}" \ - --pattern "*-${OS}-${ARCH}.tar.gz" \ - --output "${DOWNLOAD_DIR}"/artifact.tgz + --pattern "*-${OS}-${ARCH}${ARCHIVE_FORMAT}" \ + --output "${DOWNLOAD_DIR}"/"artifact${ARCHIVE_FORMAT}" # should check checksum etc - (cd "${DOWNLOAD_DIR}" && tar xf artifact.tgz "${TOOL}" && rm -f artifact.tgz) + if [[ "${OS}" != 'windows' ]] ; then + (cd "${DOWNLOAD_DIR}" && tar xf "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") + else + TOOL="${TOOL}.exe" + (cd "${DOWNLOAD_DIR}" && unzip "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") + fi mkdir -p "${TARGET_DIR}" mv "${DOWNLOAD_DIR}"/"${TOOL}" "${TARGET_DIR}" diff --git a/install/gotestsum/action.yml b/install/gotestsum/action.yml index ca5df8c..2ad53b3 100644 --- a/install/gotestsum/action.yml +++ b/install/gotestsum/action.yml @@ -72,15 +72,18 @@ runs: mkdir -p "${DOWNLOAD_DIR}" - set -x + ARCHIVE_FORMAT=".tar.gz" # e.g. gotestsum_1.13.0_linux_amd64.tar.gz gh release download "${VERSION}" \ --repo "${REPO}" \ - --pattern "*_${OS}_${ARCH}.tar.gz" \ - --output "${DOWNLOAD_DIR}"/artifact.tgz + --pattern "*_${OS}_${ARCH}${ARCHIVE_FORMAT}" \ + --output "${DOWNLOAD_DIR}"/"artifact${ARCHIVE_FORMAT}" # should check checksum etc - (cd "${DOWNLOAD_DIR}" && tar xf artifact.tgz "${TOOL}" && rm -f artifact.tgz) + if [[ "${OS}" == 'windows' ]] ; then + TOOL="${TOOL}.exe" + fi + (cd "${DOWNLOAD_DIR}" && tar xf "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") mkdir -p "${TARGET_DIR}" mv "${DOWNLOAD_DIR}"/"${TOOL}" "${TARGET_DIR}"