Skip to content

Add automated releases with GitHub Actions #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Publish

on:
push:
tags:
- "*"

jobs:
build:
name: Build packages
runs-on: ubuntu-24.04
environment: publish

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build packages
run: |
pip install -r requirements/testing.txt
make package
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
if-no-files-found: error

publish-to-pypi:
name: Publish package on PyPI
needs:
- build
runs-on: ubuntu-24.04
environment:
name: pypi
url: https://pypi.org/project/${{ github.event.repository.name }}/${{ github.ref_name }}/
permissions:
id-token: write

steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Publish package on GitHub Releases
needs:
- build
runs-on: ubuntu-24.04
environment:
name: github-releases
url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}
permissions:
contents: write
id-token: write

steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign packages
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--title "${GITHUB_REPOSITORY#*/} $GITHUB_REF_NAME"
- name: Upload artifact signatures to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"