Files
MoltenVK/.github/workflows/CI.yml
Bill Hollings 1ab13c0656 Merge pull request #2513 from zfergus/cmake-build
Download External Dependencies and Build using CMake
2025-10-18 11:35:03 -04:00

207 lines
6.9 KiB
YAML

name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events
push:
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# See the following, which includes links to supported macOS versions, including supported Xcode versions
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
jobs:
build:
strategy:
matrix:
# Primary build on latest macOS and its default Xcode version
os: [ "macos-latest" ]
platform: [ "all", "macos", "ios" ]
upload_artifacts: [ true ]
select_xcode: [ false ]
private_api: [ false ]
include:
# macOS build with private APIs enabled.
- os: "macos-latest"
platform: "macos"
upload_artifacts: true
select_xcode: false
private_api: true
# Legacy build. Up to 3 versions behind latest (or beta).
- os: "macos-14"
xcode: "15.0.1"
platform: "macos"
upload_artifacts: false
select_xcode: true
private_api: false
fail-fast: false
name: MoltenVK (Xcode ${{ matrix.xcode }} - ${{ matrix.platform }}${{ matrix.private_api && '-privateapi' || '' }})
runs-on: ${{ matrix.os }}
env:
XCODE_DEV_PATH: "/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer"
ARTIFACT_TYPE: ${{ matrix.platform }}${{ matrix.private_api && '-privateapi' || '' }}
BUILD_ARGUMENTS: ${{ matrix.platform }} ${{ matrix.private_api && 'MVK_USE_METAL_PRIVATE_API=1' || '' }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Python 3.12 removed distutils, which is used by glslang::update_glslang_sources.py called from fetchDependencies
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: List available Xcode versions
run: ls /Applications | grep Xcode
- name: Select Xcode version
if: matrix.select_xcode == true
run: sudo xcode-select -switch "${XCODE_DEV_PATH}"
- name: Prep
id: prep
run: |
echo "Get Xcode version info"
XCODE_VERSION="$(xcodebuild -version)"
echo "${XCODE_VERSION}"
XCODE_VERSION="$(echo "${XCODE_VERSION}" | tr '\t\r\n ' '_')"
echo "${XCODE_VERSION}"
echo "XCODE_VERSION=${XCODE_VERSION}" >> $GITHUB_OUTPUT
- name: Cache Dependencies
id: cache-dependencies
if: success() && !(github.event_name == 'push' && contains(github.ref, 'refs/tags/')) # never cache dependencies for pushed tags
uses: actions/cache@v3
with:
path: |
External/build
!External/build/Intermediates
key: ${{ runner.os }}-${{ steps.prep.outputs.XCODE_VERSION }}-${{ matrix.platform }}-${{ hashFiles('fetchDependencies','ExternalRevisions/**','ExternalDependencies.xcodeproj/**','Scripts/**') }}
- name: Fetch Dependencies (Use Built Cache)
if: steps.cache-dependencies.outputs.cache-hit == 'true'
run: |
./fetchDependencies -v --none
- name: Fetch Dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
./fetchDependencies -v --${{ matrix.platform }}
- name: Output Dependency Build Logs on Failure
if: failure()
run: cat "dependenciesbuild.log"
- name: Build MoltenVK
run: |
make ${BUILD_ARGUMENTS}
- name: Output MoltenVK Build Logs on Failure
if: failure()
run: |
if [ -f "xcodebuild.log" ]; then
cat "xcodebuild.log"
fi
- name: Tar Artifacts
if: success() && matrix.upload_artifacts == true
# See: https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files
# To reduce artifact size, don't include any stand-alone shader converter binaries.
run: |
rm -rf Package/Release/MoltenVKShaderConverter
tar -C Package -s/Release/MoltenVK/ -cvf "MoltenVK-${ARTIFACT_TYPE}.tar" Release/
- name: Upload Artifacts
if: success() && matrix.upload_artifacts == true
uses: actions/upload-artifact@v4
with:
name: "MoltenVK-${{ env.ARTIFACT_TYPE }}"
path: "MoltenVK-${{ env.ARTIFACT_TYPE }}.tar"
build_cmake:
strategy:
matrix:
# Primary build on latest macOS and its default Xcode version
os: [ "macos-latest" ]
# platform: [ "all", "macos", "ios" ]
config: [Debug, Release]
fail-fast: false
name: 'MoltenVK (Cmake - ${{ matrix.config }})'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Dependencies
if: runner.os == 'macOS'
run: |
brew install ccache
echo 'CACHE_PATH=~/Library/Caches/ccache' >> "$GITHUB_ENV"
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2.0.0
id: cpu-cores
- name: Cache Build
id: cache-build
uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-${{ matrix.config }}-cache
- name: Prepare ccache
run: |
ccache --max-size=1.0G
ccache -V && ccache --show-config
ccache --show-stats && ccache --zero-stats
- name: Configure
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.config }}
- name: Build
run: |
cmake --build build -j ${{ steps.cpu-cores.outputs.count }}
ccache --show-stats
release:
name: 'Release'
needs: [build]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: ncipollo/release-action@v1
with:
# Allow updating existing releases if the workflow is triggered by release creation or re-run.
allowUpdates: true
# When the release is updated, delete the existing artifacts for replacement.
removeArtifacts: true
# If a release is being replaced, omit updating the name and body.
# Allows for creating a release and filling these in before the workflow runs.
# Then, the workflow will populate the release with the artifacts.
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
# Upload all MoltenVK CI artifacts as release assets.
artifacts: "MoltenVK*/*"
artifactErrorsFailBuild: true