2025-07-21 18:26:32 +02:00

323 lines
9.9 KiB
YAML

name: Build Witness Generator
on:
push:
branches:
- main
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
version:
description: "Version to release. Must follow the format of 'vX.Y.Z'."
required: true
pull_request: # For testing purposes
jobs:
setup:
name: Define variables and configure environment
runs-on: ubuntu-latest
outputs:
version: ${{ steps.define-version.outputs.version }}
steps:
- name: Define version
id: define-version
env:
# Use the tag name if it is available, otherwise use the input version.
# If neither is available, default to the commit hash.
VERSION: ${{ github.event.release.tag_name || inputs.version }}
run: |
if [ -z "$VERSION" ]; then
echo "No version tag found. Defaulting to commit hash."
VERSION=$GITHUB_SHA
elif [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "VERSION must follow the format of 'vX.Y.Z'. Value: '$VERSION'."
exit 1
fi
# Export the version to be used in the following jobs.
echo "version=$VERSION" >> $GITHUB_OUTPUT
build-linux-native:
name: Build Linux Binary (Native)
runs-on: ubuntu-latest
needs:
- setup
env:
VERSION: ${{ needs.setup.outputs.version }}
steps:
- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: false
- name: Install Circom
run: |
git clone https://github.com/iden3/circom.git
cd circom
RUSTFLAGS="-A dead_code" cargo build --release
RUSTFLAGS="-A dead_code" cargo install --path circom
circom --version
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Initialise Submodules
working-directory: repo
run: git submodule update --init --recursive
- name: Generate C++ Circuit
working-directory: repo/circom_circuits/Mantle
run: circom --c --r1cs --no_asm pol.circom
- name: Dependencies - Setup
run: |
sudo apt update
- name: Dependencies - Install [nlohmann/json]
run: sudo apt install nlohmann-json3-dev
- name: Compile Circuit
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make pol
- name: Bundle
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: tar -czf pol-linux-x86_64.tar.gz pol pol.dat
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: pol-linux-x86_64.tar.gz
path: repo/circom_circuits/Mantle/pol_cpp/pol-linux-x86_64.tar.gz
build-windows-native:
name: Build Windows Binary (Native)
runs-on: windows-latest
needs:
- setup
env:
VERSION: ${{ needs.setup.outputs.version }}
steps:
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
mingw-w64-x86_64-toolchain
make
git
- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: false
- name: Install Circom
run: |
git clone https://github.com/iden3/circom.git
cd circom
$env:RUSTFLAGS="-A dead_code"; cargo build --release
$env:RUSTFLAGS="-A dead_code"; cargo install --path circom
circom --version
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Initialise Submodules
working-directory: repo
run: git submodule update --init --recursive
- name: Generate C++ Circuit
working-directory: repo/circom_circuits/Mantle
run: circom --c --r1cs --no_asm pol.circom
- name: Dependencies - Setup
shell: msys2 {0}
run: mkdir /include
- name: Dependencies - Install [mman-win32]
shell: msys2 {0}
run: |
git clone https://github.com/alitrack/mman-win32.git
cd mman-win32
pwd
./configure --prefix= # Path: /
make
make install
- name: Dependencies - Install [nlohmann/json]
shell: msys2 {0}
run: |
mkdir -p /include/nlohmann/
wget -O /include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.12.0/json.hpp
- name: Replace pol Makefile # TODO: Make a fork generate the appropriate Windows Makefile
working-directory: repo
shell: msys2 {0}
run: cp .github/resources/Makefile.windows circom_circuits/Mantle/pol_cpp/Makefile
- name: Compile Circuit
shell: msys2 {0}
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make pol.exe
- name: Bundle
shell: msys2 {0}
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: |
MINGW_BASE_DIR="/${MSYSTEM,,}" # converts to lowercase, e.g., MINGW64 -> mingw64
MINGW_DLL_DIR="$MINGW_BASE_DIR/bin"
cp "$MINGW_DLL_DIR"/{libgcc_s_seh-1.dll,libgmp-10.dll,libwinpthread-1.dll,libstdc++-6.dll} .
mv pol.dat pol.exe.dat
tar -czf pol-windows-x86_64.tar.gz pol.exe pol.exe.dat *.dll
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: pol-windows-x86_64.tar.gz
path: repo/circom_circuits/Mantle/pol_cpp/pol-windows-x86_64.tar.gz
build-macos-native:
name: Build MacOS Binary (Native)
runs-on: macos-latest
needs:
- setup
env:
VERSION: ${{ needs.setup.outputs.version }}
steps:
- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: false
- name: Install Circom
run: |
git clone https://github.com/iden3/circom.git
cd circom
RUSTFLAGS="-A dead_code" cargo build --release
RUSTFLAGS="-A dead_code" cargo install --path circom
circom --version
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Initialise Submodules
working-directory: repo
run: git submodule update --init --recursive
- name: Generate C++ Circuit
working-directory: repo/circom_circuits/Mantle
run: circom --c --r1cs --no_asm pol.circom
- name: Dependencies - Setup
run: mkdir include
- name: Dependencies - Install [nlohmann/json]
run: brew install nlohmann-json
- name: Replace pol Makefile # TODO: Make a fork generate the appropriate MacOS Makefile
working-directory: repo
run: cp .github/resources/Makefile.macos circom_circuits/Mantle/pol_cpp/Makefile
- name: Patch MacOS GMP
working-directory: repo
run: cp .github/resources/gmp_patch.macos.hpp circom_circuits/Mantle/pol_cpp/gmp_patch.macos.hpp
- name: Compile Circuit
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make pol
- name: Bundle
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: tar -czf pol-macos-arm64.tar.gz pol pol.dat
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: pol-macos-arm64.tar.gz
path: repo/circom_circuits/Mantle/pol_cpp/pol-macos-arm64.tar.gz
create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- setup
- build-linux-native
- build-windows-native
- build-macos-native
env:
VERSION: ${{ needs.setup.outputs.version }}
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
uses: actions/create-release@4c11c9fe1dcd9636620a16455165783b20fc7ea0 # Version 1.1.4
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: PoL Witness Generator ${{ env.VERSION }}
body: |
This is a release of PoL Witness Generator ${{ env.VERSION }}.
## Changelog
- feature(X): new feature
- fix(Y): bug description
- feature: performance improvement on Z
## Checklist
Before publishing please ensure:
- [ ] Description is complete
- [ ] Changelog is correct
- [ ] Assets for all platforms exist
- [ ] Pre-release is checked if necessary
- [ ] Remove this checklist before publishing the release.
draft: true
prerelease: true
upload-artifacts:
name: Upload Artifacts to Release
runs-on: ubuntu-latest
needs:
- setup
- create-release
strategy:
fail-fast: false
matrix:
platform:
- os: linux
arch: x86_64
- os: macos
arch: arm64
- os: windows
arch: x86_64
env:
VERSION: ${{ needs.setup.outputs.version }}
UPLOAD_URL: ${{ needs.create-release.outputs.upload_url }}
ARTIFACT_NAME: pol-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz
steps:
- name: Download Artifacts
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # Version 4.2.1
with:
name: ${{ env.ARTIFACT_NAME }}
- name: Upload Artifacts to Release
uses: actions/upload-release-asset@ef2adfe8cb8ebfa540930c452c576b3819990faa # Version 1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ${{ env.ARTIFACT_NAME }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: application/octet-stream