This repository was archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild
executable file
·122 lines (105 loc) · 2.5 KB
/
build
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
activate () {
if [[ -z "$VIRTUAL_ENV" ]]; then
if [[ -f "venv/bin/activate" ]]; then
echo "Activating venv..."
source venv/bin/activate
echo "Activated venv"
else
echo "Creating venv..."
python3 -m venv venv
activate
upgrade
fi
fi
}
build () {
clean
echo "Building..."
python3 -m build
echo "Finished building"
}
clean () {
echo "Cleaning..."
rm -rf build/
if [[ ! -d "build/" ]]; then
echo "Removed build/"
else
echo "[ERROR]: Failed to remove build/"
fi
rm -rf dist/
if [[ ! -d "dist/" ]]; then
echo "Removed dist/"
else
echo "[ERROR]: Failed to remove dist/"
fi
echo "Finished cleaning"
}
debug () {
if [[ -z "$DEV_DEBUG" ]]; then
export DEV_DEBUG=1
echo "Toggled debug mode on"
else
export DEV_DEBUG=
echo "Toggled debug mode off"
fi
}
show_help () {
echo "source build [OPTION]"
echo
echo "Peform build and development related tasks."
echo
echo " help - show this help"
echo " activate - activate virtual environment"
echo " build - build PyPi packages"
echo " clean - remove build directories"
echo " debug - toggle debug mode"
echo " test - run unit tests"
echo " upgrade - upgrade build environment"
echo " upload - upload to PyPI"
echo " upload-test - upload to test PyPI"
}
run-tests () {
echo "Running tests..."
python3 tests/test_nostalgic.py
}
upgrade () {
echo "Upgrading..."
python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine
echo "Upgrade finished"
}
upload () {
TWINE_USERNAME="__token__"
python3 -m twine upload --username $TWINE_USERNAME --repository pypi dist/*
}
upload-test () {
TWINE_USERNAME="__token__"
python3 -m twine upload --username $TWINE_USERNAME --repository testpypi dist/*
}
if [[ $1 = "help" ]]; then
show_help
elif [[ $1 = "activate" ]]; then
activate
elif [[ $1 = "build" ]]; then
activate
build
elif [[ $1 = "clean" ]]; then
clean
elif [[ $1 = "debug" ]]; then
debug
elif [[ $1 = "test" ]]; then
activate
run-tests
elif [[ $1 = "upgrade" ]]; then
activate
upgrade
elif [[ $1 = "upload-test" ]]; then
activate
upload-test
elif [[ $1 = "upload" ]]; then
activate
upload
else
show_help
fi