chore: merge parser attestor #12
Workflow file for this run
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: build-circuits | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Need full history to compare with previous release | |
- name: Install Protocol Buffers | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y protobuf-compiler libprotobuf-dev | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly-2024-06-10 | |
- name: Install Circom | |
run: | | |
CIRCOM_VERSION=2.1.9 | |
curl -L https://github.com/iden3/circom/releases/download/v$CIRCOM_VERSION/circom-linux-amd64 -o circom | |
chmod +x circom | |
sudo mv circom /usr/local/bin/ | |
circom --version | |
- name: Install circom-witnesscalc | |
run: | | |
cd .. && git clone https://github.com/pluto/circom-witnesscalc.git | |
cd circom-witnesscalc | |
cargo install --path . | |
echo $(which build-circuit) | |
- name: Install Node.js dependencies | |
run: | | |
npm install | |
- name: Get current version | |
id: current_version | |
run: | | |
CURRENT_VERSION=$(node -p "require('./package.json').version") | |
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | |
- name: Download previous artifacts | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
# Get the latest release tag | |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none") | |
if [ "$LATEST_TAG" != "none" ]; then | |
mkdir -p previous_artifacts | |
# Download and extract previous artifacts | |
curl -L $(gh release download $LATEST_TAG -p "*.zip" --json assets -q ".[0].url") -o previous.zip || true | |
if [ -f previous.zip ]; then | |
unzip -q previous.zip -d previous_artifacts | |
fi | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Compile Circom circuits | |
run: | | |
mkdir -p artifacts | |
for circuit in circuits/*.circom; do | |
if [ -f "$circuit" ]; then | |
filename=$(basename "$circuit" .circom) | |
output_dir="artifacts/$filename" | |
mkdir -p "$output_dir" | |
echo "Processing $filename..." | |
# Run circom compilation | |
circom "$circuit" --r1cs --wasm -o "$output_dir" -l node_modules | |
# Run witness calculator build | |
build-circuit "$circuit" "$output_dir/$filename.bin" -l node_modules | |
fi | |
done | |
- name: Check for R1CS changes and update version | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
id: version_check | |
run: | | |
NEEDS_BUMP=false | |
# Compare R1CS files if previous artifacts exist | |
if [ -d "previous_artifacts" ]; then | |
for r1cs in artifacts/*/*.r1cs; do | |
filename=$(basename $r1cs) | |
dirname=$(dirname $r1cs) | |
basedir=$(basename $dirname) | |
if [ -f "previous_artifacts/$basedir/$filename" ]; then | |
if ! cmp -s "$r1cs" "previous_artifacts/$basedir/$filename"; then | |
echo "R1CS change detected in $filename" | |
NEEDS_BUMP=true | |
break | |
fi | |
else | |
echo "New R1CS file detected: $filename" | |
NEEDS_BUMP=true | |
break | |
fi | |
done | |
else | |
echo "No previous artifacts found, will bump version" | |
NEEDS_BUMP=true | |
fi | |
if [ "$NEEDS_BUMP" = "true" ]; then | |
# Split version into components | |
IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION" | |
MAJOR="${version_parts[0]}" | |
MINOR="${version_parts[1]}" | |
PATCH="${version_parts[2]}" | |
# Increment minor version | |
NEW_VERSION="$MAJOR.$((MINOR + 1)).0" | |
echo "Updating version to $NEW_VERSION" | |
# Update package.json | |
npm version $NEW_VERSION --no-git-tag-version | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
else | |
echo "NEW_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | |
fi | |
- name: Create release artifacts | |
run: | | |
cd artifacts | |
zip -r ../circom-artifacts.zip ./* | |
cd .. | |
# Upload artifacts for PR | |
- name: Upload artifacts for PR | |
if: github.event_name == 'pull_request' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: circom-artifacts | |
path: artifacts/ | |
retention-days: 5 | |
# Create Release only on push to main | |
- name: Create Release | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: circom-artifacts.zip | |
name: Circuit Artifacts v${{ env.NEW_VERSION }} | |
tag_name: v${{ env.NEW_VERSION }} | |
body: | | |
Automated release of compiled Circom circuits | |
Version: ${{ env.NEW_VERSION }} | |
Commit: ${{ github.sha }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Commit version bump if needed | |
- name: Commit version bump | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && env.NEW_VERSION != env.CURRENT_VERSION | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add package.json | |
git commit -m "chore: bump version to ${{ env.NEW_VERSION }} [skip ci]" | |
git push |