From 125ee2bcfd02e2f4422fd8cb41b606ca8d565f7f Mon Sep 17 00:00:00 2001 From: Lucas de Sousa Rosa Date: Fri, 1 Dec 2023 18:33:47 -0300 Subject: [PATCH] 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> --- .github/workflows/release_and_publish.yml | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/release_and_publish.yml diff --git a/.github/workflows/release_and_publish.yml b/.github/workflows/release_and_publish.yml new file mode 100644 index 0000000..7d6375e --- /dev/null +++ b/.github/workflows/release_and_publish.yml @@ -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" \ No newline at end of file