From 240cc60fe4fe7458d3a7828c3e793795eb59a438 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 5 Mar 2024 14:36:50 -0500 Subject: [PATCH] Modernize pypi action Change format to yaml Run it on pull requests to check all steps work Publish conditionally only on tag ref pushes Signed-off-by: Simo Sorce --- .github/workflows/publish-to-pypi.yml | 73 ++++++++++++++------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 37a341f..2a201a6 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,36 +1,37 @@ -{ - "name": "Release to PyPI", - "on": { - "push": { - "tags": [ "v*.*" ] - }, - }, - "jobs": { - "pypi": { - "name": "Publish Release", - "runs-on": "ubuntu-latest", - "steps": [ - { "uses": "actions/checkout@v2" }, - { - "uses": "actions/setup-python@v2", - "with": { - "python-version": "3.10" - }, - }, - { "run": "sudo apt-get update" }, - { "run": "sudo apt-get install cargo" }, - { "run": "pip --version" }, - { "run": "python setup.py sdist" }, - { "run": "python setup.py bdist_wheel" }, - { - "uses": "pypa/gh-action-pypi-publish@release/v1", - "with": { - "user": "__token__", - "password": "${{secrets.PYPI_API_TOKEN}}", - "skip-existing": true, - }, - }, - ], - }, - }, -} +--- +name: Release to PyPI + +on: + push: + tags: [ "v*.*" ] + pull_request: + branches: ["main"] + +jobs: + pypi: + name: Publish Release + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Setup + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Make distribution + run: | + sudo apt-get update + sudo apt-get install cargo + pip --version + pip install wheel + python setup.py sdist + python setup.py bdist_wheel + - name: Publish on pypi (only for tag pushes) + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{secrets.PYPI_API_TOKEN}} + skip-existing: true