SuperGenius Tag Build #41
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: SuperGenius Tag Build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to create releases for' | |
| required: true | |
| type: string | |
| thirdparty_tag: | |
| description: 'Tag for thirdparty dependencies (defaults to main tag if not specified)' | |
| required: false | |
| type: string | |
| zkllvm_tag: | |
| description: 'Tag for zkLLVM dependencies (defaults to main tag if not specified)' | |
| required: false | |
| type: string | |
| jobs: | |
| build: | |
| env: | |
| GRPC_BUILD_ENABLE_CCACHE: "ON" | |
| GH_TOKEN: ${{ secrets.GNUS_TOKEN_1 }} | |
| runs-on: ${{matrix.host}} | |
| container: | |
| image: ${{matrix.container}} | |
| credentials: | |
| username: ${{github.actor}} | |
| password: ${{secrets.GNUS_TOKEN_1}} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [Android, iOS, OSX, Linux, Windows] | |
| build-type: [Debug,Release] | |
| abi: [""] | |
| include: | |
| - target: Linux | |
| host: sg-ubuntu-linux | |
| abi: "x86_64" | |
| build-type: "Release" | |
| container: ghcr.io/geniusventures/debian-bullseye:latest | |
| - target: Linux | |
| host: sg-ubuntu-linux | |
| abi: "x86_64" | |
| build-type: "Debug" | |
| container: ghcr.io/geniusventures/debian-bullseye:latest | |
| - target: Linux | |
| host: ubuntu-24.04-arm | |
| abi: "aarch64" | |
| build-type: "Release" | |
| container: ghcr.io/geniusventures/debian-bullseye:latest | |
| - target: Linux | |
| host: ubuntu-24.04-arm | |
| abi: "aarch64" | |
| build-type: "Debug" | |
| container: ghcr.io/geniusventures/debian-bullseye:latest | |
| - target: Windows | |
| host: SG-WIN11 | |
| - target: OSX | |
| host: gv-OSX-Large | |
| - target: Android | |
| host: sg-ubuntu-linux | |
| abi: arm64-v8a | |
| build-type: "Release" | |
| - target: Android | |
| host: sg-ubuntu-linux | |
| abi: arm64-v8a | |
| build-type: "Debug" | |
| - target: Android | |
| host: sg-ubuntu-linux | |
| abi: armeabi-v7a | |
| build-type: "Release" | |
| - target: Android | |
| host: sg-ubuntu-linux | |
| abi: armeabi-v7a | |
| build-type: "Debug" | |
| - target: iOS | |
| host: macos-latest | |
| exclude: | |
| - target: Android | |
| abi: "" | |
| - target: Linux | |
| abi: "" | |
| steps: | |
| - name: Clean workspace (self-hosted runners) | |
| if: ${{ runner.environment == 'self-hosted' }} | |
| run: | | |
| echo "=== PRE-CLEANUP DEBUG ===" | |
| echo "Current working directory: $(pwd)" | |
| echo "Workspace: ${{github.workspace}}" | |
| if [ -d "${{github.workspace}}" ]; then | |
| cd "${{github.workspace}}" | |
| echo "Changed to workspace directory: $(pwd)" | |
| echo "Contents:" | |
| ls -la | |
| if [ -d ".git" ]; then | |
| echo "Git repository detected, performing deep clean..." | |
| # Remove stale lock files first | |
| echo "Removing stale git lock files..." | |
| find . -name "index.lock" -type f -delete 2>/dev/null || true | |
| find . -name "*.lock" -path "*/.git/*" -type f -delete 2>/dev/null || true | |
| git clean -xfd | |
| git submodule foreach --recursive git clean -xfd | |
| git reset --hard | |
| git submodule foreach --recursive git reset --hard | |
| echo "Git clean completed" | |
| else | |
| echo "Not a git repository, skipping git clean" | |
| fi | |
| else | |
| echo "Workspace directory does not exist yet, skipping cleanup" | |
| fi | |
| echo "=== CLEANUP ARTIFACTS ===" | |
| # Clean up artifacts from previous runs (self-hosted runners only) | |
| if [ -d "thirdparty" ]; then | |
| echo "Removing thirdparty directory..." | |
| rm -rf thirdparty | |
| fi | |
| if [ -d "zkLLVM" ]; then | |
| echo "Removing zkLLVM directory..." | |
| rm -rf zkLLVM | |
| fi | |
| echo "=== POST-CLEANUP DEBUG ===" | |
| if [ -d "${{github.workspace}}" ]; then | |
| cd "${{github.workspace}}" | |
| echo "Final workspace contents:" | |
| ls -la | |
| fi | |
| shell: bash | |
| - name: Checkout SuperGenius repository | |
| uses: actions/checkout@v6 | |
| with: | |
| path: "SuperGenius" | |
| submodules: "recursive" | |
| ref: ${{ github.event.inputs.tag }} | |
| - 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: Download thirdparty release | |
| working-directory: ${{github.workspace}} | |
| run: | | |
| TAG_NAME="${{ github.event.inputs.tag }}" | |
| THIRDPARTY_TAG="${{ github.event.inputs.thirdparty_tag || github.event.inputs.tag }}" | |
| echo "Building for tag: ${TAG_NAME}" | |
| echo "Using thirdparty tag: ${THIRDPARTY_TAG}" | |
| if [ '${{matrix.abi}}' ]; then | |
| FILE_NAME=${{matrix.target}}-${{matrix.abi}}-${{matrix.build-type}}.tar.gz | |
| else | |
| FILE_NAME=${{matrix.target}}-${{matrix.build-type}}.tar.gz | |
| fi | |
| echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV | |
| mkdir thirdparty | |
| cd thirdparty | |
| # Download from the specified thirdparty tag's release | |
| echo "Downloading thirdparty from tag: ${THIRDPARTY_TAG}" | |
| gh release download ${THIRDPARTY_TAG} --repo GeniusVentures/thirdparty -p "${FILE_NAME}" | |
| tar -zxf "${FILE_NAME}" | |
| # Set THIRDPARTY_BUILD_DIR to the actual location where files were extracted | |
| if [ "${{ matrix.target }}" = "Windows" ]; then | |
| # Convert Unix path to Windows path for Windows builds | |
| echo "THIRDPARTY_BUILD_DIR=$(pwd -W)/${BUILD_DIRECTORY}" >> $GITHUB_ENV | |
| else | |
| echo "THIRDPARTY_BUILD_DIR=$(pwd)/${BUILD_DIRECTORY}" >> $GITHUB_ENV | |
| fi | |
| shell: bash | |
| - name: Download zkLLVM release | |
| working-directory: ${{github.workspace}} | |
| run: | | |
| TAG_NAME="${{ github.event.inputs.tag }}" | |
| ZKLLVM_TAG="${{ github.event.inputs.zkllvm_tag || github.event.inputs.tag }}" | |
| echo "Using zkLLVM tag: ${ZKLLVM_TAG}" | |
| mkdir zkLLVM | |
| cd zkLLVM | |
| echo "Downloading zkLLVM from tag: ${ZKLLVM_TAG}" | |
| if [ "${{ matrix.target }}" = "Windows" ]; then | |
| ZKLLVM_FILE_NAME=${{matrix.target}}-${{matrix.build-type}}.tar.gz | |
| ZKLLVM_BUILD_DIR=build/${{matrix.target}}/${{matrix.build-type}} | |
| elif [ '${{matrix.abi}}' ]; then | |
| ZKLLVM_FILE_NAME=${{matrix.target}}-${{matrix.abi}}-Release.tar.gz | |
| ZKLLVM_BUILD_DIR=build/${{matrix.target}}/Release/${{matrix.abi}} | |
| else | |
| ZKLLVM_FILE_NAME=${{matrix.target}}-Release.tar.gz | |
| ZKLLVM_BUILD_DIR=build/${{matrix.target}}/Release | |
| fi | |
| gh release download ${ZKLLVM_TAG} --repo GeniusVentures/zkLLVM -p "${ZKLLVM_FILE_NAME}" | |
| tar --exclude='*bin/assigner' --exclude='*bin/clang-zkllvm' --exclude='*bin/llvm-link-zkllvm' --exclude='*bin/transpiler' -xzf "${ZKLLVM_FILE_NAME}" | |
| # Set ZKLLVM_BUILD_DIR to the actual location where files were extracted | |
| if [ "${{ matrix.target }}" = "Windows" ]; then | |
| # Convert Unix path to Windows path for Windows builds | |
| echo "ZKLLVM_BUILD_DIR=$(pwd -W)/${ZKLLVM_BUILD_DIR}" >> $GITHUB_ENV | |
| else | |
| echo "ZKLLVM_BUILD_DIR=$(pwd)/${ZKLLVM_BUILD_DIR}" >> $GITHUB_ENV | |
| fi | |
| shell: bash | |
| - 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 libvulkan-dev libsecret-1-dev -y | |
| echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV | |
| - name: Configure Windows host | |
| if: ${{ runner.os == 'Windows'}} | |
| run: | | |
| choco install ccache -A | |
| - name: Configure macOS host | |
| if: ${{ runner.os == 'macOS'}} | |
| run: | | |
| brew install ninja bash gnu-tar | |
| # Ensure GNU tar is first in PATH - check both possible Homebrew locations | |
| if [ -d "/opt/homebrew/opt/gnu-tar/libexec/gnubin" ]; then | |
| echo "PATH=/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV | |
| echo "Using GNU tar from /opt/homebrew" | |
| elif [ -d "/usr/local/opt/gnu-tar/libexec/gnubin" ]; then | |
| echo "PATH=/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV | |
| echo "Using GNU tar from /usr/local" | |
| else | |
| echo "WARNING: GNU tar installation not found in expected locations" | |
| echo "Available tar: $(which tar)" | |
| fi | |
| 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: | | |
| NDK_VERSION="r27b" | |
| NDK_DIR="$HOME/android-ndk-$NDK_VERSION" | |
| if [ ! -d "$NDK_DIR" ]; then | |
| echo "Downloading Android NDK..." | |
| wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip -O ndk.zip | |
| unzip -o ndk.zip -d $HOME | |
| rm ndk.zip | |
| else | |
| echo "Android NDK already exists at $NDK_DIR, skipping download" | |
| fi | |
| echo "ANDROID_NDK_HOME=$NDK_DIR" >> $GITHUB_ENV | |
| rustup target add aarch64-linux-android | |
| rustup target add armv7-linux-androideabi | |
| - name: Install bindgen | |
| run: cargo install cbindgen | |
| - name: Add wasm Rust target | |
| run: rustup target add wasm32-unknown-emscripten | |
| - name: Configure CMake for Android | |
| if: ${{ matrix.target == 'Android'}} | |
| working-directory: ${{github.workspace}}/SuperGenius | |
| run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DSGNS_NETWORK=release -DANDROID_ABI=${{matrix.abi}} -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_BUILD_DIR=${{env.THIRDPARTY_BUILD_DIR}} -DZKLLVM_DIR=${{env.ZKLLVM_BUILD_DIR}} -DZKLLVM_BUILD_DIR=${{env.ZKLLVM_BUILD_DIR}} | |
| - name: Configure CMake for Mac | |
| if: ${{ matrix.target == 'OSX'}} | |
| working-directory: ${{github.workspace}}/SuperGenius | |
| run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DSGNS_NETWORK=release -DPLATFORM=MAC_UNIVERSAL -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_BUILD_DIR=${{env.THIRDPARTY_BUILD_DIR}} -DZKLLVM_DIR=${{env.ZKLLVM_BUILD_DIR}} -DZKLLVM_BUILD_DIR=${{env.ZKLLVM_BUILD_DIR}} | |
| - name: Configure CMake for iOS | |
| if: ${{ matrix.target == 'iOS'}} | |
| working-directory: ${{github.workspace}}/SuperGenius | |
| run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DSGNS_NETWORK=release -DPLATFORM=OS64 -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_BUILD_DIR=${{env.THIRDPARTY_BUILD_DIR}} -DZKLLVM_DIR=${{env.ZKLLVM_BUILD_DIR}} -DZKLLVM_BUILD_DIR=${{env.ZKLLVM_BUILD_DIR}} | |
| - name: Configure CMake for Linux | |
| if: ${{matrix.target == 'Linux'}} | |
| working-directory: ${{github.workspace}}/SuperGenius | |
| run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DSGNS_NETWORK=release -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_BUILD_DIR=${{env.THIRDPARTY_BUILD_DIR}} -DZKLLVM_DIR=${{env.ZKLLVM_BUILD_DIR}} -DZKLLVM_BUILD_DIR=${{env.ZKLLVM_BUILD_DIR}} -DABI_SUBFOLDER_NAME=${{matrix.abi}} | |
| - name: Configure CMake for Windows | |
| if: ${{matrix.target == 'Windows'}} | |
| working-directory: ${{github.workspace}}/SuperGenius | |
| run: cmake -S build/${{matrix.target}} -B $env:BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DSGNS_NETWORK=release -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_BUILD_DIR=${{env.THIRDPARTY_BUILD_DIR}} -DZKLLVM_DIR=${{env.ZKLLVM_BUILD_DIR}} -DZKLLVM_BUILD_DIR=${{env.ZKLLVM_BUILD_DIR}} | |
| - name: Build SuperGenius | |
| working-directory: ${{github.workspace}}/SuperGenius/${{env.BUILD_DIRECTORY}} | |
| run: cmake --build . --config ${{matrix.build-type}} -j8 | |
| - name: Install SuperGenius | |
| working-directory: ${{github.workspace}}/SuperGenius/${{env.BUILD_DIRECTORY}} | |
| run: cmake --install . --config ${{matrix.build-type}} | |
| - name: Create or check release | |
| shell: bash | |
| working-directory: ${{github.workspace}}/SuperGenius | |
| run: | | |
| TAG_NAME='${{ github.event.inputs.tag }}' | |
| echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
| echo "Checking if GitHub release exists for tag: $TAG_NAME" | |
| set +e | |
| gh release view $TAG_NAME | |
| releaseFound=$? | |
| set -e | |
| if [[ $releaseFound -ne 0 ]]; then | |
| echo "Release not found, creating for tag: $TAG_NAME" | |
| # Create a single release for the tag | |
| gh release create $TAG_NAME \ | |
| -n "Build artifacts for tag ${TAG_NAME}" \ | |
| -t "${TAG_NAME} build artifacts" | |
| else | |
| echo "Release already exists for tag: $TAG_NAME" | |
| fi | |
| - name: Compress build artifacts | |
| working-directory: ${{github.workspace}}/SuperGenius/${{env.BUILD_DIRECTORY}} | |
| run: | | |
| tar --exclude=.git -czvf ${FILE_NAME} --transform 's|^|${{env.BUILD_DIRECTORY}}/|' SuperGenius/ | |
| shell: bash | |
| - name: Release file | |
| working-directory: ${{github.workspace}}/SuperGenius/${{env.BUILD_DIRECTORY}} | |
| shell: bash | |
| run: | | |
| echo -e "Uploading ${FILE_NAME} to release ${TAG_NAME}" | |
| gh release upload --clobber ${TAG_NAME} ${FILE_NAME} |