Skip to content

Refactor and fix cd #11

Refactor and fix cd

Refactor and fix cd #11

Workflow file for this run

name: CD
on:
workflow_dispatch:
push:
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
# The release builds are done for the platforms that we want to build wheels for.
# We build wheels, test them, and then upload the wheel as an artifact.
release-builds:
name: Build wheels on ${{ matrix.os }}
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip wheel setuptools twine
- name: Build wheels
# Use v2.16, v2.20 fails the osx builds
uses: pypa/[email protected]
env:
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64
CIBW_ARCHS_LINUX: x86_64
CIBW_SKIP: cp39-musllinux_x86_64
with:
output-dir: dist
- name: Twine check
run: |
twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ matrix.os }}-build
# These release builds uses QEMU so that we can build wheels for arm64.
# We build wheels and upload the wheel as an artifact, but we don't test them here.
qemu-release-builds:
name: Build wheels on ubuntu-latest with QEMU
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
CIBW_ARCHS_LINUX: aarch64
CIBW_SKIP: cp39-musllinux_aarch64
with:
output-dir: dist
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
path: dist
name: qemu-build
sdist-build:
name: Build sdist
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install -U -r dev-requirements.txt
- name: Create source distribution
run: |
python setup.py sdist
- name: Test sdist
shell: bash
run: |
rm -rf ./wgpu
pushd $HOME
pip install $GITHUB_WORKSPACE/dist/*.tar.gz
popd
# don't run tests, we just want to know if the sdist can be installed
pip uninstall -y wgpu
git reset --hard HEAD
- name: Twine check
run: |
twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
path: dist
name: sdist-build
publish:
name: Publish to Github and Pypi
runs-on: ubuntu-latest
needs: [release-builds, qemu-release-builds, sdist-build]
if: success() && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Download assets
uses: actions/download-artifact@v4
with:
path: dist
- name: Set version from git ref
run: echo "WGPU_PY_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.WGPU_PY_VERSION }}
name: ${{ env.WGPU_PY_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
files: |
dist/**/*.tar.gz
dist/**/*.whl
body: |
Autogenerated binary wheels that include wgpu-native.
See [the changelog](https://github.com/pygfx/wgpu-py/blob/main/CHANGELOG.md) for details.
draft: false
prerelease: false
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}