fix: update action script (#1725)

This commit is contained in:
Tom Hu
2024-12-18 14:57:16 -03:00
committed by GitHub
parent 9b01a34191
commit c77245a013
2 changed files with 21 additions and 24 deletions

View File

@@ -183,7 +183,7 @@ runs:
- name: Get and set token - name: Get and set token
shell: bash shell: bash
run: | run: |
if [ "${{ inputs.use_oidc }}" == 'true' && "$CC_FORK" != 'true']; if [ "${{ inputs.use_oidc }}" == 'true' && "$CC_FORK" != 'true' ];
then then
# {"count":1984,"value":"***"} # {"count":1984,"value":"***"}
echo -e "\033[0;32m==>\033[0m Requesting OIDC token from ${ACTION_ID_TOKEN_REQUEST_URL}" echo -e "\033[0;32m==>\033[0m Requesting OIDC token from ${ACTION_ID_TOKEN_REQUEST_URL}"
@@ -191,7 +191,7 @@ runs:
echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV" echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
elif [ -n "${{ env.CODECOV_TOKEN }}" ]; elif [ -n "${{ env.CODECOV_TOKEN }}" ];
then then
echo -e "\033[0;32m==>\033[0m Token from from env" echo -e "\033[0;32m==>\033[0m Token set from env"
echo "CC_TOKEN=${{ env.CODECOV_TOKEN }}" >> "$GITHUB_ENV" echo "CC_TOKEN=${{ env.CODECOV_TOKEN }}" >> "$GITHUB_ENV"
else else
if [ -n "${{ inputs.token }}" ]; if [ -n "${{ inputs.token }}" ];

41
dist/codecov.sh vendored
View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CC_WRAPPER_VERSION="0.0.30" CC_WRAPPER_VERSION="0.0.31"
set +u set +u
say() { say() {
echo -e "$1" echo -e "$1"
@@ -52,6 +52,7 @@ then
if [ -f "$CC_BINARY" ]; if [ -f "$CC_BINARY" ];
then then
cc_filename=$CC_BINARY cc_filename=$CC_BINARY
cc_command=$CC_BINARY
else else
exit_if_error "Could not find binary file $CC_BINARY" exit_if_error "Could not find binary file $CC_BINARY"
fi fi
@@ -59,34 +60,30 @@ else
if [ -n "$CC_OS" ]; if [ -n "$CC_OS" ];
then then
say "$g==>$x Overridden OS: $b${CC_OS}$x" say "$g==>$x Overridden OS: $b${CC_OS}$x"
export cc_os=${CC_OS}
else else
CC_OS="linux" CC_OS="windows"
family=$(uname -s | tr '[:upper:]' '[:lower:]') family=$(uname -s | tr '[:upper:]' '[:lower:]')
cc_os="windows" [[ $family == "darwin" ]] && CC_OS="macos"
[[ $family == "darwin" ]] && cc_os="macos" [[ $family == "linux" ]] && CC_OS="linux"
[[ $family == "linux" ]] && cc_os="linux" [[ $CC_OS == "linux" ]] && \
[[ $cc_os == "linux" ]] && \
osID=$(grep -e "^ID=" /etc/os-release | cut -c4-) osID=$(grep -e "^ID=" /etc/os-release | cut -c4-)
[[ $osID == "alpine" ]] && cc_os="alpine" [[ $osID == "alpine" ]] && CC_OS="alpine"
[[ $(arch) == "aarch64" && $family == "linux" ]] && cc_os+="-arm64" [[ $(arch) == "aarch64" && $family == "linux" ]] && CC_OS+="-arm64"
say "$g==>$x Detected $b${cc_os}$x" say "$g==>$x Detected $b${CC_OS}$x"
export cc_os=${cc_os}
fi fi
export cc_version=${CC_VERSION}
cc_filename="codecov" cc_filename="codecov"
[[ $cc_os == "windows" ]] && cc_filename+=".exe" [[ $CC_OS == "windows" ]] && cc_filename+=".exe"
export cc_filename=${cc_filename} cc_command="./$cc_filename"
[[ $cc_os == "macos" ]] && \ [[ $CC_OS == "macos" ]] && \
! command -v gpg 2>&1 >/dev/null && \ ! command -v gpg 2>&1 >/dev/null && \
HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg
cc_url="https://cli.codecov.io" cc_url="https://cli.codecov.io"
cc_url="$cc_url/${CC_VERSION}" 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" say "$g ->$x Downloading $b${cc_url}$x"
curl -Os "$cc_url" curl -Os "$cc_url"
say "$g==>$x Finishing downloading $b${cc_os}:${CC_VERSION}$x" say "$g==>$x Finishing downloading $b${CC_OS}:${CC_VERSION}$x"
version_url="https://cli.codecov.io/api/${cc_os}/${CC_VERSION}" version_url="https://cli.codecov.io/api/${CC_OS}/${CC_VERSION}"
version=$(curl -s "$version_url" -H "Accept:application/json" | jq -r '.version') version=$(curl -s "$version_url" -H "Accept:application/json" | jq -r '.version')
say " Version: $b$version$x" say " Version: $b$version$x"
say " " say " "
@@ -101,7 +98,7 @@ CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
# One-time step # One-time step
say "$g==>$x Verifying GPG signature integrity" say "$g==>$x Verifying GPG signature integrity"
sha_url="https://cli.codecov.io" 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" sha_url="${sha_url}/${cc_filename}.SHA256SUM"
say "$g ->$x Downloading $b${sha_url}$x" say "$g ->$x Downloading $b${sha_url}$x"
say "$g ->$x Downloading $b${sha_url}.sig$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 IFS=$OLDIFS
unset NODE_OPTIONS unset NODE_OPTIONS
# See https://github.com/codecov/uploader/issues/475 # See https://github.com/codecov/uploader/issues/475
chmod +x $cc_filename chmod +x $cc_command
if [ -n "$CC_TOKEN_VAR" ]; if [ -n "$CC_TOKEN_VAR" ];
then then
token="$(eval echo \$$CC_TOKEN_VAR)" token="$(eval echo \$$CC_TOKEN_VAR)"
@@ -208,8 +205,8 @@ then
token_arg+=( " -t " "$token") token_arg+=( " -t " "$token")
fi fi
say "$g==>$x Running upload-coverage" say "$g==>$x Running upload-coverage"
say " $b./$cc_filename $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x" say " $b$cc_command $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x"
if ! ./$cc_filename \ if ! $cc_command \
${cc_cli_args[*]} \ ${cc_cli_args[*]} \
upload-coverage \ upload-coverage \
${token_arg[*]} \ ${token_arg[*]} \