Skip to content

Commit

Permalink
Finalize and polish github workflows/CI
Browse files Browse the repository at this point in the history
  • Loading branch information
1runeberg committed Jul 18, 2024
1 parent 51872a8 commit b1147cc
Show file tree
Hide file tree
Showing 12 changed files with 604 additions and 239 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/_src_android_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# xrlib

name: _src_android_builds

on:
workflow_call:
inputs:
matrix-json:
description: 'Build matrix json'
required: true
type: string
build-as-static:
description: 'Whether to build as a static library (ON/OFF)'
required: true
type: string
export-artifacts:
description: 'Whether to export artifacts (ON/OFF)'
required: true
type: string


jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix: ${{ fromJson(inputs['matrix-json']) }}

steps:
- name: Checkout code
uses: actions/[email protected]
with:
submodules: recursive
fetch-depth: 1

- name: Get cmake-latest
uses: lukka/get-cmake@latest

- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: android-arm64-v8a-${{ matrix.build_type }}-c++_shared

- name: Configure CMake on Android (shared library)
if: ${{ inputs.build-as-static == 'OFF' }}
run: |
cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-D ANDROID_PLATFORM=33 \
-D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \
-D CMAKE_ANDROID_STL_TYPE=c++_shared \
-D ANDROID_NDK=$ANDROID_NDK_ROOT \
-D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_AS_STATIC=OFF \
-D ENABLE_XRVK=${{ matrix.enable_xrvk }} \
-D BUILD_TESTS=OFF \
-D UPDATE_DEPS=ON \
-D BUILD_WERROR=ON
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache

- name: Configure CMake on Android (static library)
if: ${{ inputs.build-as-static == 'ON' }}
run: |
cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-D ANDROID_PLATFORM=33 \
-D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \
-D CMAKE_ANDROID_STL_TYPE=c++_static \
-D ANDROID_NDK=$ANDROID_NDK_ROOT \
-D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_AS_STATIC=ON \
-D ENABLE_XRVK=${{ matrix.enable_xrvk }} \
-D BUILD_TESTS=OFF \
-D UPDATE_DEPS=ON \
-D BUILD_WERROR=ON
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache

- name: Build xrlib
run: cmake --build build/

- name: Upload build artifact
if: ${{ inputs.export-artifacts == 'ON' }}
uses: actions/upload-artifact@v4
with:
name: xrlib-static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }}
path: lib
102 changes: 102 additions & 0 deletions .github/workflows/_src_desktop_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# xrlib
# Vulkan is installed on the runner prior to compilation

name: _src_desktop_builds

on:
workflow_call:
inputs:
matrix-json:
description: 'Build matrix json'
required: true
type: string
build-as-static:
description: 'Whether to build as a static library (ON/OFF)'
required: true
type: string
export-artifacts:
description: 'Whether to export artifacts (ON/OFF)'
required: true
type: string


jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix: ${{ fromJson(inputs['matrix-json']) }}

steps:
- name: Checkout code
uses: actions/[email protected]
with:
submodules: recursive
fetch-depth: 1

- name: Archive source code
if: ${{ (inputs.export-artifacts == 'ON') && (matrix.os == 'windows-latest') && (inputs.build-as-static == 'OFF') && (matrix.enable_xrvk == 'ON') }}
uses: actions/upload-artifact@v4
with:
name: xrlib-source
path: ./

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Prepare Vulkan SDK
uses: humbletim/setup-vulkan-sdk@main
with:
vulkan-query-version: 1.3.204.0
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true

- name: Configure CMake on Linux
if: runner.os == 'Linux'
run: |
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-D CMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_AS_STATIC=${{ inputs.build-as-static }} \
-D ENABLE_XRVK=${{ matrix.enable_xrvk }} \
-S ${{ github.workspace }}
- name: Configure CMake on Windows
if: runner.os == 'Windows'
run: |
cmake -B ${{ steps.strings.outputs.build-output-dir }} `
-D CMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} `
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-D BUILD_AS_STATIC=${{ inputs.build-as-static }} `
-D ENABLE_XRVK=${{ matrix.enable_xrvk }} `
-S ${{ github.workspace }}
- name: Build xrlib
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Upload build artifact (windows dll & symbol exports)
if: ${{ inputs.export-artifacts == 'ON' && (matrix.os == 'windows-latest') && (inputs.build-as-static == 'OFF') }}
uses: actions/upload-artifact@v4
with:
name: xrlib-${{ matrix.os }}_compiler_${{ matrix.cpp_compiler }}_static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }}
path: |
bin
lib
- name: Upload build artifact (windows static)
if: ${{ inputs.export-artifacts == 'ON' && (matrix.os == 'windows-latest') && (inputs.build-as-static == 'ON') }}
uses: actions/upload-artifact@v4
with:
name: xrlib-${{ matrix.os }}_compiler_${{ matrix.cpp_compiler }}_static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }}
path: lib

