Publish Python distributions to PyPI #796
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
# 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: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
version: "latest" | |
- 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: uv build | |
- name: Publish distribution to PyPI | |
if: ${{ github.event_name != 'push' || startsWith(github.ref, 'refs/tags') }} | |
run: uv publish |