Skip to content

Commit b3f2ace

Browse files
authored
Refactor and fix cd (#570)
* Refactor and fix cd * add cd * tweak * mmm * try older version * fix * fix artifacts and set-output * try * mac-latest also builds x86 * turn it on
1 parent 730fe86 commit b3f2ace

File tree

3 files changed

+180
-173
lines changed

3 files changed

+180
-173
lines changed

.github/workflows/cd.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CD
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
14+
# The release builds are done for the platforms that we want to build wheels for.
15+
# We build wheels, test them, and then upload the wheel as an artifact.
16+
release-builds:
17+
name: Build wheels on ${{ matrix.os }}
18+
timeout-minutes: 10
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ubuntu-latest, windows-latest, macos-latest]
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.9'
30+
- name: Install dev dependencies
31+
run: |
32+
python -m pip install --upgrade pip wheel setuptools twine
33+
- name: Build wheels
34+
# Use v2.16, v2.20 fails the osx builds
35+
uses: pypa/[email protected]
36+
env:
37+
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64
38+
CIBW_ARCHS_LINUX: x86_64
39+
CIBW_SKIP: cp39-musllinux_x86_64
40+
with:
41+
output-dir: dist
42+
- name: Twine check
43+
run: |
44+
twine check dist/*
45+
- name: Upload distributions
46+
uses: actions/upload-artifact@v4
47+
with:
48+
path: dist
49+
name: ${{ matrix.os }}-build
50+
51+
# These release builds uses QEMU so that we can build wheels for arm64.
52+
# We build wheels and upload the wheel as an artifact, but we don't test them here.
53+
qemu-release-builds:
54+
name: Build wheels on ubuntu-latest with QEMU
55+
timeout-minutes: 10
56+
runs-on: ubuntu-latest
57+
strategy:
58+
fail-fast: false
59+
steps:
60+
- uses: actions/checkout@v4
61+
- name: Set up QEMU
62+
uses: docker/setup-qemu-action@v3
63+
with:
64+
platforms: arm64
65+
- name: Build wheels
66+
uses: pypa/[email protected]
67+
env:
68+
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
69+
CIBW_ARCHS_LINUX: aarch64
70+
CIBW_SKIP: cp39-musllinux_aarch64
71+
with:
72+
output-dir: dist
73+
- name: Upload distributions
74+
uses: actions/upload-artifact@v4
75+
with:
76+
path: dist
77+
name: qemu-build
78+
79+
sdist-build:
80+
name: Build sdist
81+
timeout-minutes: 5
82+
runs-on: ubuntu-latest
83+
strategy:
84+
fail-fast: false
85+
steps:
86+
- uses: actions/checkout@v4
87+
- name: Set up Python
88+
uses: actions/setup-python@v5
89+
with:
90+
python-version: '3.12'
91+
- name: Install dev dependencies
92+
run: |
93+
python -m pip install --upgrade pip
94+
pip install -U -r dev-requirements.txt
95+
- name: Create source distribution
96+
run: |
97+
python setup.py sdist
98+
- name: Test sdist
99+
shell: bash
100+
run: |
101+
rm -rf ./wgpu
102+
pushd $HOME
103+
pip install $GITHUB_WORKSPACE/dist/*.tar.gz
104+
popd
105+
# don't run tests, we just want to know if the sdist can be installed
106+
pip uninstall -y wgpu
107+
git reset --hard HEAD
108+
- name: Twine check
109+
run: |
110+
twine check dist/*
111+
- name: Upload distributions
112+
uses: actions/upload-artifact@v4
113+
with:
114+
path: dist
115+
name: sdist-build
116+
117+
publish:
118+
name: Publish to Github and Pypi
119+
runs-on: ubuntu-latest
120+
needs: [release-builds, qemu-release-builds, sdist-build]
121+
if: success() && startsWith(github.ref, 'refs/tags/v')
122+
steps:
123+
- uses: actions/checkout@v4
124+
- name: Set up Python
125+
uses: actions/setup-python@v5
126+
with:
127+
python-version: '3.12'
128+
- name: Download assets
129+
uses: actions/download-artifact@v4
130+
with:
131+
path: dist
132+
- name: Set version from git ref
133+
run: echo "WGPU_PY_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
134+
- name: Upload Release Assets
135+
uses: softprops/action-gh-release@v2
136+
with:
137+
tag_name: ${{ env.WGPU_PY_VERSION }}
138+
name: ${{ env.WGPU_PY_VERSION }}
139+
token: ${{ secrets.GITHUB_TOKEN }}
140+
files: |
141+
dist/**/*.tar.gz
142+
dist/**/*.whl
143+
body: |
144+
Autogenerated binary wheels that include wgpu-native.
145+
See [the changelog](https://github.com/pygfx/wgpu-py/blob/main/CHANGELOG.md) for details.
146+
draft: false
147+
prerelease: false
148+
- name: Publish to PyPI
149+
uses: pypa/gh-action-pypi-publish@v1
150+
with:
151+
user: __token__
152+
password: ${{ secrets.PYPI_PASSWORD }}

0 commit comments

Comments
 (0)