Skip to content

Commit c77245a

Browse files
fix: update action script (#1725)
1 parent 9b01a34 commit c77245a

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ runs:
183183
- name: Get and set token
184184
shell: bash
185185
run: |
186-
if [ "${{ inputs.use_oidc }}" == 'true' && "$CC_FORK" != 'true'];
186+
if [ "${{ inputs.use_oidc }}" == 'true' && "$CC_FORK" != 'true' ];
187187
then
188188
# {"count":1984,"value":"***"}
189189
echo -e "\033[0;32m==>\033[0m Requesting OIDC token from ${ACTION_ID_TOKEN_REQUEST_URL}"
190190
CC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://codecov.io" | cut -d\" -f6)
191191
echo "CC_TOKEN=$CC_TOKEN" >> "$GITHUB_ENV"
192192
elif [ -n "${{ env.CODECOV_TOKEN }}" ];
193193
then
194-
echo -e "\033[0;32m==>\033[0m Token from from env"
194+
echo -e "\033[0;32m==>\033[0m Token set from env"
195195
echo "CC_TOKEN=${{ env.CODECOV_TOKEN }}" >> "$GITHUB_ENV"
196196
else
197197
if [ -n "${{ inputs.token }}" ];

dist/codecov.sh

+19-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
CC_WRAPPER_VERSION="0.0.30"
2+
CC_WRAPPER_VERSION="0.0.31"
33
set +u
44
say() {
55
echo -e "$1"
@@ -52,41 +52,38 @@ then
5252
if [ -f "$CC_BINARY" ];
5353
then
5454
cc_filename=$CC_BINARY
55+
cc_command=$CC_BINARY
5556
else
5657
exit_if_error "Could not find binary file $CC_BINARY"
5758
fi
5859
else
5960
if [ -n "$CC_OS" ];
6061
then
6162
say "$g==>$x Overridden OS: $b${CC_OS}$x"
62-
export cc_os=${CC_OS}
6363
else
64-
CC_OS="linux"
64+
CC_OS="windows"
6565
family=$(uname -s | tr '[:upper:]' '[:lower:]')
66-
cc_os="windows"
67-
[[ $family == "darwin" ]] && cc_os="macos"
68-
[[ $family == "linux" ]] && cc_os="linux"
69-
[[ $cc_os == "linux" ]] && \
66+
[[ $family == "darwin" ]] && CC_OS="macos"
67+
[[ $family == "linux" ]] && CC_OS="linux"
68+
[[ $CC_OS == "linux" ]] && \
7069
osID=$(grep -e "^ID=" /etc/os-release | cut -c4-)
71-
[[ $osID == "alpine" ]] && cc_os="alpine"
72-
[[ $(arch) == "aarch64" && $family == "linux" ]] && cc_os+="-arm64"
73-
say "$g==>$x Detected $b${cc_os}$x"
74-
export cc_os=${cc_os}
70+
[[ $osID == "alpine" ]] && CC_OS="alpine"
71+
[[ $(arch) == "aarch64" && $family == "linux" ]] && CC_OS+="-arm64"
72+
say "$g==>$x Detected $b${CC_OS}$x"
7573
fi
76-
export cc_version=${CC_VERSION}
7774
cc_filename="codecov"
78-
[[ $cc_os == "windows" ]] && cc_filename+=".exe"
79-
export cc_filename=${cc_filename}
80-
[[ $cc_os == "macos" ]] && \
75+
[[ $CC_OS == "windows" ]] && cc_filename+=".exe"
76+
cc_command="./$cc_filename"
77+
[[ $CC_OS == "macos" ]] && \
8178
! command -v gpg 2>&1 >/dev/null && \
8279
HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg
8380
cc_url="https://cli.codecov.io"
8481
cc_url="$cc_url/${CC_VERSION}"
85-
cc_url="$cc_url/${cc_os}/${cc_filename}"
82+
cc_url="$cc_url/${CC_OS}/${cc_filename}"
8683
say "$g ->$x Downloading $b${cc_url}$x"
8784
curl -Os "$cc_url"
88-
say "$g==>$x Finishing downloading $b${cc_os}:${CC_VERSION}$x"
89-
version_url="https://cli.codecov.io/api/${cc_os}/${CC_VERSION}"
85+
say "$g==>$x Finishing downloading $b${CC_OS}:${CC_VERSION}$x"
86+
version_url="https://cli.codecov.io/api/${CC_OS}/${CC_VERSION}"
9087
version=$(curl -s "$version_url" -H "Accept:application/json" | jq -r '.version')
9188
say " Version: $b$version$x"
9289
say " "
@@ -101,7 +98,7 @@ CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
10198
# One-time step
10299
say "$g==>$x Verifying GPG signature integrity"
103100
sha_url="https://cli.codecov.io"
104-
sha_url="${sha_url}/${cc_version}/${cc_os}"
101+
sha_url="${sha_url}/${CC_VERSION}/${CC_OS}"
105102
sha_url="${sha_url}/${cc_filename}.SHA256SUM"
106103
say "$g ->$x Downloading $b${sha_url}$x"
107104
say "$g ->$x Downloading $b${sha_url}.sig$x"
@@ -192,7 +189,7 @@ cc_uc_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
192189
IFS=$OLDIFS
193190
unset NODE_OPTIONS
194191
# See https://github.com/codecov/uploader/issues/475
195-
chmod +x $cc_filename
192+
chmod +x $cc_command
196193
if [ -n "$CC_TOKEN_VAR" ];
197194
then
198195
token="$(eval echo \$$CC_TOKEN_VAR)"
@@ -208,8 +205,8 @@ then
208205
token_arg+=( " -t " "$token")
209206
fi
210207
say "$g==>$x Running upload-coverage"
211-
say " $b./$cc_filename $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x"
212-
if ! ./$cc_filename \
208+
say " $b$cc_command $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x"
209+
if ! $cc_command \
213210
${cc_cli_args[*]} \
214211
upload-coverage \
215212
${token_arg[*]} \

0 commit comments

Comments
 (0)