Skip to content

Automated deployment to PyPI on release #3

Automated deployment to PyPI on release

Automated deployment to PyPI on release #3

Workflow file for this run

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

View workflow run for this annotation

GitHub Actions / Build and upload to PyPI

Invalid workflow file

The workflow is not valid. .github/workflows/deploy.yaml (Line: 42, Col: 11): Unexpected symbol: '='. Located at position 21 within expression: ((github.event_name = 'push' && startsWith(github.ref, 'refs/tags/' )) || (github.event_name = 'release' && github.event.action == 'published')) && github.event_name != "pull_request"
((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