-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·66 lines (56 loc) · 1.54 KB
/
publish.sh
File metadata and controls
executable file
·66 lines (56 loc) · 1.54 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
62
63
64
65
66
#!/bin/bash
set -o errexit
set -o nounset
cd "$(dirname "$0")"
source python.sh
echo "Deactivating any active virtual environment..."
deactivate 2>/dev/null || true
if [ ! -d dist ]
then
>&2 echo "No dist/ directory found. Please run build.sh first."
exit 1
fi
DIST_FILES="$(ls -1 dist/*.tar.gz dist/*.whl)"
if [ -z "$DIST_FILES" ]
then
>&2 echo "No distribution files found. Please run build.sh first."
exit 1
fi
# Require that the tests have been run !
if [ ! -e dist/.tested ]
then
>&2 echo "Please run test-dist.sh before publishing."
exit 1
else
# And that no file in src/ is newer than the test marker file
if [ ! -z "$(find src -type f -newer dist/.tested)" ]
then
>&2 echo "Source files have been modified since tests were last run. Please run test-dist.sh again."
exit 1
fi
fi
# Get confirmation from user
echo "Found these files to publish:"
echo "$DIST_FILES" | sed 's/^/ /'
read -n1 -r -p "Ready to publish [y/n]? " confirm
echo
if [[ ! "$confirm" =~ ^[Yy]$ ]]
then
>&2 echo "Aborting publication."
exit 1
fi
# Create a clean venv for building
if [ -d .venv-publish ]
then
rm -rf .venv-publish
fi
# Create and activate a publish venv
$PYTHON -m venv .venv-publish
source .venv-publish/bin/activate
$PYTHON -m pip install --upgrade pip
$PYTHON -m pip install --upgrade twine
# And publish.
DIST_FILES_ONE_LINE=$(echo "$DIST_FILES" | tr '\n' ' ')
$PYTHON -m twine upload $DIST_FILES_ONE_LINE
echo
echo "Done. You'll need to reactivate your previous virtual environment if you had one."