Skip to content

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

Publish Python 🐍 distributions πŸ“¦ to PyPI

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

name: "Publish Python 🐍 distributions πŸ“¦ to PyPI"
on:
release:
types: [published]
jobs:
build:
name: "Build distribution πŸ“¦"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Set up Python 3.x"
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
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@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: "Publish Python 🐍 distribution πŸ“¦ to PyPI"
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/letsbuilda-pypi/
permissions:
id-token: write
steps:
- name: "Download dists"
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: "Publish distribution πŸ“¦ to PyPI"
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # v1.8.11
with:
verbose: true
print-hash: true