Skip to content

Publish Python distributions to PyPI #779

Publish Python distributions to PyPI

Publish Python distributions to PyPI #779

Workflow file for this run

# Based on
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: Publish Python distributions to PyPI
on:
push:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-n-publish:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
permissions:
# needed for PyPI trusted publishing
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv pip install build --system
- run: uv pip freeze
- if: ${{ github.event_name != 'push' }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
DATE=$(date '+%y.%-m.%-d')
echo $DATE
git config --global user.name releasebot
git config --global user.email ""
git tag -a $DATE -m ""
git push --tags
gh release create $DATE --notes "Automated weekly release"
- name: Build a binary wheel and a source tarball
run: python -m build --outdir dist/ .
- name: Publish distribution to PyPI
if: ${{ github.event_name != 'push' || startsWith(github.ref, 'refs/tags') }}
uses: pypa/gh-action-pypi-publish@release/v1