Skip to content

Deploy to PyPI 📦 #49

Deploy to PyPI 📦

Deploy to PyPI 📦 #49

Workflow file for this run

name: Deploy to PyPI 📦
# trigger deploy_to_pypi workflow once deploy_to_testpypi has successfully completed
on:
workflow_run:
workflows: [Deploy to TestPyPI 📦]
types: [completed]
# allow for workflow to be manually initiated from the Actions tab
workflow_dispatch:
# build and deploy to PyPI server if test workflow was successful or manual trigger was selected
jobs:
test_success:
name: Deploy to PyPI 📦
runs-on: ubuntu-latest # platform: [ubuntu-latest, macos-latest, windows-latest]
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
python-version: [3.9] #deploying using one Python version on 1 runner
steps:
- uses: actions/checkout@v3
# build distribution package using poetry tool and upload to the PYPi server via custom github action
- name: Build and publish to PyPI
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
#sleep for 30 seconds to ensure that distribution package has finished uploading to PyPI
- name: Wait / Sleep
uses: jakejarvis/wait-action@master
with:
time: '30s'
# download package of iso3166_2 from PYPI server to ensure it uploaded correctly
- name: Install iso3166_2 from PyPI
run: |
pip install iso3166_2 --upgrade
echo -e "import iso3166_2 as iso3166_2" | python3
echo "iso3166_2 successfully installed"
# test workflow was not successful so package not deployed to PyPI server
test_failure:
name: Test workflow failure
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo "Test workflow failure, package not deployed to PyPI server"