-
Notifications
You must be signed in to change notification settings - Fork 52
/
upload-to-codecov.sh
executable file
·60 lines (47 loc) · 1.44 KB
/
upload-to-codecov.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Download the codecov uploader, check for integrity, and run
# (https://docs.codecov.com/docs/codecov-uploader#integrity-checking-the-uploader)
set -eo pipefail
defaultCodecovVersion="v0.1.20"
exitWithUsageInfo() {
echo "
Usage: ${BASH_SOURCE} -t <upload token> [-v <codecov version, defaults to ${defaultCodecovVersion}>]
"
exit 1
}
function importPublicKey() {
curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
}
function downloadCodecov() {
curl -Os "https://uploader.codecov.io/${codecovVersion}/linux/codecov"
curl -Os "https://uploader.codecov.io/${codecovVersion}/linux/codecov.SHA256SUM"
curl -Os "https://uploader.codecov.io/${codecovVersion}/linux/codecov.SHA256SUM.sig"
}
function verifySHASUM() {
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
}
function runCodecovUploader() {
chmod +x codecov
./codecov -t "${token}"
}
# Read script arguments
while getopts ":t:v:" option; do
case $option in
t) token=${OPTARG} ;;
v) codecovVersion=${OPTARG} ;;
*) exitWithUsageInfo ;;
esac
done
if [[ -z "${token}" ]]; then
exitWithUsageInfo
fi
if [[ -z "${codecovVersion}" ]]; then
codecovVersion="${defaultCodecovVersion}"
fi
importPublicKey
downloadCodecov
verifySHASUM
runCodecovUploader