From 375a409708d0bd4c7bbc83bbe3bf9f878d5f1c8a Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 5 Dec 2024 21:51:44 -0300 Subject: [PATCH 1/2] fix: update binary to pull relative --- dist/codecov.sh | 39 ++++++++++++++++++--------------------- scripts/download.sh | 32 ++++++++++++++------------------ scripts/upload.sh | 6 +++--- scripts/validate.sh | 2 +- 4 files changed, 36 insertions(+), 43 deletions(-) diff --git a/dist/codecov.sh b/dist/codecov.sh index 7adca6c..939880e 100755 --- a/dist/codecov.sh +++ b/dist/codecov.sh @@ -52,6 +52,7 @@ then if [ -f "$CC_BINARY" ]; then cc_filename=$CC_BINARY + cc_command=$CC_BINARY else exit_if_error "Could not find binary file $CC_BINARY" fi @@ -59,34 +60,30 @@ else if [ -n "$CC_OS" ]; then say "$g==>$x Overridden OS: $b${CC_OS}$x" - export cc_os=${CC_OS} else - CC_OS="linux" + CC_OS="windows" family=$(uname -s | tr '[:upper:]' '[:lower:]') - cc_os="windows" - [[ $family == "darwin" ]] && cc_os="macos" - [[ $family == "linux" ]] && cc_os="linux" - [[ $cc_os == "linux" ]] && \ + [[ $family == "darwin" ]] && CC_OS="macos" + [[ $family == "linux" ]] && CC_OS="linux" + [[ $CC_OS == "linux" ]] && \ osID=$(grep -e "^ID=" /etc/os-release | cut -c4-) - [[ $osID == "alpine" ]] && cc_os="alpine" - [[ $(arch) == "aarch64" && $family == "linux" ]] && cc_os+="-arm64" - say "$g==>$x Detected $b${cc_os}$x" - export cc_os=${cc_os} + [[ $osID == "alpine" ]] && CC_OS="alpine" + [[ $(arch) == "aarch64" && $family == "linux" ]] && CC_OS+="-arm64" + say "$g==>$x Detected $b${CC_OS}$x" fi - export cc_version=${CC_VERSION} cc_filename="codecov" - [[ $cc_os == "windows" ]] && cc_filename+=".exe" - export cc_filename=${cc_filename} - [[ $cc_os == "macos" ]] && \ + cc_command="./$cc_filename" + [[ $CC_OS == "windows" ]] && cc_filename+=".exe" + [[ $CC_OS == "macos" ]] && \ ! command -v gpg 2>&1 >/dev/null && \ HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg cc_url="https://cli.codecov.io" cc_url="$cc_url/${CC_VERSION}" - cc_url="$cc_url/${cc_os}/${cc_filename}" + cc_url="$cc_url/${CC_OS}/${cc_filename}" say "$g ->$x Downloading $b${cc_url}$x" curl -Os "$cc_url" - say "$g==>$x Finishing downloading $b${cc_os}:${CC_VERSION}$x" - version_url="https://cli.codecov.io/api/${cc_os}/${CC_VERSION}" + say "$g==>$x Finishing downloading $b${CC_OS}:${CC_VERSION}$x" + version_url="https://cli.codecov.io/api/${CC_OS}/${CC_VERSION}" version=$(curl -s "$version_url" -H "Accept:application/json" | jq -r '.version') say " Version: $b$version$x" say " " @@ -101,7 +98,7 @@ CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc) # One-time step say "$g==>$x Verifying GPG signature integrity" sha_url="https://cli.codecov.io" - sha_url="${sha_url}/${cc_version}/${cc_os}" + sha_url="${sha_url}/${CC_VERSION}/${CC_OS}" sha_url="${sha_url}/${cc_filename}.SHA256SUM" say "$g ->$x Downloading $b${sha_url}$x" say "$g ->$x Downloading $b${sha_url}.sig$x" @@ -192,7 +189,7 @@ cc_uc_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT)) IFS=$OLDIFS unset NODE_OPTIONS # See https://github.com/codecov/uploader/issues/475 -chmod +x $cc_filename +chmod +x $cc_command if [ -n "$CC_TOKEN_VAR" ]; then token="$(eval echo \$$CC_TOKEN_VAR)" @@ -208,8 +205,8 @@ then token_arg+=( " -t " "$token") fi say "$g==>$x Running upload-coverage" -say " $b./$cc_filename $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x" -if ! ./$cc_filename \ +say " $b$cc_command $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x" +if ! $cc_command \ ${cc_cli_args[*]} \ upload-coverage \ ${token_arg[*]} \ diff --git a/scripts/download.sh b/scripts/download.sh index 0b26ef1..0c18f4a 100755 --- a/scripts/download.sh +++ b/scripts/download.sh @@ -5,6 +5,7 @@ then if [ -f "$CODECOV_BINARY" ]; then codecov_filename=$CODECOV_BINARY + codecov_command=$CODECOV_BINARY else exit_if_error "Could not find binary file $CODECOV_BINARY" fi @@ -12,37 +13,32 @@ else if [ -n "$CODECOV_OS" ]; then say "$g==>$x Overridden OS: $b${CODECOV_OS}$x" - export codecov_os=${CODECOV_OS} else - CODECOV_OS="linux" + CODECOV_OS="windows" family=$(uname -s | tr '[:upper:]' '[:lower:]') - codecov_os="windows" - [[ $family == "darwin" ]] && codecov_os="macos" - - [[ $family == "linux" ]] && codecov_os="linux" - [[ $codecov_os == "linux" ]] && \ + [[ $family == "darwin" ]] && CODECOV_OS="macos" + [[ $family == "linux" ]] && CODECOV_OS="linux" + [[ $CODECOV_OS == "linux" ]] && \ osID=$(grep -e "^ID=" /etc/os-release | cut -c4-) - [[ $osID == "alpine" ]] && codecov_os="alpine" - [[ $(arch) == "aarch64" && $family == "linux" ]] && codecov_os+="-arm64" - say "$g==>$x Detected $b${codecov_os}$x" - export codecov_os=${codecov_os} + [[ $osID == "alpine" ]] && CODECOV_OS="alpine" + [[ $(arch) == "aarch64" && $family == "linux" ]] && CODECOV_OS+="-arm64" + say "$g==>$x Detected $b${CODECOV_OS}$x" fi - export codecov_version=${CODECOV_VERSION} codecov_filename="codecov" - [[ $codecov_os == "windows" ]] && codecov_filename+=".exe" - export codecov_filename=${codecov_filename} - [[ $codecov_os == "macos" ]] && \ + codecov_command="./$codecov_filename" + [[ $CODECOV_OS == "windows" ]] && codecov_filename+=".exe" + [[ $CODECOV_OS == "macos" ]] && \ ! command -v gpg 2>&1 >/dev/null && \ HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg codecov_url="https://cli.codecov.io" codecov_url="$codecov_url/${CODECOV_VERSION}" - codecov_url="$codecov_url/${codecov_os}/${codecov_filename}" + codecov_url="$codecov_url/${CODECOV_OS}/${codecov_filename}" say "$g ->$x Downloading $b${codecov_url}$x" curl -Os "$codecov_url" - say "$g==>$x Finishing downloading $b${codecov_os}:${CODECOV_VERSION}$x" + say "$g==>$x Finishing downloading $b${CODECOV_OS}:${CODECOV_VERSION}$x" - version_url="https://cli.codecov.io/api/${codecov_os}/${CODECOV_VERSION}" + version_url="https://cli.codecov.io/api/${CODECOV_OS}/${CODECOV_VERSION}" version=$(curl -s "$version_url" -H "Accept:application/json" | jq -r '.version') say " Version: $b$version$x" say " " diff --git a/scripts/upload.sh b/scripts/upload.sh index 95a8f88..e86de8f 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -3,7 +3,7 @@ unset NODE_OPTIONS # See https://github.com/codecov/uploader/issues/475 -chmod +x $codecov_filename +chmod +x $codecov_command if [ -n "$CODECOV_TOKEN_VAR" ]; then @@ -22,8 +22,8 @@ then fi say "$g==>$x Running upload-coverage" -say " $b./$codecov_filename $(echo "${codecov_cli_args[@]}") upload-coverage$token_str $(echo "${codecov_uc_args[@]}")$x" -if ! ./$codecov_filename \ +say " $b$codecov_command $(echo "${codecov_cli_args[@]}") upload-coverage$token_str $(echo "${codecov_uc_args[@]}")$x" +if ! $codecov_command \ ${codecov_cli_args[*]} \ upload-coverage \ ${token_arg[*]} \ diff --git a/scripts/validate.sh b/scripts/validate.sh index e8d5146..e8d2820 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -10,7 +10,7 @@ else # One-time step say "$g==>$x Verifying GPG signature integrity" sha_url="https://cli.codecov.io" - sha_url="${sha_url}/${codecov_version}/${codecov_os}" + sha_url="${sha_url}/${CODECOV_VERSION}/${CODECOV_OS}" sha_url="${sha_url}/${codecov_filename}.SHA256SUM" say "$g ->$x Downloading $b${sha_url}$x" say "$g ->$x Downloading $b${sha_url}.sig$x" From ef8e8e2b26f75758d045f6437ff4ca56b614b0d7 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 16 Dec 2024 11:35:18 -0300 Subject: [PATCH 2/2] fix: set command post windows --- dist/codecov.sh | 2 +- scripts/download.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/codecov.sh b/dist/codecov.sh index 939880e..a258247 100755 --- a/dist/codecov.sh +++ b/dist/codecov.sh @@ -72,8 +72,8 @@ else say "$g==>$x Detected $b${CC_OS}$x" fi cc_filename="codecov" - cc_command="./$cc_filename" [[ $CC_OS == "windows" ]] && cc_filename+=".exe" + cc_command="./$cc_filename" [[ $CC_OS == "macos" ]] && \ ! command -v gpg 2>&1 >/dev/null && \ HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg diff --git a/scripts/download.sh b/scripts/download.sh index 0c18f4a..0209572 100755 --- a/scripts/download.sh +++ b/scripts/download.sh @@ -26,8 +26,8 @@ else fi codecov_filename="codecov" - codecov_command="./$codecov_filename" [[ $CODECOV_OS == "windows" ]] && codecov_filename+=".exe" + codecov_command="./$codecov_filename" [[ $CODECOV_OS == "macos" ]] && \ ! command -v gpg 2>&1 >/dev/null && \ HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg