Skip to content

Commit

Permalink
release versioning (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel authored Oct 24, 2024
1 parent e90dded commit 55ac7bd
Showing 1 changed file with 86 additions and 3 deletions.
89 changes: 86 additions & 3 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
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: |
Expand Down Expand Up @@ -47,6 +49,28 @@ jobs:
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
Expand All @@ -66,6 +90,54 @@ jobs:
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
Expand All @@ -87,10 +159,21 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: circom-artifacts.zip
name: Circuit Artifacts ${{ github.sha }}
tag_name: v${{ github.run_number }}
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 }}
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

0 comments on commit 55ac7bd

Please sign in to comment.