Skip to content

Adds Github Action for PyPI release! #648

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
#os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
# env:
# CIBW_SOME_OPTION: value
# ...
# with:
# package-dir: .
# output-dir: wheelhouse
# config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
container: nvidia/cuda:12.8.1-devel-ubuntu24.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
version: 0.6.9
enable-cache: true
- name: Build SDist
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Release

on:
push:
tags:
# Publish on any tag starting with a `v`, e.g. v1.2.3
- v*

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
#os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
# env:
# CIBW_SOME_OPTION: value
# ...
# with:
# package-dir: .
# output-dir: wheelhouse
# config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
container: nvidia/cuda:12.8.1-devel-ubuntu24.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
version: 0.6.9
enable-cache: true
- name: Build SDist
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
pypi:
name: Publish to PyPI
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
# Environment and permissions trusted publishing.
environment:
# Create this environment in the GitHub repository under Settings -> Environments
name: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
version: 0.6.9
enable-cache: true
- name: Get Pyproject Version
run: |
export PYPROJECT_VERSION=v$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)
echo "PYPROJECT_VERSION=$PYPROJECT_VERSION" >> "$GITHUB_ENV"
- name: Validate version with tag
if: ${{ github.ref_name != env.PYPROJECT_VERSION }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Tag version ${{ github.ref_name }} does not match pyproject version ${{ env.PYPROJECT_VERSION }}')
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish wheel
run: uv publish --trusted-publishing always
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,21 @@ where = ["Python"]
[tool.setuptools.package-data]
"tigre.utilities.cuda_interface" = ["*.pyx", "*.pxd", "*.cpp"]

[tool.cibuildwheel]
build-frontend = "build[uv]"
skip = "pp* *musl*"
archs = ["native"]

[tool.cibuildwheel.linux]
#CUDA Installation
before-all = """
rpm --import https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/7fa2af80.pub &&
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo &&
yum clean all &&
yum -y install cuda-nvcc-12-4 cuda-cudart-devel-12-4 libcurand-devel-12-4 &&
ls -al /usr/local &&
export PATH=$PATH:/usr/local/cuda/bin &&
export CUDA_PATH=/usr/local/cuda &&
nvcc --version &&
export BUILD_WITH_CUDA=1
"""