Skip to content

Commit

Permalink
CI: Add workflow to build wheels and publish to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed Oct 28, 2024
1 parent 37f31a9 commit 9951660
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build/publish package

on: push

jobs:
build_wheels:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Build wheels on ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v3

- name: Print the installed version
run: echo "Installed uv version is ${{ steps.setup-uv.outputs.uv-version }}"

- name: Set up Python 3.12 and install dependencies
run: |
uv python install 3.12
uv sync --python 3.12 --extra test --extra build --frozen
- name: Build
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: auto aarch64
CIBW_ARCHS_MACOS: x86_64 arm64

- name: Upload Wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: wheelhouse

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

publish-to-pypi:
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/sdf-xarray
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ sdist.include = ["src/sdf_xarray/_version.py"]
write_to = "src/sdf_xarray/_version.py"

[tool.cibuildwheel]
build-frontend = "build[uv]"
skip = ["*-win32", "*-manylinux_i686", "pp*", "*musllinux*"]

0 comments on commit 9951660

Please sign in to comment.