Release Build CI #383
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
name: Release Build CI | |
# Controls when the workflow will run | |
# Triggers the workflow on push or pull request events and manually from the Actions tab | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
pull_request: | |
branches: | |
- develop | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
env: | |
GRPC_BUILD_ENABLE_CCACHE: "ON" | |
runs-on: ${{matrix.host}} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [Android, iOS, OSX, Linux, Windows] | |
include: | |
- target: Linux | |
host: ubuntu-latest | |
- target: Windows | |
host: windows-latest | |
- target: OSX | |
host: macos-latest | |
- target: Android | |
host: ubuntu-latest | |
abi: arm64-v8a | |
- target: iOS | |
host: macos-latest | |
steps: | |
- name: Checkout SuperGenius repository | |
uses: actions/checkout@v4 | |
with: | |
path: "SuperGenius" | |
submodules: "recursive" | |
- name: Check out thirdparty repository | |
uses: actions/checkout@v4 | |
with: | |
repository: "GeniusVentures/thirdparty" | |
path: "thirdparty" | |
submodules: "recursive" | |
ref: vulkan-linking | |
- name: Set clang as the default compiler | |
if: ${{ matrix.host == 'ubuntu-latest' }} | |
run: | | |
sudo update-alternatives --install /usr/bin/cc cc $(which clang) 100 | |
sudo update-alternatives --install /usr/bin/c++ c++ $(which clang++) 100 | |
sudo update-alternatives --set cc $(which clang) | |
sudo update-alternatives --set c++ $(which clang++) | |
- name: Install Linux host dependencies | |
if: ${{ matrix.host == 'ubuntu-latest'}} | |
run: | | |
sudo apt install ccache ninja-build -y | |
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV | |
- name: Install Windows host dependencies | |
if: ${{ matrix.host == 'windows-latest'}} | |
run: | | |
choco install ccache -A | |
- name: Install Darwin host dependencies | |
if: ${{ matrix.host == 'macos-latest'}} | |
run: | | |
brew install ccache ninja | |
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV | |
- name: Add Darwin toolchain | |
if: ${{ matrix.target == 'OSX'}} | |
run: rustup target add x86_64-apple-darwin | |
- name: Add iOS toolchain | |
if: ${{ matrix.target == 'iOS' }} | |
run: | | |
rustup toolchain install nightly-aarch64-apple-darwin | |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin | |
rustup target add aarch64-apple-ios | |
- name: Add Android toolchain | |
if: ${{ matrix.target == 'Android' }} | |
run: | | |
rustup target add aarch64-linux-android | |
- name: Install bindgen | |
run: cargo install cbindgen | |
- name: Add Rust target | |
run: rustup target add wasm32-unknown-emscripten | |
- name: Configure Thirdparty CMake for Mac x86 | |
if: ${{ matrix.target == 'OSX'}} | |
working-directory: ${{github.workspace}}/thirdparty | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DPLATFORM=MAC | |
- name: Configure Thirdparty CMake for iOS | |
if: ${{ matrix.target == 'iOS'}} | |
working-directory: ${{github.workspace}}/thirdparty | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DPLATFORM=OS64 | |
- name: Configure Thirdparty CMake for Android | |
if: ${{ matrix.target == 'Android'}} | |
working-directory: ${{github.workspace}}/thirdparty | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release/${{matrix.abi}} -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=${{matrix.abi}} | |
- name: Configure Thirdparty CMake | |
if: ${{ matrix.target != 'OSX' && matrix.target != 'iOS' && matrix.target != 'Android' }} | |
working-directory: ${{github.workspace}}/thirdparty | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release | |
- name: Build Thirdparty | |
working-directory: ${{github.workspace}}/thirdparty | |
run: | | |
if [ '${{matrix.target}}' == 'Android' ]; then | |
cmake --build build/${{matrix.target}}/Release/${{matrix.abi}} --config Release -j | |
else | |
cmake --build build/${{matrix.target}}/Release --config Release -j | |
fi | |
shell: bash | |
- name: Configure SuperGenius CMake for Mac x86 | |
if: ${{ matrix.target == 'OSX'}} | |
working-directory: ${{github.workspace}}/SuperGenius | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DPLATFORM=MAC | |
- name: Configure SuperGenius CMake for iOS | |
if: ${{ matrix.target == 'iOS'}} | |
working-directory: ${{github.workspace}}/SuperGenius | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DPLATFORM=OS64 | |
- name: Configure SuperGenius CMake for Android | |
if: ${{ matrix.target == 'Android'}} | |
working-directory: ${{github.workspace}}/SuperGenius | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release/${{matrix.abi}} -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=${{matrix.abi}} | |
- name: Configure SuperGenius CMake | |
if: ${{ matrix.target != 'OSX' && matrix.target != 'iOS' && matrix.target != 'Android' }} | |
working-directory: ${{github.workspace}}/SuperGenius | |
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release | |
- name: Build SuperGenius | |
if: ${{ matrix.target != 'Android' }} | |
working-directory: ${{github.workspace}}/SuperGenius | |
run: | | |
if [ '${{matrix.target}}' == 'Android' ]; then | |
cmake --build build/${{matrix.target}}/Release/${{matrix.abi}} --config Release -j | |
else | |
cmake --build build/${{matrix.target}}/Release --config Release -j | |
fi | |
shell: bash | |
- name: Install SuperGenius | |
working-directory: ${{github.workspace}}/SuperGenius/build/${{matrix.target}}/Release | |
run: | | |
if [ '${{matrix.target}}' == 'Android' ]; then | |
cd ${{matrix.abi}} | |
fi | |
cmake --install . | |
shell: bash | |
- name: Compressing Build Artifacts | |
working-directory: ${{github.workspace}}/SuperGenius | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
shopt -s extglob | |
rm -rf !(build) .[!.]* ..?* | |
cd build | |
rm -rf !(${{matrix.target}}) .[!.]* ..?* | |
cd ${{matrix.target}} | |
rm -rf !(Release) .[!.]* ..?* | |
cd Release | |
if [[ "${{matrix.target == 'Android'}}"]]; then | |
rm -rf !(${{matrix.abi}}) .[!.]* ..?* | |
cd ${{matrix.abi}} | |
fi | |
rm -rf !(SuperGenius) .[!.]* ..?* | |
cd $GITHUB_WORKSPACE | |
tar -czvf SuperGenius.tar.gz SuperGenius/ | |
shell: bash | |
- name: Set Release Variables | |
id: vars | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
if [ '${{matrix.target}}' == 'Android' ]; then | |
OS_NAME=${{matrix.target}}-${{matrix.abi}} | |
else | |
OS_NAME=${{matrix.target}} | |
fi | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
BUILD_TYPE=Release | |
FILE_NAME="${OS_NAME}-${BRANCH_NAME}-${BUILD_TYPE}.tar.gz" | |
echo "RELEASE_TAG=${OS_NAME}-${BRANCH_NAME}-${BUILD_TYPE}-${GITHUB_SHA::7}" >> $GITHUB_ENV | |
echo "RELEASE_NAME=${OS_NAME} ${BRANCH_NAME} ${BUILD_TYPE} (${GITHUB_SHA::7})" >> $GITHUB_ENV | |
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV | |
shell: bash | |
- name: Rename Artifact | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: mv SuperGenius.tar.gz ${{ env.FILE_NAME }} | |
shell: bash | |
- name: Create GitHub Release | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GNUS_TOKEN_1 }} | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
release_name: ${{ env.RELEASE_NAME }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GNUS_TOKEN_1 }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.FILE_NAME }} | |
asset_name: ${{ env.FILE_NAME }} | |
asset_content_type: application/gzip |