-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdeploy.sh
executable file
·51 lines (48 loc) · 1.28 KB
/
deploy.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
#!/bin/bash
# Deploy amc2moodle weel to pypi server.
# wheel path
WHEEL_DIR=$(pwd)/dist
function wheel()
{
# Build and test wheel in an venv to check if all required files are present in
# the wheel.
# Clean-up previous version
rm $WHEEL_DIR/amc2moodle*.whl
pip3 wheel . -w dist
# Setup venv
TEMP_DIR=$(mktemp -d)
python3 -m venv $TEMP_DIR
source $TEMP_DIR/bin/activate
# Change dir to test really wheel file and not the repo files
cd $TEMP_DIR
# Install the wheel
pip3 install $WHEEL_DIR/amc2moodle*.whl
# Run all tests
python3 -m amc2moodle.amc2moodle.test && python -m amc2moodle.moodle2amc.test && python -m amc2moodle.utils.test
SUCCESS=$?
# Clean-up tmp directory
cd $WHEEL_DIR
trap 'rm -rf "$TEMP_DIR"' EXIT
if [ $SUCCESS -eq 0 ]
then
echo "Ready for uploading :" $(ls $WHEEL_DIR/amc2moodle*.whl)
return 0
else
echo "Test failed. Stop deployment." >&2
return 1
fi
}
# Main deployment script
for i in "$@"
do
case "$i" in
-i|--install) pip install --user twine
;;
-t|--test)
wheel && twine upload --verbose -r testpypi $WHEEL_DIR/amc2moodle*.whl
;;
-d|--deploy)
wheel && twine upload --verbose $WHEEL_DIR/amc2moodle*.whl
;;
esac
done