Skip to content

🔖 release v0.2.5 #14

🔖 release v0.2.5

🔖 release v0.2.5 #14

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag_name:
description: 'Existing tag name, e.g. v0.2.2'
required: true
type: string
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
env:
TAG_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.TAG_NAME }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract release notes from CHANGELOG
run: |
VERSION="${TAG_NAME#v}"
awk -v version="$VERSION" '
$0 ~ "^## \\[" version "\\]" {capture=1; next}
capture && $0 ~ "^## \\[" {exit}
capture {print}
' CHANGELOG.md | sed '/^[[:space:]]*$/N;/^\n$/D' > release_notes.md
if [ ! -s release_notes.md ]; then
{
echo "Release ${TAG_NAME}"
echo
echo "No matching section found in CHANGELOG.md."
} > release_notes.md
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
name: ${{ env.TAG_NAME }}
body_path: release_notes.md
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*