Skip to content

new version

new version #2

Workflow file for this run

name: Publish to PyPI
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for trusted publishing to PyPI
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
- name: Check package
run: |
twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Get changelog for version
id: get_changelog
run: |
VERSION=${{ steps.get_version.outputs.version }}
CHANGELOG_FILE="changelogs/CHANGELOG-${VERSION}.rst"
if [ -f "$CHANGELOG_FILE" ]; then
# Read changelog and store in output
echo "changelog<<EOF" >> $GITHUB_OUTPUT
cat "$CHANGELOG_FILE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "found=true" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
echo "changelog=Release $VERSION" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.get_version.outputs.tag }}
body: ${{ steps.get_changelog.outputs.changelog }}
draft: false
prerelease: false
files: |
dist/*.whl
dist/*.tar.gz