|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - build-all-platforms |
| 11 | + pull_request: |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + |
| 16 | +jobs: |
| 17 | + |
| 18 | + build-windows-x86_64: |
| 19 | + runs-on: windows-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - uses: dtolnay/rust-toolchain@stable |
| 24 | + |
| 25 | + - name: Install protoc |
| 26 | + run: choco install protoc -y |
| 27 | + |
| 28 | + - name: Install LLVM |
| 29 | + run: choco install llvm -y |
| 30 | + |
| 31 | + - name: Cache cargo |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: | |
| 35 | + ~/.cargo/registry |
| 36 | + ~/.cargo/git |
| 37 | + target |
| 38 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 39 | + |
| 40 | + - name: Build |
| 41 | + env: |
| 42 | + LIBCLANG_PATH: "C:\\Program Files\\LLVM\\bin" |
| 43 | + run: cargo build --release |
| 44 | + |
| 45 | + - name: Build build-circuit |
| 46 | + env: |
| 47 | + LIBCLANG_PATH: "C:\\Program Files\\LLVM\\bin" |
| 48 | + run: cargo build --release -p build-circuit |
| 49 | + |
| 50 | + - name: Collect artifacts |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + mkdir -p artifacts/win-x64 |
| 54 | + cp target/release/circom_witnesscalc.dll artifacts/win-x64/ |
| 55 | + cp target/release/calc-witness.exe artifacts/win-x64/ |
| 56 | + cp target/release/build-circuit.exe artifacts/win-x64/ |
| 57 | +
|
| 58 | + - name: Upload artifacts |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: circom-witnesscalc-win-x64 |
| 62 | + path: artifacts/win-x64 |
| 63 | + if-no-files-found: error |
| 64 | + |
| 65 | + build-linux-x86_64: |
| 66 | + runs-on: ubuntu-24.04 |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - uses: dtolnay/rust-toolchain@stable |
| 71 | + |
| 72 | + - name: Install dependencies |
| 73 | + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libclang-dev |
| 74 | + |
| 75 | + - name: Cache cargo |
| 76 | + uses: actions/cache@v4 |
| 77 | + with: |
| 78 | + path: | |
| 79 | + ~/.cargo/registry |
| 80 | + ~/.cargo/git |
| 81 | + target |
| 82 | + key: ${{ runner.os }}-x86_64-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 83 | + |
| 84 | + - name: Build |
| 85 | + run: cargo build --release |
| 86 | + |
| 87 | + - name: Build build-circuit |
| 88 | + run: cargo build --release -p build-circuit |
| 89 | + |
| 90 | + - name: Collect artifacts |
| 91 | + run: | |
| 92 | + mkdir -p artifacts/linux-x64 |
| 93 | + cp target/release/libcircom_witnesscalc.so artifacts/linux-x64/ |
| 94 | + cp target/release/calc-witness artifacts/linux-x64/ |
| 95 | + cp target/release/build-circuit artifacts/linux-x64/ |
| 96 | +
|
| 97 | + - name: Upload artifacts |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: circom-witnesscalc-linux-x64 |
| 101 | + path: artifacts/linux-x64 |
| 102 | + if-no-files-found: error |
| 103 | + |
| 104 | + build-linux-arm64: |
| 105 | + runs-on: ubuntu-24.04-arm |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - uses: dtolnay/rust-toolchain@stable |
| 110 | + |
| 111 | + - name: Install dependencies |
| 112 | + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libclang-dev |
| 113 | + |
| 114 | + - name: Cache cargo |
| 115 | + uses: actions/cache@v4 |
| 116 | + with: |
| 117 | + path: | |
| 118 | + ~/.cargo/registry |
| 119 | + ~/.cargo/git |
| 120 | + target |
| 121 | + key: ${{ runner.os }}-arm64-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 122 | + |
| 123 | + - name: Build |
| 124 | + run: cargo build --release |
| 125 | + |
| 126 | + - name: Collect artifacts |
| 127 | + run: | |
| 128 | + mkdir -p artifacts/linux-arm64 |
| 129 | + cp target/release/libcircom_witnesscalc.so artifacts/linux-arm64/ |
| 130 | + cp target/release/calc-witness artifacts/linux-arm64/ |
| 131 | +
|
| 132 | + - name: Upload artifacts |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: circom-witnesscalc-linux-arm64 |
| 136 | + path: artifacts/linux-arm64 |
| 137 | + if-no-files-found: error |
| 138 | + |
| 139 | + build-macos-arm64: |
| 140 | + runs-on: macos-15 |
| 141 | + steps: |
| 142 | + - uses: actions/checkout@v4 |
| 143 | + |
| 144 | + - uses: dtolnay/rust-toolchain@stable |
| 145 | + |
| 146 | + - name: Install dependencies |
| 147 | + run: brew install protobuf |
| 148 | + |
| 149 | + - name: Cache cargo |
| 150 | + uses: actions/cache@v4 |
| 151 | + with: |
| 152 | + path: | |
| 153 | + ~/.cargo/registry |
| 154 | + ~/.cargo/git |
| 155 | + target |
| 156 | + key: ${{ runner.os }}-arm64-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 157 | + |
| 158 | + - name: Build |
| 159 | + run: cargo build --workspace --release |
| 160 | + |
| 161 | + - name: Collect artifacts |
| 162 | + run: | |
| 163 | + mkdir -p artifacts/osx-arm64 |
| 164 | + cp target/release/libcircom_witnesscalc.dylib artifacts/osx-arm64/ |
| 165 | + cp target/release/libcircom_witnesscalc.a artifacts/osx-arm64/ |
| 166 | + cp target/release/calc-witness artifacts/osx-arm64/ |
| 167 | + cp target/release/build-circuit artifacts/osx-arm64/ |
| 168 | + install_name_tool -id @rpath/libcircom_witnesscalc.dylib artifacts/osx-arm64/libcircom_witnesscalc.dylib |
| 169 | +
|
| 170 | + - name: Upload artifacts |
| 171 | + uses: actions/upload-artifact@v4 |
| 172 | + with: |
| 173 | + name: circom-witnesscalc-osx-arm64 |
| 174 | + path: artifacts/osx-arm64 |
| 175 | + if-no-files-found: error |
| 176 | + |
| 177 | + build-macos-x86_64: |
| 178 | + runs-on: macos-15-intel |
| 179 | + steps: |
| 180 | + - uses: actions/checkout@v4 |
| 181 | + |
| 182 | + - uses: dtolnay/rust-toolchain@stable |
| 183 | + |
| 184 | + - name: Install dependencies |
| 185 | + run: brew install protobuf |
| 186 | + |
| 187 | + - name: Cache cargo |
| 188 | + uses: actions/cache@v4 |
| 189 | + with: |
| 190 | + path: | |
| 191 | + ~/.cargo/registry |
| 192 | + ~/.cargo/git |
| 193 | + target |
| 194 | + key: ${{ runner.os }}-x86_64-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 195 | + |
| 196 | + - name: Build |
| 197 | + run: cargo build --release |
| 198 | + |
| 199 | + - name: Collect artifacts |
| 200 | + run: | |
| 201 | + mkdir -p artifacts/osx-x64 |
| 202 | + cp target/release/libcircom_witnesscalc.dylib artifacts/osx-x64/ |
| 203 | + cp target/release/calc-witness artifacts/osx-x64/ |
| 204 | + install_name_tool -id @rpath/libcircom_witnesscalc.dylib artifacts/osx-x64/libcircom_witnesscalc.dylib |
| 205 | +
|
| 206 | + - name: Upload artifacts |
| 207 | + uses: actions/upload-artifact@v4 |
| 208 | + with: |
| 209 | + name: circom-witnesscalc-osx-x64 |
| 210 | + path: artifacts/osx-x64 |
| 211 | + if-no-files-found: error |
| 212 | + |
| 213 | + build-android: |
| 214 | + runs-on: ubuntu-24.04 |
| 215 | + strategy: |
| 216 | + matrix: |
| 217 | + include: |
| 218 | + - target: aarch64-linux-android |
| 219 | + rid: android-arm64 |
| 220 | + - target: x86_64-linux-android |
| 221 | + rid: android-x64 |
| 222 | + steps: |
| 223 | + - uses: actions/checkout@v4 |
| 224 | + |
| 225 | + - uses: dtolnay/rust-toolchain@stable |
| 226 | + with: |
| 227 | + targets: ${{ matrix.target }} |
| 228 | + |
| 229 | + - name: Install dependencies |
| 230 | + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libclang-dev |
| 231 | + |
| 232 | + - name: Cache cargo |
| 233 | + uses: actions/cache@v4 |
| 234 | + with: |
| 235 | + path: | |
| 236 | + ~/.cargo/registry |
| 237 | + ~/.cargo/git |
| 238 | + target |
| 239 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 240 | + |
| 241 | + - name: Build |
| 242 | + env: |
| 243 | + ANDROID_NDK_ROOT: ${{ env.ANDROID_NDK_LATEST_HOME }} |
| 244 | + run: | |
| 245 | + export CC="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.target }}34-clang" |
| 246 | + export CARGO_TARGET_$(echo ${{ matrix.target }} | tr '[:lower:]-' '[:upper:]_')_LINKER=$CC |
| 247 | + export CLANG_PATH=$CC |
| 248 | + export RUSTFLAGS="-C link-arg=-Wl,-z,max-page-size=0x4000" |
| 249 | + cargo build --target ${{ matrix.target }} --release |
| 250 | +
|
| 251 | + - name: Collect artifacts |
| 252 | + run: | |
| 253 | + mkdir -p artifacts/${{ matrix.rid }} |
| 254 | + cp target/${{ matrix.target }}/release/libcircom_witnesscalc.so artifacts/${{ matrix.rid }}/ |
| 255 | + cp target/${{ matrix.target }}/release/libcircom_witnesscalc.a artifacts/${{ matrix.rid }}/ |
| 256 | +
|
| 257 | + - name: Upload artifacts |
| 258 | + uses: actions/upload-artifact@v4 |
| 259 | + with: |
| 260 | + name: circom-witnesscalc-${{ matrix.rid }} |
| 261 | + path: artifacts/${{ matrix.rid }} |
| 262 | + if-no-files-found: error |
| 263 | + |
| 264 | + upload-release: |
| 265 | + if: github.event_name == 'release' |
| 266 | + needs: [build-windows-x86_64, build-linux-x86_64, build-linux-arm64, build-macos-arm64, build-macos-x86_64, build-android] |
| 267 | + runs-on: ubuntu-latest |
| 268 | + steps: |
| 269 | + - name: Download all artifacts |
| 270 | + uses: actions/download-artifact@v4 |
| 271 | + with: |
| 272 | + path: all-artifacts |
| 273 | + |
| 274 | + - name: Create release zips |
| 275 | + run: | |
| 276 | + cd all-artifacts |
| 277 | + for dir in */; do |
| 278 | + name="${dir%/}" |
| 279 | + zip -r "../${name}-${{ github.ref_name }}.zip" "$dir" |
| 280 | + done |
| 281 | +
|
| 282 | + - name: Upload to release |
| 283 | + env: |
| 284 | + GH_TOKEN: ${{ github.token }} |
| 285 | + run: | |
| 286 | + for zip in *.zip; do |
| 287 | + gh release upload ${{ github.event.release.tag_name }} "$zip" -R ${{ github.repository }} |
| 288 | + done |
0 commit comments