Skip to content
Open
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
95 changes: 95 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Publish to PyPI

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build distributions
Comment thread
fe-neu marked this conversation as resolved.
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v')
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/setup-uv@v10.1.0
with:
python-version: "3.11"

- name: Check release tag matches project version
if: github.event_name == 'release'
env:
TAG: ${{ github.event.release.tag_name }}
run: |
version="$(uv version --short)"
if [ "$TAG" != "v$version" ]; then
echo "::error::Release tag '$TAG' does not match expected tag 'v$version'."
exit 1
fi

- name: Build sdist and wheel
run: uv build

- name: Check distribution metadata
run: uvx twine check --strict dist/*

- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
if-no-files-found: error

publish-testpypi:
name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch'
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: testpypi
url: https://test.pypi.org/p/seriousdb
permissions:
# Required to request the OIDC token used for Trusted Publishing.
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-pypi:
name: Publish to PyPI
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/p/seriousdb
permissions:
# Required to request the OIDC token used for Trusted Publishing.
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Loading