Skip to content

Publish Python 🐍 distributions πŸ“¦ to PyPI #82

Publish Python 🐍 distributions πŸ“¦ to PyPI

Publish Python 🐍 distributions πŸ“¦ to PyPI #82

name: "Publish Python 🐍 distributions πŸ“¦ to PyPI"
on:
push:
branches:
- main
pull_request:
release:
types: [published]
jobs:
build:
name: "Build publish Python 🐍 distributions"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: "Set up Python 3.x"
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.x"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: "Install pypa/build"
run: >-
python -m
pip install
build
--user
- name: "Build a binary wheel and a source tarball"
run: >-
python -m
build
--outdir dist/
- name: "Upload packages"
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: packages
path: dist
publish:
name: "Publish πŸ“¦ to PyPI"
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packages
- name: "Publish distribution πŸ“¦ to PyPI"
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
with:
skip-existing: true
verbose: true
print-hash: true