-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
63 lines (43 loc) · 1.55 KB
/
entrypoint.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
#!/bin/bash
set -o errexit -o pipefail -o nounset
GITHUB_REPO=${INPUT_GITHUB_REPO}
UPLOAD_REPO=${INPUT_UPLOAD_REPO:-}
TWINE_USERNAME=${INPUT_TWINE_USERNAME}
TWINE_PASSWORD=${INPUT_TWINE_PASSWORD}
VERIFY_METADATA=${INPUT_VERIFY_METADATA}
SKIP_EXISTING=${INPUT_SKIP_EXISTING}
VERBOSE=${INPUT_VERBOSE}
REPO_NAME=$(cut -d "/" -f2 <<< ${GITHUB_REPO})
echo "---------------- CLONE REPO ----------------"
git clone https://github.com/${GITHUB_REPO}
cd ${REPO_NAME}
echo "---------------- MODIFY SETUP FILE ----------------"
RELEASE_VER=`curl -s https://api.github.com/repos/${GITHUB_REPO}/releases | jq -r .[0].tag_name`
if [[ ${RELEASE_VER} == v* ]];
then
CLEAN_VER=$(echo ${RELEASE_VER} | sed '0,/v/ s/v//')
else
CLEAN_VER=${RELEASE_VER}
fi
echo "Cleaned version name: ${CLEAN_VER}"
VERSION_REGEX='version=\"[^"]\+\"'
VERSION_REPLACE="version=\"${CLEAN_VER}\""
sed -i -e "s/${VERSION_REGEX}/${VERSION_REPLACE}/g" setup.py
echo "---------------- BUILD PACKAGE ----------------"
python setup.py sdist bdist_wheel
echo "---------------- PUBLISH PACKAGE ----------------"
if [[ -z "${UPLOAD_REPO}" ]]; then
EXTRA_ARGS="--repository-url ${UPLOAD_REPO} ${EXTRA_ARGS}"
echo "-------- Using repository: ${UPLOAD_REPO}"
fi
if [[ ${VERIFY_METADATA} != "false" ]] ; then
twine check dist/*
fi
EXTRA_ARGS=
if [[ ${SKIP_EXISTING} != "false" ]] ; then
EXTRA_ARGS=--skip-existing
fi
if [[ ${VERBOSE} != "false" ]] ; then
EXTRA_ARGS="--verbose ${EXTRA_ARGS}"
fi
python -m twine upload dist/* -u ${TWINE_USERNAME} -p ${TWINE_PASSWORD} ${EXTRA_ARGS}