Linux and MacOS workflows #17
This file contains hidden or 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
# Copyright 2025 The Khronos Group Inc. | |
# SPDX-License-Identifier: Apache-2.0 | |
name: KTX-Software Linux CI | |
# Seems no way to avoid duplicating this on logic in each .yml file. | |
# See https://github.com/actions/starter-workflows/issues/245. | |
on: | |
# Trigger the workflow on a pull request, | |
pull_request: | |
push: | |
# And on pushes to main, which will occur when a PR is merged. | |
branches: | |
- main | |
# Also trigger on push of release tags to any branch. Useful | |
# for testing release builds before merging to main. | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-*' | |
paths-ignore: | |
- .appveyor.yml | |
- .github/workflows/android.yml | |
- .github/workflows/check-mkvk.yml | |
- .github/workflows/docs.yml | |
- .github/workflows/formatting.yml | |
- .github/workflows/publish-pyktx.yml | |
- .github/workflows/windows.yml | |
- .travis.yml | |
- README.md | |
- CODE_OF_CONDUCT.md | |
- CONTRIBUTING.md | |
- LICENSE.md | |
- LICENSES | |
- RELEASE_NOTES.md | |
- REUSE.toml | |
- install-gitconfig* | |
# Allow manual trigger | |
workflow_dispatch: | |
jobs: | |
#formatting: | |
# uses: ./.github/workflows/formatting.yml | |
macos-linux: | |
# Shortcircuit and don't burn CI time when formatting will reject | |
#needs: formatting | |
strategy: | |
matrix: | |
os: [ macos-13 ] | |
generator: [ Xcode ] | |
arch: [ x86_64 ] | |
vk_sdk_ver: ['1.3.290.0'] | |
options: [ | |
{config: 'Debug,Release', platform: macOS, | |
doc: ON, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: ON, | |
package: YES, sse: ON, opencl: OFF}, | |
# {config: Release, platform: macOS, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: ON, opencl: ON}, | |
# {config: Release, platform: macOS, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: ON}, | |
# {config: Release, platform: macOS, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: OFF} | |
] | |
#include: | |
#- os: macos-latest | |
# generator: Xcode | |
# arch: arm64 | |
# vk_sdk_ver: '1.3.290.0' | |
# options: { | |
# config: Release, platform: macOS, | |
# doc: ON, jni: ON, loadtests: OpenGL+Vulkan, py: OFF, tests: OFF, tools: ON, tools_cts: OFF, | |
# package: YES, sse: ON, opencl: OFF | |
# } | |
#- os: macos-latest | |
# generator: Xcode | |
# arch: arm64 | |
# vk_sdk_ver: '1.3.290.0' | |
# options: { | |
# config: Release, platform: macOS, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tests: OFF, tools: OFF, tools_cts: OFF, | |
# sse: ON, opencl: ON | |
# } | |
#- os: macos-latest | |
# generator: Xcode | |
# arch: arm64 | |
# vk_sdk_ver: '1.3.290.0' | |
# options: { | |
# config: Release, platform: macOS, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tests: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: ON | |
# } | |
#- os: macos-latest | |
# generator: Xcode | |
# arch: arm64 | |
# vk_sdk_ver: '1.3.290.0' | |
# options: { | |
# config: Release, platform: macOS, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tests: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: OFF | |
# } | |
#- os: macos-latest | |
# generator: Xcode | |
# # note: arch was missing from travis.yml for iOS case | |
# arch: arm64 | |
# vk_sdk_ver: '1.3.290.0' | |
# options: { | |
# config: Release, platform: iOS, | |
# doc: OFF, jni: OFF, loadtests: OpenGL+Vulkan, py: OFF, tests: OFF, tools: OFF, tools_cts: OFF, | |
# package: YES, sse: OFF, opencl: OFF | |
# } | |
## Linux matrix elements | |
#- os: ubuntu-22.04 | |
# check_mkvk: NO | |
# check_reuse: ONLY | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: gcc | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Debug, | |
# doc: OFF, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: ON, | |
# sse: ON, opencl: OFF | |
# } | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: gcc | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Release, | |
# doc: ON, jni: ON, loadtests: OpenGL+Vulkan, py: ON, tools: ON, tools_cts: ON, | |
# package: YES, sse: ON, opencl: OFF | |
# } | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: arm64 | |
# compiler: gcc | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Release, | |
# doc: ON, jni: ON, loadtests: OpenGL, py: ON, tools: ON, tools_cts: ON, | |
# package: YES, sse: OFF, opencl: OFF | |
# } | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: gcc | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Release, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: ON, opencl: ON | |
# } | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: gcc | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Release, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: ON | |
# } | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: gcc | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Release, | |
# doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: OFF | |
# } | |
## WASM | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: clang | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Debug, | |
# doc: OFF, jni: OFF, loadtests: OpenGL, py: OFF, tools: OFF, tools_cts: OFF, | |
# sse: OFF, opencl: OFF, wasm: ON | |
# } | |
#- os: ubuntu-22.04 | |
# generator: Ninja | |
# arch: x86_64 | |
# compiler: clang | |
# vk_sdk_ver: '1.3.290' | |
# options: { | |
# config: Release, | |
# doc: OFF, jni: OFF, loadtests: OpenGL, py: OFF, tools: OFF, tools_cts: OFF, | |
# package: YES, sse: OFF, opencl: OFF, wasm: ON | |
# } | |
runs-on: ${{ matrix.os }} | |
env: | |
GIT_LFS_SKIP_SMUDGE: 1 | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
BUILD_DIR: build | |
REL_DESC_FILE: "build/rel_desc.md" | |
# Map test matrix elements to environmental variables, so that scripts launched from CI scripts may react to them. | |
# Some matrix variables have defaults if unspecified by the matrix | |
CMAKE_GEN: ${{ matrix.generator }} | |
CHECK_MKVK: ${{ matrix.check_mkvk && matrix.check_mkvk || 'NO' }} | |
CHECK_REUSE: ${{ matrix.check_reuse && matrix.check_reuse || 'NO' }} | |
CONFIGURATION: ${{ matrix.options.config }} | |
PLATFORM: ${{ matrix.options.platform }} | |
FEATURE_DOC: ${{ matrix.options.doc }} | |
FEATURE_JNI: ${{ matrix.options.jni }} | |
FEATURE_LOADTESTS: ${{ matrix.options.loadtests }} | |
FEATURE_PY: ${{ matrix.options.py }} | |
FEATURE_TESTS: ${{ matrix.options.tests && matrix.options.tests || 'ON' }} | |
FEATURE_TOOLS: ${{ matrix.options.tools }} | |
FEATURE_TOOLS_CTS: ${{ matrix.options.tools_cts }} | |
PACKAGE: ${{ matrix.options.package || matrix.options.package || 'NO' }} | |
DEPLOY_DOCS: ${{ matrix.options.deploy_docs || matrix.options.deploy_docs || 'NO' }} | |
SUPPORT_OPENCL: ${{ matrix.options.opencl }} | |
SUPPORT_SSE: ${{ matrix.options.sse }} | |
WASM_BUILD: ${{ matrix.options.wasm && matrix.options.wasm || 'OFF' }} | |
WERROR: ${{ matrix.options.werror && matrix.options.werror || 'ON' }} | |
# CC Handled by job step | |
# CXX Handled by job step | |
PYTHON_DIST_DIR: interface/python_binding/dist | |
VULKAN_SDK_VER: ${{ matrix.vk_sdk_ver }} | |
# This is just to tell the Vulkan install script where to install. | |
# NOTE: Hardcoded $HOME expansion, due to 'env' context being unavailble in env: | |
VULKAN_INSTALL_DIR: /Users/runner/VulkanSDK/${{ matrix.vk_sdk_ver }} | |
VULKAN_SDK: /Users/runner/VulkanSDK/${{ matrix.vk_sdk_ver }}/macOS | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Fetch all history to make sure tags are | |
# included (used for version creation) | |
fetch-depth: 0 | |
- name: Set compiler (linux) | |
if: runner.os == 'Linux' | |
run: | | |
if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
echo "CC=gcc" >> $GITHUB_ENV | |
echo "CXX=g++" >> $GITHUB_ENV | |
elif [ "${{ matrix.compiler }}" = "clang" ]; then | |
echo "CC=clang" >> $GITHUB_ENV | |
echo "CXX=clang++" >> $GITHUB_ENV | |
else | |
echo "Unknown compiler toolchain set" | |
exit 1 | |
fi | |
- name: before_install | |
run: | | |
echo -n "Running on the following GitHub Actions CI runner: " && uname -a | |
echo -n "CMake version on the runner is " && cmake --version | |
echo -e "machine github.com\n login $GITHUB_TOKEN" >> ~/.netrc # Prevent rate limiting on Git LFS. | |
cat ~/.netrc | |
case "${RUNNER_OS:-Linux}" in | |
Linux) | |
if [ "$WASM_BUILD" = "YES" ]; then | |
# Need to set uid/gid because, unlike when running docker locally, | |
# /src ends up being owned by the uid/gid running this script and | |
# the recent fix for CVE-2022-24765 in Git causes Git to error | |
# when the repo owner differs from the user. For details see | |
# https://github.blog/2022-04-12-git-security-vulnerability-announced/ | |
docker run -dit --name emscripten --user "$(id -u):$(id -g)" -v $(pwd):/src emscripten/emsdk bash | |
elif [ "$CHECK_REUSE" != "ONLY" -a "$CHECK_MKVK" != "ONLY" ]; then | |
sudo apt-get update | |
fi | |
;; | |
macOS) | |
if [[ -n "$FEATURE_LOADTESTS" && "$FEATURE_LOADTESTS" != "OFF" ]]; then | |
# Install vcpkg. | |
pushd $HOME | |
git clone https://github.com/microsoft/vcpkg | |
cd vcpkg && ./bootstrap-vcpkg.sh -disableMetrics && echo "VCPKG_ROOT=`pwd`" >> $GITHUB_ENV | |
popd | |
fi | |
;; | |
esac | |
- name: install | |
run: | | |
case "${RUNNER_OS:-Linux}" in | |
Linux) | |
if [ "$CHECK_REUSE" = "YES" -o "$CHECK_REUSE" = "ONLY" ]; then | |
set -e # because the if below swallows a bad exit status. | |
# reuse available via `apt install reuse` is very old: 0.14.0. | |
# Therefore install via pip. Version today, 2024.7.9, is 4.0.3. | |
pip3 install reuse | |
set +e | |
fi | |
if [ "$CHECK_REUSE" != "ONLY" -a "$CHECK_MKVK" != "ONLY" -a "$WASM_BUILD" != "YES" ]; then | |
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV | |
echo "JAVA_HOME = $JAVA_HOME" | |
echo "/usr/lib/jvm" | |
ls -l /usr/lib/jvm | |
echo "/usr/local/lib/jvm" | |
ls -l /usr/local/lib/jvm | |
./scripts/install_linux.sh | |
fi | |
;; | |
macOS) | |
if [ "$CHECK_REUSE" != "ONLY" -a "$CHECK_MKVK" != "ONLY" ]; then | |
if [ "$FEATURE_DOC" = "ON" ]; then | |
brew install --formula doxygen | |
brew install graphviz | |
fi | |
env | |
./scripts/install_macos.sh | |
fi | |
;; | |
esac | |
- name: Set up Python 3.11 | |
if: matrix.options.py == 'ON' && matrix.check_mkvk != 'ONLY' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11.4' | |
- name: before_script | |
run: | | |
case "${RUNNER_OS:-Linux}" in | |
Linux) | |
;; | |
macOS) | |
./scripts/before_build_macos.sh | |
;; | |
esac | |
if [ "$FEATURE_TOOLS_CTS" = "ON" ]; then | |
git submodule update --init --recursive tests/cts | |
fi | |
# Make sure embedded dates are correct. | |
./install-gitconfig.sh | |
scripts/smudge_date.sh | |
- name: script | |
run: | | |
set -e # Instead of trying to chain everything together with && | |
# otherwise subsequent commands will swallow bad exit status. | |
case "${RUNNER_OS:-Linux}" in | |
Linux) | |
if [ "$CHECK_REUSE" = "YES" -o "$CHECK_REUSE" = "ONLY" ]; then | |
echo "Calling reuse lint." | |
reuse lint | |
fi | |
if [ "$CHECK_REUSE" != "ONLY" -a "$CHECK_MKVK" != "ONLY" ]; then | |
if [ "$WASM_BUILD" = "YES" ]; then | |
./scripts/build_wasm_docker.sh | |
else | |
./scripts/build_linux.sh | |
fi | |
fi | |
;; | |
macOS) | |
if [ "$CHECK_REUSE" != "ONLY" -a "$CHECK_MKVK" != "ONLY" ]; then | |
if [ "$PLATFORM" = "macOS" ]; then | |
./scripts/build_macos.sh | |
./scripts/notarize.sh $BUILD_DIR/KTX-Software-*.pkg $APPLE_ID $DEVELOPMENT_TEAM $ALTOOL_PASSWORD && export NOTARIZED="true" | |
else | |
./scripts/build_ios.sh | |
fi | |
fi | |
;; | |
esac | |
if [ "$CHECK_MKVK" = "ONLY" ]; then | |
scripts/check_mkvk.sh | |
fi | |
if [ "$DEPLOY_DOCS" = "YES" ]; then | |
# Some files in the pyktx docs have an _ prefix so Jekyll will | |
# not copy them from the gh-pages branch to the website. This | |
# file says no Jekyll files here. Treat all as ordinary files. | |
touch $BUILD_DIR/docs/html/.nojekyll | |
fi | |
set +e | |
- name: before_deploy | |
run: | | |
gem install octokit:'~> 4.15.0' mime-types | |
if [ ! -f $REL_DESC_FILE -a -f RELEASE_NOTES.md ]; then | |
# Remove lines that are unnecessary in the context of a GitHub | |
# release description. | |
awk '/^Release Notes/,/^## Version/ { next } | |
! /<!-- Copyright/ && ! /<!-- SPDX/ { print }' RELEASE_NOTES.md \ | |
> $REL_DESC_FILE | |
# dpl v2 alternative | |
#RELNOTES=$(awk '/^Release Notes/,/^## Version/ { next } | |
# ! /<!-- Copyright/ && ! /<!-- SPDX/ { print }' RELEASE_NOTES.md) | |
fi | |
- name: Get KTX version | |
if: matrix.options.package == 'YES' | |
id: ktx-version | |
run: | | |
KTX_VERSION=`cat $BUILD_DIR/ktx.version` | |
echo "KTX_VERSION=$KTX_VERSION" >> $env:GITHUB_ENV | |
# For these artifact uploads, need to take care that only one CLangCL | |
# "package" job for each architecture produces artifacts. A second | |
# job would attempt to upload a same-named artifact. | |
- name: Upload artifact Install Package | |
if: matrix.options.package == 'YES' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: KTX-Software-${{env.KTX_VERSION}}-${{runner.os}}-${{matrix.arch}} | |
path: ${{env.BUILD_DIR}}/KTX-Software-*-* | |
compression-level: 0 # Installer already compressed. | |
- name: Upload artifact pyktx | |
if: matrix.options.package == 'YES' && matrix.options.py == 'ON' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pyktx-${{env.KTX_VERSION}}-${{runner.os}}-${{matrix.arch}} | |
path: ${{env.BUILD_DIR}}/${{env.PYTHON_DIST_DIR}} | |
- name: Upload to Release | |
uses: softprops/action-gh-release@v2 | |
if: matrix.options.package == 'YES' && github.event_name == 'push' && github.ref_type == 'tag' | |
with: | |
draft: true | |
prerelease: true | |
files: | | |
${{env.BUILD_DIR}}/KTX-Software-*-* | |
${{env.BUILD_DIR}}/${{env.PYTHON_DIST_DIR}}/pyktx-* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |