Skip to content

try if upload to PyPI works when PR comes from the same repo #509

try if upload to PyPI works when PR comes from the same repo

try if upload to PyPI works when PR comes from the same repo #509

name: Build & Publish Python Package
# Trigger the workflow on push or pull request, but only for the master branch
on:
pull_request:
push:
branches: [master]
jobs:
build_wheels:
name: Build wheel on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: "ubuntu-latest"
os: ubuntu-latest
- name: "macos-latest-x86_64"
os: macos-latest
macos_arch: x86_64
- name: "macos-latest-arm64"
os: macos-latest
macos_arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.x'
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel
- name: Install build tools for OSX
if: startsWith(matrix.os, 'macos')
run: |
brew install automake
brew install libtool
- name: Build wheels on Linux
if: startsWith(matrix.os, 'macos') != true
env:
CIBW_BEFORE_BUILD: |
cd src/runtime/c
autoreconf -i
./configure
make
make install
run: |
python -m cibuildwheel src/runtime/python --output-dir wheelhouse
- name: Build wheels on OSX
if: startsWith(matrix.os, 'macos')
env:
CFLAGS: "-arch ${{ matrix.macos_arch }}"
LDFLAGS: "-arch ${{ matrix.macos_arch }}"
CIBW_BEFORE_BUILD: |
cd src/runtime/c
glibtoolize
autoreconf -i
CFLAGS="-arch ${{ matrix.macos_arch }}" LDFLAGS="-arch ${{ matrix.macos_arch }}" ./configure
make
sudo make install
run: |
python -m cibuildwheel src/runtime/python --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.name }}
path: ./wheelhouse
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Build sdist
run: cd src/runtime/python && python setup.py sdist
- uses: actions/upload-artifact@v4
with:
name: wheel-source
path: ./src/runtime/python/dist/*.tar.gz
upload_pypi:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install twine
run: pip install twine
- uses: actions/download-artifact@v4.1.7
with:
pattern: wheel-*
merge-multiple: true
path: ./dist
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
ls -la ./dist/ # Debug: Check if wheels exist
echo "Attempting upload..."
twine upload --verbose --non-interactive --skip-existing dist/*