Deploy to TestPyPI 📦 #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to TestPyPI 📦 | |
# trigger deploy workflow once build and test workflow has successfully completed | |
on: | |
workflow_run: | |
workflows: ["Building and Testing"] | |
types: [completed] | |
# allow for workflow to be manually initiated from the Actions tab | |
workflow_dispatch: | |
# build and deploy to Test PyPI server if test workflow was successful or manual trigger was selected | |
jobs: | |
test_success: | |
name: Deploy to TestPyPI 📦 | |
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 test PYPi server via custom github action | |
- name: Build and publish to Test PyPI | |
uses: JRubics/poetry-publish@v2.0 | |
with: | |
pypi_token: ${{ secrets.PYPI_TEST }} | |
repository_name: "testpypi" | |
repository_url: "https://test.pypi.org/legacy/" | |
#sleep for 30 seconds to ensure that distribution package has finished uploading to Test PyPI | |
- name: Wait / Sleep | |
uses: jakejarvis/wait-action@master | |
with: | |
time: '30s' | |
# download package of iso3166_2 from Test PYPI server to ensure it uploaded correctly | |
- name: Install iso3166_2 from Test PyPI | |
run: | | |
pip install -i https://test.pypi.org/simple/ iso3166_2 --upgrade | |
echo "iso3166_2 successfully installed" | |
# test workflow was not successful so package not deployed to Test PyPI or PyPI | |
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 Test PyPI server" |