Skip to content

Release Build CI

Release Build CI #47

Workflow file for this run

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:
GH_TOKEN: ${{ secrets.GNUS_TOKEN_1 }}
runs-on: ${{matrix.host}}
strategy:
fail-fast: false
matrix:
target: [Android, iOS, OSX, Linux, Windows]
build-type: [Release]
abi: [""]
include:
- target: Android
host: ubuntu-latest
abi: arm64-v8a
build-type: Release
- target: Android
host: ubuntu-latest
abi: armeabi-v7a
build-type: Release
- target: iOS
host: macos-latest
- target: OSX
host: macos-latest
- target: Linux
host: ubuntu-latest
- target: Windows
host: windows-latest
exclude:
- target: Android
abi: ""
steps:
- name: Configure Linux host
if: ${{ runner.os == 'Linux'}}
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++)
sudo apt install ccache ninja-build -y
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
- name: Configure Windows host
if: ${{ runner.os == 'Windows'}}
run: |
choco install ccache -y
- name: Configure macOS host
if: ${{ runner.os == 'macOS'}}
run: |
brew install ccache ninja bash
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
- name: Add Android toolchain
if: ${{ matrix.target == 'Android' }}
run: |
NDK_VERSION="r27b"
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip -O ndk.zip
unzip ndk.zip -d $HOME
echo "ANDROID_NDK_HOME=$HOME/android-ndk-$NDK_VERSION" >> $GITHUB_ENV
- name: Set build directory
run: |
if [ '${{matrix.abi}}' ]; then
BUILD_DIRECTORY=build/${{matrix.target}}/${{matrix.build-type}}/${{matrix.abi}}
else
BUILD_DIRECTORY=build/${{matrix.target}}/${{matrix.build-type}}
fi
echo "BUILD_DIRECTORY=$BUILD_DIRECTORY" >> $GITHUB_ENV
shell: bash
- name: Define Release Tag
shell: bash
run: |
if [ '${{matrix.abi}}' ]; then
RELEASE_TAG='${{matrix.target}}-${{matrix.abi}}-${{ github.ref_name }}-${{matrix.build-type}}'
else
RELEASE_TAG='${{matrix.target}}-${{ github.ref_name }}-${{matrix.build-type}}'
fi
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
- name: Download Prebuilt Boost from Thirdparty
shell: bash
run: |
if [ '${{matrix.abi}}' ]; then
thirdparty_tag='${{matrix.target}}-${{matrix.abi}}-develop-${{matrix.build-type}}'
else
thirdparty_tag='${{matrix.target}}-develop-${{matrix.build-type}}'
fi
gh release download \
--repo GeniusVentures/thirdparty \
${thirdparty_tag} \
--pattern Boost-lib.tar.gz
mkdir -p ${{github.workspace}}/thirdparty/${{env.BUILD_DIRECTORY}}
- name: Extract Boost
run: |
mkdir -p thirdparty/${{env.BUILD_DIRECTORY}}
tar -xzf Boost-lib.tar.gz -C thirdparty/${{env.BUILD_DIRECTORY}}
- name: Checkout
uses: actions/checkout@v4
with:
path: "zkLLVM"
submodules: "recursive"
- name: Configure CMake for Android
if: ${{ matrix.target == 'Android'}}
working-directory: ${{github.workspace}}/zkLLVM
run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DANDROID_ABI=${{matrix.abi}} -DCMAKE_ANDROID_NDK=${ANDROID_NDK_HOME}
- name: Configure CMake for iOS
if: ${{ matrix.target == 'iOS'}}
working-directory: ${{github.workspace}}/zkLLVM
run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DPLATFORM=OS64
- name: Configure CMake for Mac x86
if: ${{ matrix.target == 'OSX'}}
working-directory: ${{github.workspace}}/zkLLVM
run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DPLATFORM=MAC
- name: Configure CMake for Linux
if: ${{ matrix.target == 'Linux' }}
working-directory: ${{github.workspace}}/zkLLVM
run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty
- name: Configure CMake for Windows
if: ${{ matrix.target == 'Windows' }}
working-directory: ${{github.workspace}}/zkLLVM
run: cmake -S build/${{matrix.target}} -B $env:BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -G "Visual Studio 17 2022" -A x64
- name: Build
working-directory: ${{github.workspace}}/zkLLVM
run: cmake --build ${{env.BUILD_DIRECTORY}} --config ${{matrix.build-type}} -j
- name: Install
working-directory: ${{github.workspace}}/zkLLVM/${{env.BUILD_DIRECTORY}}
run: cmake --install .
- name: Compressing Build Artifacts
working-directory: ${{github.workspace}}/zkLLVM
if: ${{github.event_name == 'workflow_dispatch'}}
run: |
shopt -s extglob
IFS='/' read -ra dirs <<< "$BUILD_DIRECTORY"
for dir in "${dirs[@]}"; do
rm -rf !($dir) .[!.]* ..?*
cd $dir
done
cd $GITHUB_WORKSPACE
tar --exclude='zkLLVM/build/Windows/Release/zkLLVM/src' \
--exclude='zkLLVM/build/Windows/Release/zkLLVM/tmp' \
-czvf zkLLVM.tar.gz zkLLVM/
- name: Set Release Variables
id: vars
shell: bash
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
if [ '${{matrix.abi}}' ]; 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
- name: Rename Artifact
if: ${{ github.event_name == 'workflow_dispatch' }}
run: mv zkLLVM.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