Skip to content

Commit

Permalink
ci: Merge pull request #120 from rspencer01/conditional_publish
Browse files Browse the repository at this point in the history
Add logic to circleci to conditionally publish package to test or live PyPI
  • Loading branch information
rspencer01 authored Oct 10, 2024
2 parents 1da7cdb + 0899669 commit 4c5bb90
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,23 @@ jobs:
command: |
set -e
. ci/bin/activate
export TWINE_USERNAME='__token__'
export TWINE_PASSWORD=$PYPI_TOKEN
if git describe --exact-match --tags; then
if [[ $PYPI_INSTANCE == "test" ]]; then
echo "Publishing to test PyPI"
export TWINE_USERNAME='__token__'
export TWINE_PASSWORD=$TEST_PYPI_TOKEN
twine upload --verbose --repository=testpypi dist/*
elif [[ $PYPI_INSTANCE == "live" ]]; then
echo "Publishing to live PyPI"
export TWINE_USERNAME='__token__'
export TWINE_PASSWORD=$PYPI_TOKEN
if git describe --exact-match --tags; then
twine upload --verbose dist/*
else
echo "Not on an exact tag: refusing to publish"
fi
else
echo "Not on an exact tag: refusing to publish"
echo "Variable PYPI_INSTANCE must be set to either `live` or `test`."
exit 1
fi
workflows:
version: 2
Expand Down

0 comments on commit 4c5bb90

Please sign in to comment.