Add action to make a release and publish to PyPI

This GitHub Actions workflow automates two tasks:

1. **Create Release:**
   - Triggered when a new version tag (formatted as `vX.X.X`) is pushed.
   - Creates a release with the tag name, marking it as the latest version.

2. **Publish to PyPI:**
   - Runs after the release is created successfully.
   - Builds and publishes the Python package to PyPI using Poetry.
   - Ignores development requirements during the publishing process.

This ensures that each new version gets a release on GitHub and the corresponding Python package is published on PyPI.

Co-authored-by: Darwish Ahmad Herati <13837531+daherati@users.noreply.github.com>
Co-authored-by: mateuslatrova <57113699+mateuslatrova@users.noreply.github.com>
This commit is contained in:
Lucas de Sousa Rosa 2023-12-01 18:33:47 -03:00
parent 4a88a2fc78
commit 125ee2bcfd

View File

@ -0,0 +1,32 @@
name: Create and publish a release
on:
push:
tags:
- 'v*.*.*'
jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref_name }}
makeLatest: true
publish_to_pypi:
name: Publish to PyPI
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and publish to PyPI
uses: JRubics/poetry-publish@v1.17
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
ignore_dev_requirements: "yes"