3D Particle System #334
Workflow file for this run
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
name: CMake on multiple platforms | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | |
fail-fast: false | |
# Set up a matrix to run the following 4 configurations: | |
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | |
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> | |
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | |
# 4. <macOS, Release, latest Clang compiler toolchain on the default runner image, default generator> | |
# | |
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | |
matrix: | |
os: ['ubuntu-22.04', windows-latest, macos-latest] | |
build_type: [Release] | |
c_compiler: [gcc, clang, cl] | |
include: | |
- os: windows-latest | |
c_compiler: cl | |
cpp_compiler: cl | |
- os: 'ubuntu-22.04' | |
c_compiler: gcc | |
cpp_compiler: g++ | |
- os: 'ubuntu-22.04' | |
c_compiler: clang | |
cpp_compiler: clang++ | |
- os: macos-latest | |
c_compiler: clang | |
cpp_compiler: clang++ | |
exclude: | |
- os: windows-latest | |
c_compiler: gcc | |
- os: windows-latest | |
c_compiler: clang | |
- os: 'ubuntu-22.04' | |
c_compiler: cl | |
- os: macos-latest | |
c_compiler: gcc | |
- os: macos-latest | |
c_compiler: cl | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set reusable strings | |
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
- name: Install dependencies (Ubuntu) | |
if: ${{ matrix.os == 'ubuntu-22.04' }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libwayland-dev libxkbcommon-dev libgl1-mesa-dev | |
- name: Prepare Vulkan SDK | |
uses: humbletim/install-vulkan-sdk@main | |
with: | |
version: 1.4.309.0 | |
cache: true | |
- name: Configure CMake | |
run: > | |
cmake -B ${{ steps.strings.outputs.build-output-dir }} | |
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
-S ${{ github.workspace }} | |
- name: Build | |
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | |
- name: Test | |
working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: ctest --build-config ${{ matrix.build_type }} | |
- name: Copy Shared Libraries | |
shell: bash | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
cp -L $VULKAN_SDK/lib/libvulkan* ${{ steps.strings.outputs.build-output-dir }}/bin/ | |
cp -L /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ${{ steps.strings.outputs.build-output-dir }}/bin/ | |
cp -L /lib/x86_64-linux-gnu/libgcc_s.so.1 ${{ steps.strings.outputs.build-output-dir }}/bin/ | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
cp $VULKAN_SDK/lib/libMoltenVK.dylib ${{ steps.strings.outputs.build-output-dir }}/bin/ | |
cp $VULKAN_SDK/lib/libvulkan.* ${{ steps.strings.outputs.build-output-dir }}/bin/ | |
fi | |
- name: Zip Artifacts | |
shell: pwsh | |
run: | | |
$buildDir = "${{ steps.strings.outputs.build-output-dir }}/bin" | |
$zipName = "${{ matrix.os }}-${{ matrix.c_compiler }}-release.zip" | |
cd $buildDir | |
if ($IsWindows) { | |
# Use 7-zip on Windows | |
7z a -tzip $zipName ./* | |
} else { | |
# Use native zip on Linux/macOS | |
zip -r $zipName ./* | |
} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-${{ matrix.c_compiler }}-binaries | |
path: | | |
${{ steps.strings.outputs.build-output-dir }}/bin/*.zip | |
retention-days: 5 | |
release: | |
needs: build | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get version from CMakeLists.txt | |
id: get_version | |
run: | | |
VERSION=$(grep -oP 'project\([^)]*VERSION\s+\K[0-9.]+' CMakeLists.txt || echo "0.1.0") | |
COMMIT_SHA="${{ github.sha }}" | |
SHORT_SHA="${COMMIT_SHA:0:7}" | |
echo "version=$VERSION-$SHORT_SHA" >> $GITHUB_OUTPUT | |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: List downloaded artifacts | |
run: find artifacts -type f | sort | |
- name: Create Release | |
id: create_release | |
uses: softprops/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
name: Release ${{ steps.get_version.outputs.version }} (${{ steps.get_version.outputs.date }}) | |
tag_name: v${{ steps.get_version.outputs.version }} | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
files: | | |
artifacts/**/*.zip | |
artifacts/**/*.tar.gz |