Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 10 additions & 30 deletions .github/workflows/test_and_publish.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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 }}