-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·61 lines (51 loc) · 1.27 KB
/
publish.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.27 KB
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
#!/bin/bash
# Function to show usage
usage() {
echo "Usage: $0 [patch|minor|major] [--test]"
exit 1
}
# Check version argument
if [ "$1" == "patch" ] || [ "$1" == "minor" ] || [ "$1" == "major" ]; then
VERSION=$1
else
usage
fi
# Check for test option
if [ "$2" == "--test" ]; then
REPOSITORY="testpypi"
API_TOKEN=$TEST_PYPI_API_TOKEN
else
REPOSITORY="pypi"
API_TOKEN=$PROD_PYPI_API_TOKEN
fi
# Check if Git working directory is clean
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Git working directory is not clean. Please commit or stash your changes."
exit 1
fi
# Update version
if ! bumpversion $VERSION; then
echo "Error: bumpversion failed."
exit 1
fi
# Clean up the build directory
if ! rm -rf dist; then
echo "Error: Failed to clean up the build directory."
exit 1
fi
# Build the package
if ! python -m build; then
echo "Error: Build failed."
exit 1
fi
# Upload to the specified repository
if ! python -m twine upload --repository $REPOSITORY dist/* -u "__token__" -p $API_TOKEN; then
echo "Error: Failed to upload the package."
exit 1
fi
# Push changes to Git
if ! git push origin main; then
echo "Error: Failed to push changes to Git."
exit 1
fi
echo "All steps completed successfully."