add gnu Windows/iOS/Android builds and improve continuous delivery wo… #226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow builds the binaries, which are released when a "v*" tag is pushed. | |
# These also include builds for 32bit platforms, which are thus tested as a side-effect. | |
# This workflow only runs on a push to master and when pushing a version-tag. | |
# | |
# The Linux builds are performed on a "manylinux" container. This container | |
# is designed such that that the resulting binary has minimal dependencies on system | |
# libraries, and thus works on as many linuxes as possible. It's a thing from the | |
# Python world, but generally useful. | |
# | |
# Each target (operating system + architecture) is built in grouped jobs by operating system. | |
# | |
# Each job should specify at least these env vars: | |
# * TARGET: used in makefile to do cargo build --target $TARGET | |
# * ARCHIVE_NAME: used by the makefile to package things up | |
# * WGPU_NATIVE_VERSION: is backed into the binary at compile time | |
# | |
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html for Rust build targets. | |
name: CD | |
env: | |
CACHE_SUFFIX: a | |
on: | |
workflow_dispatch: | |
push: | |
tags: ["v*"] | |
branches: [trunk, cd] | |
jobs: | |
# ----- | |
iOS: | |
# Config | |
name: release - ${{ matrix.name }} | |
runs-on: macos-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- name: iOS-aarch64 | |
target: aarch64-apple-ios | |
- name: iOS-aarch64-simulator | |
target: aarch64-apple-ios-sim | |
- name: iOS-x86_64-simulator | |
target: x86_64-apple-ios | |
env: | |
TARGET: ${{ matrix.target }} | |
ARCHIVE_NAME: wgpu-${{ matrix.name }} | |
steps: | |
# Common part (same for each build) | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set WGPU_NATIVE_VERSION | |
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
shell: bash | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Add iOS targets | |
run: rustup target add ${{ matrix.TARGET }} | |
- name: Setup caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: build-${{ matrix.TARGET }}-${{ matrix.CACHE_SUFFIX }} | |
# Build | |
- name: Build | |
run: make package | |
# Upload (same for each build) | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist | |
name: ${{ env.ARCHIVE_NAME }} | |
# ----- | |
android: | |
name: release - ${{ matrix.name }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- name: android-i686 | |
target: i686-linux-android | |
setup_env: | | |
set -x | |
ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.0.12077973 | |
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang | |
echo "CC=$CC" >> $GITHUB_ENV | |
echo "CXX=$CC++" >> $GITHUB_ENV | |
echo "CLANG_PATH=$CC" >> $GITHUB_ENV | |
echo "CARGO_TARGET_I686_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV | |
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV | |
- name: android-x86_64 | |
target: x86_64-linux-android | |
setup_env: | | |
set -x | |
ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.0.12077973 | |
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang | |
echo "CC=$CC" >> $GITHUB_ENV | |
echo "CXX=$CC++" >> $GITHUB_ENV | |
echo "CLANG_PATH=$CC" >> $GITHUB_ENV | |
echo "CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV | |
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV | |
- name: android-aarch64 | |
target: aarch64-linux-android | |
setup_env: | | |
set -x | |
ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.0.12077973 | |
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang | |
echo "CC=$CC" >> $GITHUB_ENV | |
echo "CXX=$CC++" >> $GITHUB_ENV | |
echo "CLANG_PATH=$CC" >> $GITHUB_ENV | |
echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV | |
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV | |
- name: android-armv7 | |
target: armv7-linux-androideabi | |
setup_env: | | |
set -x | |
ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.0.12077973 | |
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang | |
echo "CC=$CC" >> $GITHUB_ENV | |
echo "CXX=$CC++" >> $GITHUB_ENV | |
echo "CLANG_PATH=$CC" >> $GITHUB_ENV | |
echo "CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$CC" >> $GITHUB_ENV | |
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV | |
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV | |
env: | |
TARGET: ${{ matrix.target }} | |
ARCHIVE_NAME: wgpu-${{ matrix.name }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set WGPU_NATIVE_VERSION | |
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
shell: bash | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
target: ${{ matrix.target }} | |
- name: Setup caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: build-${{ matrix.TARGET }}-${{ matrix.CACHE_SUFFIX }} | |
- name: Setup Environment | |
run: ${{ matrix.setup_env }} | |
- name: Build | |
run: make package | |
shell: bash | |
# Upload (same for each build) | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist | |
name: ${{ env.ARCHIVE_NAME }} | |
# ----- | |
linux: | |
# Config | |
name: release - ${{ matrix.name }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- name: linux-x86_64 | |
target: x86_64-unknown-linux-gnu | |
image: manylinux_2_28_x86_64 | |
- name: linux-aarch64 | |
target: aarch64-unknown-linux-gnu | |
image: manylinux_2_28_aarch64 | |
env: | |
TARGET: ${{ matrix.target }} | |
ARCHIVE_NAME: wgpu-${{ matrix.name }} | |
TOOLCHAIN: stable-${{ matrix.target }} | |
IMAGE: ${{ matrix.image }} | |
steps: | |
# Common part (same for nearly each build) | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set WGPU_NATIVE_VERSION | |
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
shell: bash | |
# prepare qemu for cross-compilation | |
- name: Set up QEMU | |
if: matrix.image == 'manylinux_2_28_aarch64' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
# Build | |
- name: Build | |
run: | | |
CID=$(docker create -t -w /tmp/wgpu-native -v $PWD:/tmp/src:ro -e TARGET -e ARCHIVE_NAME -e WGPU_NATIVE_VERSION quay.io/pypa/$IMAGE bash -c "\ | |
cp -r /tmp/src/. . && \ | |
rm -rf ./dist && \ | |
export PATH=/root/.cargo/bin:\$PATH && \ | |
export USER=root && \ | |
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none && \ | |
rustup toolchain install --no-self-update $TOOLCHAIN && \ | |
rustup default $TOOLCHAIN && \ | |
dnf install clang-devel zip -y && \ | |
make package") | |
docker start -ai $CID | |
mkdir -p dist | |
docker cp $CID:/tmp/wgpu-native/dist/. dist/. | |
docker rm $CID | |
# Upload (same for each build) | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist | |
name: ${{ env.ARCHIVE_NAME }} | |
# ----- | |
windows: | |
# Config | |
name: release - ${{ matrix.name }} | |
runs-on: windows-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- name: windows-x86_64 - MSVC | |
target: x86_64-pc-windows-msvc | |
archive-name: windows-x86_64-msvc | |
toolchain: stable-msvc | |
- name: windows-i686 - MSVC | |
target: i686-pc-windows-msvc | |
archive-name: windows-i686-msvc | |
toolchain: stable-msvc | |
- name: windows-aarch64 - MSVC | |
target: aarch64-pc-windows-msvc | |
archive-name: windows-aarch64-msvc | |
toolchain: stable-msvc | |
- name: windows-x86_64 - GNU | |
target: x86_64-pc-windows-gnu | |
archive-name: windows-x86_64-gnu | |
toolchain: stable-gnu | |
env: | |
TARGET: ${{ matrix.target }} | |
ARCHIVE_NAME: wgpu-${{ matrix.archive-name }} | |
steps: | |
# Common part (same for each build) | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set WGPU_NATIVE_VERSION | |
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
shell: bash | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
targets: ${{ env.TARGET }} | |
- name: Setup caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: build-${{ env.TARGET }}-${{ env.CACHE_SUFFIX }} | |
# Build | |
- name: Build | |
run: make package | |
shell: bash | |
# Upload (same for each build) | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist | |
name: ${{ env.ARCHIVE_NAME }} | |
# ----- | |
macos: | |
# Config | |
name: release - ${{ matrix.name }} | |
runs-on: macos-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- name: macos-x86_64 | |
target: x86_64-apple-darwin | |
archive-name: macos-x86_64 | |
- name: macos-aarch64 | |
target: aarch64-apple-darwin | |
archive-name: macos-aarch64 | |
env: | |
TARGET: ${{ matrix.target }} | |
ARCHIVE_NAME: wgpu-${{ matrix.archive-name }} | |
MACOSX_DEPLOYMENT_TARGET: "10.13" | |
RUSTFLAGS: "-C link-args=-Wl,-install_name,@rpath/libwgpu_native.dylib" | |
steps: | |
# Common part (same for each build) | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set WGPU_NATIVE_VERSION | |
run: echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
shell: bash | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ env.TARGET }} | |
- name: Setup caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: build-${{ env.TARGET }}-${{ env.CACHE_SUFFIX }} | |
# Build | |
- name: Build | |
run: make package | |
# Upload (same for each build) | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist | |
name: ${{ env.ARCHIVE_NAME }} | |
# Create a Github release and upload the binary libs that we just built. | |
# There should be a release and debug build for each platform (win32, win64, MacOS64, Linux64), | |
# plus a file containing the commit sha. | |
publish: | |
name: Publish Github release | |
needs: | |
- iOS | |
- android | |
- linux | |
- windows | |
- macos | |
runs-on: ubuntu-latest | |
if: success() && contains(github.ref, 'tags/v') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set version (which gets used as release name) | |
run: | | |
echo "WGPU_NATIVE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
shell: bash | |
- name: Download assets | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
- name: Create commit-sha file | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
run: | | |
echo $GITHUB_SHA > dist/commit-sha | |
- name: Upload Release Assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.WGPU_NATIVE_VERSION }} | |
name: ${{ env.WGPU_NATIVE_VERSION }} | |
files: | | |
dist/**/*.zip | |
dist/commit-sha | |
body: | | |
Autogenerated binary modules. | |
The Linux builds are built on AlmaLinux 8 [manylinux_2_28](https://github.com/pypa/manylinux#manylinux). | |
The MacOS builds target MacOS 10.13 High Sierra and up. | |
The Windows builds are built using MSVC on all architectures and GNU on x64. | |
draft: false | |
prerelease: false |