Skip to content

Commit f480acb

Browse files
ci: add release and continuous workflows
- CI job does a single wheel build on Linux, Mac and Windows - Release job uses semantic release, build all wheels and upload to pypi
1 parent 8661982 commit f480acb

3 files changed

Lines changed: 222 additions & 0 deletions

File tree

.github/workflows/build-wheels.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: build-wheels
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
description: "OS to run on, must be one of supported runner type"
8+
required: true
9+
type: string
10+
build-target:
11+
description: "CIBW build target (e.g., cp310-manylinux_x86_64)"
12+
required: true
13+
type: string
14+
python-version:
15+
description: "CIBW build target (e.g., 3.10)"
16+
required: true
17+
type: string
18+
platform-tag:
19+
description: "Wheel platform tag to apply after building."
20+
required: true
21+
type: string
22+
23+
jobs:
24+
build-test:
25+
runs-on: ${{ inputs.os }}
26+
27+
env:
28+
PIP_EXTRA_INDEX_URL: "https://vtk.org/files/wheel-sdks"
29+
CIBW_ENVIRONMENT_PASS_LINUX: "PIP_EXTRA_INDEX_URL"
30+
CIBW_BUILD: ${{ inputs.build-target }}
31+
# Required to make tests pass (VTK needs them)
32+
CIBW_BEFORE_ALL_LINUX: "yum install -y mesa-libGL-devel glx-utils freeglut-devel"
33+
# Global test setup
34+
CIBW_TEST_REQUIRES: "pytest virtualenv"
35+
# Do not repair, everything is already put just as needed to make it work
36+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "
37+
python -m pip install wheel &&
38+
python -m wheel tags --platform-tag ${{ inputs.platform-tag }} --remove {wheel} &&
39+
cp $(dirname {wheel})/slicer_layer_dm*.whl {dest_dir}"
40+
# same as above, we don't patch the wheel on Mac too.
41+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "
42+
python -m pip install wheel &&
43+
python -m wheel tags --platform-tag ${{ inputs.platform-tag }} --remove {wheel} &&
44+
cp $(dirname {wheel})/slicer_layer_dm*.whl {dest_dir}"
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ inputs.python-version }}
51+
# Required to use MSVC with Ninja
52+
- uses: ilammy/msvc-dev-cmd@v1.13.0
53+
54+
- name: Build wheel
55+
uses: pypa/cibuildwheel@v3.3.1
56+
env:
57+
CIBW_TEST_COMMAND: "python -m pytest {project}/LayerDM -m runtime --verbose"
58+
with:
59+
package-dir: LayerDM
60+
output-dir: wheelhouse
61+
62+
- name: Build wheel SDK
63+
uses: pypa/cibuildwheel@v3.3.1
64+
env:
65+
CIBW_TEST_COMMAND: "python -m pytest {project}/LayerDM -m sdk --verbose"
66+
with:
67+
package-dir: LayerDMSDK
68+
output-dir: wheelhouse
69+
70+
- name: Upload wheels
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: slicer_layer_md-${{ inputs.build-target }}
74+
path: |
75+
wheelhouse/slicer_layer_dm-*.whl
76+
wheelhouse/slicer_layer_dm_sdk-*.whl

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI Slicer Core
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
build-test:
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macos-15]
13+
py-abi: ["cp310"]
14+
include:
15+
# Python version to install on host
16+
- py-abi: cp310
17+
python-version: "3.10"
18+
# OS name to ciwheelbuild platform name
19+
- os: ubuntu-latest
20+
platform-tag: manylinux_2_28_x86_64
21+
build-target: "manylinux_x86_64"
22+
- os: windows-latest
23+
platform-tag: win_amd64
24+
build-target: "win_amd64"
25+
- os: macos-15
26+
platform-tag: macosx_11_0_arm64
27+
build-target: "macosx_arm64"
28+
uses: ./.github/workflows/build-wheels.yml
29+
with:
30+
os: ${{ matrix.os }}
31+
build-target: ${{ matrix.py-abi }}-${{ matrix.build-target }}
32+
python-version: ${{ matrix.python-version }}
33+
platform-tag: ${{ matrix.platform-tag }}

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
semantic-release:
7+
runs-on: ubuntu-latest
8+
environment:
9+
name: pypi
10+
url: https://pypi.org/p/trame-slicer
11+
permissions:
12+
id-token: write # IMPORTANT: mandatory for trusted publishing
13+
contents: write # IMPORTANT: mandatory for making GitHub Releases
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Python Semantic Release
22+
id: release
23+
uses: python-semantic-release/python-semantic-release@master
24+
with:
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
changelog: true
27+
build: false # build is too complex to be handled by semantic release
28+
29+
release-build:
30+
needs: [semantic-release]
31+
strategy:
32+
fail-fast: true
33+
matrix:
34+
os: [ubuntu-latest, windows-latest, macos-15]
35+
py-abi: ["cp310", "cp311", "cp312", "cp313"]
36+
include:
37+
# Python version to install on host
38+
- py-abi: cp310
39+
python-version: "3.10"
40+
- py-abi: cp311
41+
python-version: "3.11"
42+
- py-abi: cp312
43+
python-version: "3.12"
44+
- py-abi: cp313
45+
python-version: "3.13"
46+
# OS name to ciwheelbuild platform name
47+
- os: ubuntu-latest
48+
platform-tag: manylinux_2_28_x86_64
49+
build-target: "manylinux_x86_64"
50+
- os: windows-latest
51+
platform-tag: win_amd64
52+
build-target: "win_amd64"
53+
- os: macos-15
54+
platform-tag: macosx_11_0_arm64
55+
build-target: "macosx_arm64"
56+
uses: ./.github/workflows/build-wheels.yml
57+
with:
58+
os: ${{ matrix.os }}
59+
build-target: ${{ matrix.py-abi }}-${{ matrix.build-target }}
60+
python-version: ${{ matrix.python-version }}
61+
platform-tag: ${{ matrix.platform-tag }}
62+
63+
upload-pypi:
64+
name: Push runtime wheel on PyPi
65+
needs: [release-build]
66+
runs-on: ubuntu-latest
67+
environment:
68+
name: pypi
69+
url: https://pypi.org/p/slicer-layer-dm
70+
permissions:
71+
id-token: write # IMPORTANT: mandatory for trusted publishing
72+
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Download all wheel artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
path: ./wheelhouse
80+
pattern: slicer_layer_dm-*
81+
merge-multiple: true # Flattens them into one directory
82+
83+
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
84+
- name: Publish package distributions to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1
86+
with:
87+
packages-dir: ./wheelhouse
88+
89+
upload-pypi-sdk:
90+
name: Push SDK wheel on PyPi
91+
needs: [release-build]
92+
runs-on: ubuntu-latest
93+
environment:
94+
name: pypi
95+
url: https://pypi.org/p/slicer-layer-dm-sdk
96+
permissions:
97+
id-token: write # IMPORTANT: mandatory for trusted publishing
98+
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Download all wheel artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: ./wheelhouse
106+
pattern: slicer_layer_dm_sdk-*
107+
merge-multiple: true # Flattens them into one directory
108+
109+
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
110+
- name: Publish package distributions to PyPI
111+
uses: pypa/gh-action-pypi-publish@release/v1
112+
with:
113+
packages-dir: ./wheelhouse

0 commit comments

Comments
 (0)