Skip to content
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
45 changes: 20 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,24 @@ name: Publish to PyPI

on:
push:
branches: [main]
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=v$VERSION" >> $GITHUB_OUTPUT

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: Release ${{ steps.get_version.outputs.version }}
body: |
## What's Changed
${{ github.event.head_commit.message }}

**Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.get_version.outputs.version }}
draft: false
prerelease: false

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -48,6 +28,21 @@ jobs:
- name: Build package
run: python -m build

- name: Extract changelog
id: changelog
run: |
VERSION=${GITHUB_REF#refs/tags/v}
CHANGELOG=$(awk '/## \['$VERSION'\]/,/## \[/' CHANGELOG.md | sed '$d' | tail -n +2)
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.content }}
generate_release_notes: false

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
Expand Down