Skip to content

Commit b3dc9df

Browse files
committed
Make sure only a tagged commit gets published. (As with Travis, this doesn't check that the tag matches what we will publish. This should be good enough for now, though.)
1 parent 655dc75 commit b3dc9df

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

bin/publish

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,34 @@ if [ -z "$PYPI_PASSWORD" ]; then
1010
exit 1
1111
fi
1212

13-
read -p "Are you sure you want to publish $(poetry version) to PyPi? " -n 1 -r
14-
if [[ ! $REPLY =~ ^[Yy]$ ]]
15-
then
16-
exit 1
13+
changes=`git diff`
14+
15+
if [ -n "${changes}" ]; then
16+
echo "You have made changes to this branch that you have not committed."
17+
exit 1
18+
fi
19+
20+
staged_changes=`git diff --staged`
21+
22+
if [ -n "${staged_changes}" ]; then
23+
echo "You have staged changes to this branch that you have not committed."
24+
exit 1
1725
fi
1826

27+
tagged=`git log -1 --decorate | head -1 | grep 'tag:'`
28+
29+
if [ -z "$tagged" ]; then
30+
# We don't encourage people to tag it unless they have no changes pending.
31+
echo "You can only publish a tagged commit."
32+
exit 1
33+
fi
34+
35+
read -p "Are you sure you want to publish $(poetry version) to PyPi? "
36+
REPLY=`echo "$REPLY" | tr '[:upper:]' '[:lower:]'`
37+
if [ "$REPLY" != 'y' ] && [ "$REPLY" != "yes" ]
38+
then
39+
echo "Publishing aborted."
40+
exit 1
41+
fi
1942

2043
poetry publish --no-interaction --build --username=$PYPI_USER --password=$PYPI_PASSWORD

0 commit comments

Comments
 (0)