-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
79 lines (57 loc) · 2.09 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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}\""
VERSION_REGEX_WITH_SPACE='version\ =\ \"[^"]\+\"'
VERSION_REPLACE_WITH_SPACE="version\ =\ \"${CLEAN_VER}\""
if [[ -e setup.py ]]; then
sed -i -e "s/${VERSION_REGEX}/${VERSION_REPLACE}/g" setup.py
sed -i -e "s/${VERSION_REGEX_WITH_SPACE}/${VERSION_REPLACE_WITH_SPACE}/g" setup.py
fi
if [[ -e pyproject.toml ]]; then
sed -i -e "s/${VERSION_REGEX}/${VERSION_REPLACE}/g" pyproject.toml
sed -i -e "s/${VERSION_REGEX_WITH_SPACE}/${VERSION_REPLACE_WITH_SPACE}/g" pyproject.toml
fi
echo "---------------- BUILD PACKAGE ----------------"
if [[ -e pyproject.toml ]]; then
pip install -q build
python -m build
elif [[ -e setup.py ]]; then
python setup.py sdist bdist_wheel
fi
if [[ ${VERIFY_METADATA} != "false" ]] ; then
twine check dist/*
fi
echo "---------------- PUBLISH PACKAGE ----------------"
EXTRA_ARGS=
if [[ -n "${UPLOAD_REPO}" ]]; then
EXTRA_ARGS="--repository-url ${UPLOAD_REPO} ${EXTRA_ARGS}"
echo "-------- Using repository: ${UPLOAD_REPO}"
fi
if [[ ${SKIP_EXISTING} != "false" ]] ; then
EXTRA_ARGS="--skip-existing ${EXTRA_ARGS}"
fi
if [[ ${VERBOSE} != "false" ]] ; then
EXTRA_ARGS="--verbose ${EXTRA_ARGS}"
fi
python -m twine upload dist/* -u ${TWINE_USERNAME} -p ${TWINE_PASSWORD} ${EXTRA_ARGS}