Automated deployment to PyPI on release #3
Workflow file for this run
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: Build and upload to PyPI | ||
on: | ||
push: | ||
tags: | ||
- "*" | ||
release: | ||
types: | ||
- published | ||
pull_request: | ||
branches: [main] | ||
jobs: | ||
# Build the packacge and upload the resulting distribution | ||
# as an artifact to later be used during deployment to | ||
# PyPI | ||
build: | ||
name: "Build $PACKAGE_NAME" | ||
if: github.repository == ${{ vars.REPO_OWNER}}/${{ vars.REPO_NAME }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build wheel and source | ||
run: python3 -m build | ||
- name: Upload distribution artifact | ||
if: | | ||
Check failure on line 42 in .github/workflows/deploy.yaml GitHub Actions / Build and upload to PyPIInvalid workflow file
|
||
((github.event_name = 'push' && startsWith(github.ref, 'refs/tags/' )) || | ||
(github.event_name = 'release' && github.event.action == 'published')) && | ||
github.event_name != "pull_request" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
# Publish the resulting artifact from the above job to | ||
# the main PyPI repository. | ||
publish-to-pypi: | ||
name: "Publish $PACKAGE_NAME to PyPI" | ||
if: | | ||
github.event_name == 'release' && | ||
github.event.action == 'published' && | ||
github.repository == ${{ vars.REPO_OWNER }}/${{ vars.REPO_NAME }} && | ||
github.event_name != "pull_request" | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: "https://pypi.org/p/$PACKAGE_NAME" | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Downlaod build artifacts | ||
uses: actions/download-artifacts@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: "Publish $PACKAGE_NAME to PyPI" | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
publish-to-testpypi: | ||
name: "Publish $PACKAGE_NAME to TestPyPI" | ||
if: | | ||
github.repository == ${{ vars.REPO_OWNER }}/${{ vars.REPO_NAME }} && | ||
github.event_name == 'push' && | ||
startsWith(github.ref, 'refs/tags/') && | ||
github.event_name != "pull_request" | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: testpypi | ||
url: "https://test.pypi.org/p/$PACKAGE_NAME" | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Downlaod build artifacts | ||
uses: actions/download-artifacts@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: "Publish $PACKAGE_NAME to TestPyPI" | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
skip_existing: true |