From ca5dc794030331dcfba480a1414fb37cd38c67a5 Mon Sep 17 00:00:00 2001 From: Luca Gilli Date: Thu, 15 May 2025 11:15:26 +0200 Subject: [PATCH] Update test_and_publish.yaml --- .github/workflows/test_and_publish.yaml | 40 +++++++------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/.github/workflows/test_and_publish.yaml b/.github/workflows/test_and_publish.yaml index 8b9b8f7..f44103d 100644 --- a/.github/workflows/test_and_publish.yaml +++ b/.github/workflows/test_and_publish.yaml @@ -1,15 +1,14 @@ - name: Test and Publish Library to PyPI on: push: branches: - main + pull_request: jobs: build: runs-on: ${{ matrix.os }} - strategy: matrix: os: [macos-latest, ubuntu-latest] @@ -37,42 +36,23 @@ jobs: - name: Build Python wheels run: | - python setup.py bdist_wheel + python setup.py sdist bdist_wheel - # - name: Check if version exists on PyPI - # id: check-version - # run: | - # PACKAGE_NAME=$(python setup.py --name) - # PACKAGE_VERSION=$(python setup.py --version) - - # RESPONSE=$(curl --silent --fail https://pypi.org/pypi/${PACKAGE_NAME}/json || echo "not found") - - # if echo "$RESPONSE" | grep -q '"releases"'; then - # if echo "$RESPONSE" | jq -e ".releases | has(\"$PACKAGE_VERSION\")" >/dev/null; then - # echo "Version ${PACKAGE_VERSION} already exists on PyPI." - # echo "already_published=true" >> $GITHUB_ENV - # else - # echo "Version ${PACKAGE_VERSION} does not exist on PyPI." - # echo "already_published=false" >> $GITHUB_ENV - # fi - # else - # echo "Package does not exist on PyPI." - # echo "already_published=false" >> $GITHUB_ENV - # fi - name: Repair manylinux wheels if: runner.os == 'Linux' run: | - pip install numpy build wheel auditwheel + pip install auditwheel + mkdir wheels for whl in dist/*.whl; do - auditwheel repair "$whl" --plat manylinux2014_x86_64 -w dist/ + auditwheel repair "$whl" --plat manylinux2014_x86_64 -w wheels done + mv wheels/*.whl dist/ + - name: Publish on PyPI - # if: env.already_published == 'false' - + if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: | - pip install twine - twine upload dist/*.* + pip install twine + twine upload dist/* env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} -