-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Add semantic versioning and proper export of koalabear fields #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
03642e1
fix: Made Poseidon2KoalaBera const as public and added semantic versi…
ch4r10t33r 50028fc
fix: Exported the koalabear16 module properly from root.zig
ch4r10t33r 172da72
fix: corrected lint errors
ch4r10t33r f1ab6c1
fix: corrected error in ci workflow
ch4r10t33r 1a0441d
fix: Corrected the GH workflow to release a verion on the release branch
ch4r10t33r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| name: Auto Release on Release Branch | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - release | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| auto-release: | ||
| # Only run if PR was merged to release branch (not just closed) | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Fetch all history for versioning | ||
|
|
||
| - name: Setup Zig | ||
| uses: goto-bus-stop/setup-zig@v2 | ||
| with: | ||
| version: 0.14.1 | ||
|
|
||
| - name: Read VERSION file | ||
| id: get_version | ||
| run: | | ||
| VERSION=$(cat VERSION) | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Check if tag exists | ||
| id: check_tag | ||
| run: | | ||
| if git rev-parse "v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then | ||
| echo "exists=true" >> $GITHUB_OUTPUT | ||
| echo "⚠️ Tag v${{ steps.get_version.outputs.version }} already exists" | ||
| else | ||
| echo "exists=false" >> $GITHUB_OUTPUT | ||
| echo "✅ Tag v${{ steps.get_version.outputs.version }} does not exist" | ||
| fi | ||
|
|
||
| - name: Run tests | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| run: zig build test | ||
|
|
||
| - name: Build library | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| run: zig build | ||
|
|
||
| - name: Update build.zig.zon version | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| run: | | ||
| VERSION="${{ steps.get_version.outputs.version }}" | ||
| sed -i "s/\.version = \".*\"/\.version = \"$VERSION\"/" build.zig.zon | ||
|
|
||
| - name: Generate changelog | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| id: changelog | ||
| run: | | ||
| VERSION="${{ steps.get_version.outputs.version }}" | ||
|
|
||
| # Get previous tag | ||
| PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | ||
|
|
||
| if [ -z "$PREV_TAG" ]; then | ||
| echo "## 🎉 Initial Release" > CHANGELOG.md | ||
| echo "" >> CHANGELOG.md | ||
| echo "First release of zig-poseidon - A Zig implementation of Poseidon2 hash function." >> CHANGELOG.md | ||
| echo "" >> CHANGELOG.md | ||
| echo "### Features" >> CHANGELOG.md | ||
| echo "- BabyBear field (p = 2³¹ - 2²⁷ + 1) for Ethereum Lean chain" >> CHANGELOG.md | ||
| echo "- KoalaBear field (p = 2³¹ - 2²⁴ + 1) for plonky3 and Rust hash-sig compatibility" >> CHANGELOG.md | ||
| echo "- Generic Montgomery form implementation" >> CHANGELOG.md | ||
| echo "- Compression mode for Merkle Trees" >> CHANGELOG.md | ||
| echo "- Comprehensive test suite" >> CHANGELOG.md | ||
| else | ||
| echo "## Changes since $PREV_TAG" > CHANGELOG.md | ||
| echo "" >> CHANGELOG.md | ||
| git log "$PREV_TAG"..HEAD --pretty=format:"- %s (%h)" >> CHANGELOG.md | ||
| fi | ||
|
|
||
| cat CHANGELOG.md | ||
|
|
||
| - name: Create Git tag | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -a "${{ steps.get_version.outputs.tag }}" -m "Release ${{ steps.get_version.outputs.tag }}" | ||
| git push origin "${{ steps.get_version.outputs.tag }}" | ||
|
|
||
| - name: Create GitHub Release | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ steps.get_version.outputs.tag }} | ||
| name: Release ${{ steps.get_version.outputs.tag }} | ||
| body_path: CHANGELOG.md | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Calculate tarball hash | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| id: tarball_hash | ||
| run: | | ||
| VERSION="${{ steps.get_version.outputs.version }}" | ||
| TARBALL_URL="https://github.com/${{ github.repository }}/archive/v${VERSION}.tar.gz" | ||
|
|
||
| # Download and calculate hash | ||
| curl -L "$TARBALL_URL" -o release.tar.gz | ||
| HASH=$(zig fetch release.tar.gz 2>&1 | grep -o '12[0-9a-f]*' || echo "") | ||
|
|
||
| if [ -z "$HASH" ]; then | ||
| echo "⚠️ Could not calculate hash automatically" | ||
| echo "📦 Users can get the hash by running:" | ||
| echo " zig fetch --save $TARBALL_URL" | ||
| else | ||
| echo "hash=$HASH" >> $GITHUB_OUTPUT | ||
| echo "📦 Tarball hash: $HASH" | ||
| fi | ||
|
|
||
| - name: Post release information | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| run: | | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| echo "🎉 Release ${{ steps.get_version.outputs.tag }} created successfully!" | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| echo "" | ||
| echo "📦 To use this release in your project's build.zig.zon:" | ||
| echo "" | ||
| echo ".dependencies = .{" | ||
| echo " .poseidon = .{" | ||
| echo " .url = \"https://github.com/${{ github.repository }}/archive/${{ steps.get_version.outputs.tag }}.tar.gz\"," | ||
| echo " .hash = \"${{ steps.tarball_hash.outputs.hash }}\"," | ||
| echo " }," | ||
| echo "}," | ||
| echo "" | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
|
|
||
| - name: Skip release (tag exists) | ||
| if: steps.check_tag.outputs.exists == 'true' | ||
| run: | | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| echo "⚠️ Skipping release - tag ${{ steps.get_version.outputs.tag }} already exists" | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| echo "" | ||
| echo "To create a new release:" | ||
| echo "1. Update the VERSION file with a new version number" | ||
| echo "2. Commit the change" | ||
| echo "3. Create and merge a PR" | ||
| echo "" | ||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 0.2.0 | ||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| .{ | ||
| .name = .zig_poseidon, | ||
| .version = "0.2.0", | ||
| .fingerprint = 0x4cb45c65d8967708, | ||
| .minimum_zig_version = "0.14.0", | ||
|
|
||
| .dependencies = .{}, | ||
|
|
||
| .paths = .{ | ||
| "build.zig", | ||
| "build.zig.zon", | ||
| "src", | ||
| "README.md", | ||
| "LICENSE", | ||
| "VERSION", | ||
| }, | ||
| } | ||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Root module for zig-poseidon | ||
| // Re-exports all components | ||
|
|
||
| pub const babybear16 = @import("instances/babybear16.zig"); | ||
| pub const koalabear16 = @import("instances/koalabear16.zig"); | ||
| pub const poseidon2 = @import("poseidon2/poseidon2.zig"); | ||
|
|
||
| // Convenience type exports | ||
| pub const Poseidon2BabyBear = babybear16.Poseidon2BabyBear; | ||
| pub const Poseidon2KoalaBear = koalabear16.Poseidon2KoalaBear; | ||
|
|
||
| test { | ||
| @import("std").testing.refAllDecls(@This()); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to release every time a PR is merged, we can have a release branch on which we create release PRs from main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected this now.