Skip to content

Commit

Permalink
Make sure only a tagged commit gets published. (As with Travis, this …
Browse files Browse the repository at this point in the history
…doesn't check that the tag matches what we will publish. This should be good enough for now, though.)
  • Loading branch information
netsettler committed Mar 13, 2020
1 parent 655dc75 commit b3dc9df
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions bin/publish
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,34 @@ if [ -z "$PYPI_PASSWORD" ]; then
exit 1
fi

read -p "Are you sure you want to publish $(poetry version) to PyPi? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
changes=`git diff`

if [ -n "${changes}" ]; then
echo "You have made changes to this branch that you have not committed."
exit 1
fi

staged_changes=`git diff --staged`

if [ -n "${staged_changes}" ]; then
echo "You have staged changes to this branch that you have not committed."
exit 1
fi

tagged=`git log -1 --decorate | head -1 | grep 'tag:'`

if [ -z "$tagged" ]; then
# We don't encourage people to tag it unless they have no changes pending.
echo "You can only publish a tagged commit."
exit 1
fi

read -p "Are you sure you want to publish $(poetry version) to PyPi? "
REPLY=`echo "$REPLY" | tr '[:upper:]' '[:lower:]'`
if [ "$REPLY" != 'y' ] && [ "$REPLY" != "yes" ]
then
echo "Publishing aborted."
exit 1
fi

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

0 comments on commit b3dc9df

Please sign in to comment.