Skip to content

update: publish-to-pypi.yaml #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025
Merged
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
85 changes: 12 additions & 73 deletions .github/workflows/publish-to-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,88 +6,27 @@ on:
- v*

jobs:
# First job is to build the wheels on different OS
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Upgrade pip and install cibuildwheel
run: |
python -m pip install --upgrade pip
pip install cibuildwheel

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp310-* cp311-* cp312-*"
CIBW_SKIP: "pp* *musllinux*"
CIBW_TEST_SKIP: "*"
CIBW_ARCHS_MACOS: "universal2"
CIBW_ARCHS_LINUX: "x86_64 aarch64"

- name: Upload built wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl

# Then just build the source distribution as normal
build_sdist:
name: Build source distribution
build-release:
name: Build and publish PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v3
with:
python-version: "3.12"
python-version: '3.10'

- name: Upgrade pip and install build
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build

- name: Build sdist
run: python -m build --sdist --outdir dist

- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz

# Finally publish all files to PyPI
publish:
name: Publish to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
pip install --upgrade pip setuptools wheel build setuptools_scm

- name: Merge all distributions
- name: Build Package
run: |
mkdir -p final_dist
find dist -name '*.whl' -exec cp {} final_dist/ \;
find dist -name '*.tar.gz' -exec cp {} final_dist/ \;
python -m build --no-isolation

- name: Publish to PyPI
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: final_dist
password: ${{ secrets.PYPI_API_TOKEN }}
Loading