-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupload_wheels.sh
executable file
·68 lines (55 loc) · 1.94 KB
/
upload_wheels.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
61
62
63
64
65
66
67
68
#!/bin/bash
# fail on undefined variables
set -u
# Prevent pipe errors to be silenced
set -o pipefail
# Exit if any command exit as non-zero
set -e
# enable trace mode (print what it does)
set -x
# get the anaconda token from the github secrets
#
# this is to prevent accidental uploads
echo "Getting anaconda token from github secrets..."
ANACONDA_ORG="${INPUT_ANACONDA_NIGHTLY_UPLOAD_ORGANIZATION}"
ANACONDA_TOKEN="${INPUT_ANACONDA_NIGHTLY_UPLOAD_TOKEN}"
ANACONDA_LABELS="${INPUT_ANACONDA_NIGHTLY_UPLOAD_LABELS}"
# if the ANACONDA_ORG is empty, exit with status -1
# this is to prevent attempt to upload to the wrong anaconda channel
if [ -z "${ANACONDA_ORG}" ]; then
echo "ANACONDA_ORG is empty, exiting..."
exit -1
fi
# if the ANACONDA_TOKEN is empty, exit with status -1
# this is to prevent accidental uploads
if [ -z "${ANACONDA_TOKEN}" ]; then
echo "ANACONDA_TOKEN is empty , exiting..."
exit -1
fi
# if the ANACONDA_LABELS is empty, exit with status -1
# as this should be set in action.yml or by the user
# and it is better to fail on this to sigal a problem.
if [ -z "${ANACONDA_LABELS}" ]; then
echo "ANACONDA_LABELS is empty, exiting..."
exit -1
fi
# convert newlines to commas for parsing
# and ensure that there is no trailing comma
ANACONDA_LABELS="$(tr '\n' ',' <<< "${ANACONDA_LABELS}" | sed 's/,$//')"
IFS=',' read -ra LABELS <<< "${ANACONDA_LABELS}"
LABEL_ARGS=""
for label in "${LABELS[@]}"; do
LABEL_ARGS+="--label ${label} "
done
# trim trailing slashes from $INPUT_ARTIFACTS_PATH
INPUT_ARTIFACTS_PATH="${INPUT_ARTIFACTS_PATH%/}"
# upload wheels
echo "Uploading wheels to anaconda.org..."
# Note: ${LABEL_ARGS} must not be quoted during shell parameter expansion,
# else it will be treated as a file and not additional command arguments.
anaconda --token "${ANACONDA_TOKEN}" upload \
--force \
--user "${ANACONDA_ORG}" \
${LABEL_ARGS} \
"${INPUT_ARTIFACTS_PATH}"/*.whl
echo "Index: https://pypi.anaconda.org/${ANACONDA_ORG}/simple"