- name: Upload build artifact (linux)
if: ${{ inputs.export-artifacts == 'ON' && (matrix.os == 'ubuntu-latest') }}
uses: actions/upload-artifact@v4
with:
name: xrlib-${{ matrix.os }}_compiler_${{ matrix.cpp_compiler }}_static_${{ inputs.build-as-static }}-xrvk_${{ matrix.enable_xrvk }}
path: lib
52 changes: 13 additions & 39 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,22 @@
# xrlib

name: Android builds [ arm64-v8a, Debug|Release ]
name: android-latest

on:
push:
branches: [ "**" ]
branches: ['**']
pull_request:
branches: [ "**" ]
branches: ['main']

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
build_type: [Debug, Release]

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: lukka/get-cmake@latest

- name: Setup ccache
uses: hendrikmuhs/[email protected]
jobs:
build-shared:
uses: ./.github/workflows/_src_android_builds.yml
with:
key: android-arm64-v8a-${{ matrix.build_type }}-c++_shared

- name: Configure CMake on Android
run: |
cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-D ANDROID_PLATFORM=26 \
-D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \
-D CMAKE_ANDROID_STL_TYPE=c++_shared \
-D ANDROID_NDK=$ANDROID_NDK_ROOT \
-D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D BUILD_TESTS=OFF \
-D UPDATE_DEPS=ON \
-D BUILD_WERROR=ON
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache

- run: cmake --build build/
matrix-json: >
{
"build_type": ["debug", "release"],
"enable_xrvk": ["ON", "OFF"]
}
build-as-static : "OFF"
export-artifacts: "OFF"
83 changes: 83 additions & 0 deletions .github/workflows/android_releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# xrlib

name: android-releases

on:
push:
tags:
- 'v*.*.*.*'


jobs:
build-shared:
uses: ./.github/workflows/_src_android_builds.yml
with:
matrix-json: >
{
"build_type": ["release"],
"enable_xrvk": ["ON", "OFF"]
}
build-as-static : "OFF"
export-artifacts: "ON"

build-static:
uses: ./.github/workflows/_src_android_builds.yml
with:
matrix-json: >
{
"build_type": ["release"],
"enable_xrvk": ["ON", "OFF"]
}
build-as-static : "ON"
export-artifacts: "ON"

package-release:
runs-on: ubuntu-latest
needs: [build-shared, build-static]
steps:
- run: |
mkdir ${{ github.ref_name }}_xrlib_binaries_android-shared
mkdir ${{ github.ref_name }}_xrlib_binaries_android-shared/with_renderer
mkdir ${{ github.ref_name }}_xrlib_binaries_android-shared/no_renderer
mkdir ${{ github.ref_name }}_xrlib_binaries_android-static
mkdir ${{ github.ref_name }}_xrlib_binaries_android-static/with_renderer
mkdir ${{ github.ref_name }}_xrlib_binaries_android-static/no_renderer
# Download build artifacts
- uses: actions/download-artifact@v4
with:
name: xrlib-static_OFF-xrvk_ON
path: ${{ github.ref_name }}_xrlib_binaries_android-shared/with_renderer

- uses: actions/download-artifact@v4
with:
name: xrlib-static_OFF-xrvk_OFF
path: ${{ github.ref_name }}_xrlib_binaries_android-shared/no_renderer

- uses: actions/download-artifact@v4
with:
name: xrlib-static_ON-xrvk_ON
path: ${{ github.ref_name }}_xrlib_binaries_android-static/with_renderer

- uses: actions/download-artifact@v4
with:
name: xrlib-static_ON-xrvk_OFF
path: ${{ github.ref_name }}_xrlib_binaries_android-static/no_renderer

# Upload final release artifacts
- uses: actions/upload-artifact@v4
with:
name: xrlib-${{ github.ref_name }}-android-shared-libs
path: ./${{ github.ref_name }}_xrlib_binaries_android-shared

- uses: actions/upload-artifact@v4
with:
name: xrlib-${{ github.ref_name }}-android-static-libs
path: ./${{ github.ref_name }}_xrlib_binaries_android-static

- uses: geekyeggo/delete-artifact@v5
with:
name: |
xrlib-shared_*
xrlib-static_*
failOnError: false
Loading

0 comments on commit b1147cc

Please sign in to comment.