ci(workflow): use release event for publishing

This commit is contained in:
tayf 2026-03-19 16:42:05 +02:00
parent 740fabbbe9
commit c50f4b4324
2 changed files with 38 additions and 15 deletions

View file

@ -1,6 +1,8 @@
name: Publish to PyPI
on:
workflow_dispatch:
release:
types: [published]
jobs:
publish:
@ -8,26 +10,15 @@ jobs:
environment: pypi
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
ref: ${{ github.event.release.tag_name }}
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "import tomllib; data=tomllib.load(open('pyproject.toml','rb')); print(data['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- uses: astral-sh/setup-uv@v5
- name: Build
run: uv build
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: v${{ steps.get_version.outputs.version }}
generate_release_notes: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

32
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Release
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "import tomllib; data=tomllib.load(open('pyproject.toml','rb')); print(data['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build
run: uv build
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: v${{ steps.get_version.outputs.version }}
generate_release_notes: true
files: dist/*