Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
92b46a8
add wrapAsEither circuits
andrew-fleming Aug 16, 2025
9fc5bbe
add option to compile directory in compact
andrew-fleming Aug 17, 2025
98b7a32
add granular compile scripts
andrew-fleming Aug 17, 2025
ae9e311
fix fmt
andrew-fleming Aug 17, 2025
4a9885b
use fast compilation prior to tests, cache tests
andrew-fleming Aug 17, 2025
d707d28
revert changes
andrew-fleming Aug 18, 2025
d113802
update readme with targeted compilation
andrew-fleming Aug 18, 2025
c004dd8
build preserves dir structure
andrew-fleming Aug 21, 2025
6de7a17
keep compact files in directories in dist, add tsc in build
andrew-fleming Aug 23, 2025
787f91b
include explicit witnesses in tsconfig, remove sourceMap
andrew-fleming Aug 23, 2025
865aa11
move compact compiler install to composite action
andrew-fleming Aug 23, 2025
579ef4d
add prepare-release workflow (version bump)
andrew-fleming Aug 23, 2025
7f64555
add release workflow
andrew-fleming Aug 23, 2025
f2067a8
add releasing doc
andrew-fleming Aug 23, 2025
f6c7c5c
remove comment
andrew-fleming Aug 23, 2025
d46ffaf
remove unused env, remove redundant compile in favor of build
andrew-fleming Aug 23, 2025
f71f616
add provenance
andrew-fleming Aug 23, 2025
9f9be1e
remove private field from contracts
andrew-fleming Aug 24, 2025
60b5b3a
add manifest metadata, remove private field
andrew-fleming Aug 24, 2025
67c95ff
fix fmt
andrew-fleming Aug 24, 2025
9982d95
improve find pattern
andrew-fleming Aug 24, 2025
5cb6300
further improve find pattern
andrew-fleming Aug 24, 2025
810e5d0
Merge branch 'main' into support-releasing
andrew-fleming Aug 28, 2025
fd96741
fix conflicts
andrew-fleming Aug 28, 2025
90f8762
Apply suggestions from code review
andrew-fleming Aug 29, 2025
e5e650f
Standardize zero address structure
emnul May 28, 2025
ae88fea
fix: compcat install url variable
0xisk Oct 31, 2025
88728ba
fix: trusted publisher, and node check
0xisk Nov 3, 2025
a5f27b9
fix: conflicts with main
0xisk Nov 3, 2025
e2b244c
fix: requested changes from code rabbit
0xisk Nov 3, 2025
2233d58
fix: ci issues
0xisk Nov 3, 2025
e06d048
fix: ci issues
0xisk Nov 3, 2025
0028e18
Updates codeql-action to latest version
emnul Nov 3, 2025
83b8129
Updates setup-node to v6
emnul Nov 3, 2025
006522e
Update compact version and setup-node action version
emnul Nov 4, 2025
8c5674c
Merge branch 'main' into fix/release-issues
emnul Nov 4, 2025
a279b5a
Updates Compact version in various file docs, tooling, etc
emnul Nov 4, 2025
35dfd69
Use pinned OS version
emnul Nov 4, 2025
98a2dba
Use latest setup-node version
emnul Nov 4, 2025
11755b8
Use pinned OS runner version
emnul Nov 4, 2025
42b2b9e
biome lint fix
emnul Nov 4, 2025
d11542f
Ensure default compiler version is set
emnul Nov 4, 2025
ec0845b
Merge branch 'main' into fix/release-issues
emnul Nov 4, 2025
fc8ffb1
Merge branch 'main' into fix/release-issues
emnul Nov 7, 2025
9072d97
fix: .github/workflows/prepare-release.yml
0xisk Nov 7, 2025
3bab84a
fix: .github/workflows/prepare-release.yml
0xisk Nov 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"dockerfile": "Dockerfile"
},
"postCreateCommand": "code --install-extension /tmp/compact.vsix && compact update 0.26.0"
}
}
112 changes: 108 additions & 4 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
name: "Setup Environment"
description: "Sets up the environment with yarn, Node.js, and turbo"
description: "Sets up the environment with yarn, Node.js, turbo, and Compact compiler"

inputs:
skip-compact:
description: "Skip Compact compiler installation"
required: false
default: "false"

outputs:
compact-home:
description: "Path to Compact compiler installation"
value: ${{ steps.compact-outputs.outputs.compact-home }}
compact-version:
description: "Installed Compact compiler version"
value: ${{ steps.compact-outputs.outputs.version }}

runs:
using: "composite"
steps:
- name: Enable Corepack
- name: Set shared environment variables
shell: bash
run: |
echo "COMPILER_VERSION=0.26.0" >> $GITHUB_ENV
echo "LANGUAGE_VERSION=0.18.0" >> $GITHUB_ENV

- name: Get yarn cache directory path
shell: bash
run: corepack enable

Expand All @@ -16,8 +36,17 @@ runs:
restore-keys: |
${{ runner.os }}-turbo-${{ hashFiles('.turbo/*') }}

- name: Cache Compact compiler
if: inputs.skip-compact != 'true'
uses: actions/cache@v4
id: compact-cache
with:
path: |
~/.local/bin/compact
key: compact-compiler-${{ env.COMPILER_VERSION }}-${{ runner.os }}

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
cache: "yarn"
Expand All @@ -31,5 +60,80 @@ runs:
env:
TURBO_MAJOR_VERSION: 2
TURBO_TELEMETRY_DISABLED: 1
run: npm install turbo@${{ env.TURBO_MAJOR_VERSION }} -g

- name: Install Compact compiler
if: inputs.skip-compact != 'true' && steps.compact-cache.outputs.cache-hit != 'true'
shell: bash
run: |
npm install turbo@${{ env.TURBO_MAJOR_VERSION }} -g
set -euo pipefail
COMPACT_HOME="$HOME/.local/bin"
mkdir -p "$COMPACT_HOME"

# Require COMPACT_INSTALLER_URL to be provided by the caller
if [ -z "${COMPACT_INSTALLER_URL:-}" ]; then
echo "::error::COMPACT_INSTALLER_URL is required but not set. Provide it via env or secrets."
exit 1
fi

echo "🔧 Installing Compact compiler from $COMPACT_INSTALLER_URL ..."
curl --proto '=https' --tlsv1.2 -LsSf "$COMPACT_INSTALLER_URL" | sh

echo "🔧 Updating Compact compiler to $COMPILER_VERSION..."
"$COMPACT_HOME/compact" update "$COMPILER_VERSION"

echo "✅ Compact compiler installed"

- name: Setup Compact environment
if: inputs.skip-compact != 'true'
shell: bash
run: |
COMPACT_HOME="$HOME/.local/bin"
echo "📁 Setting Compact environment variables..."
echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV"
echo "$COMPACT_HOME" >> "$GITHUB_PATH"

if [ -f "$COMPACT_HOME/compact" ]; then
echo "✅ Compact compiler is installed at $COMPACT_HOME"
else
echo "::error::❌ Compact compiler not found in $COMPACT_HOME"
exit 1
fi

- name: Set Compact outputs
if: inputs.skip-compact != 'true'
id: compact-outputs
shell: bash
run: |
echo "compact-home=$HOME/.local/bin" >> $GITHUB_OUTPUT
echo "version=$COMPILER_VERSION" >> $GITHUB_OUTPUT

- name: Check compiler and language version
if: inputs.skip-compact != 'true'
shell: bash
run: |
set -euo pipefail

echo "🔧 Updating Compact compiler to $COMPILER_VERSION..."
"$COMPACT_HOME/compact" update "$COMPILER_VERSION"

echo "🔍 Checking Compact compiler version..."
COMPILER_OUTPUT=$("$COMPACT_HOME/compact" compile --version)
COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1)

if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then
echo "::error::❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION"
exit 1
fi
echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION"

echo "🔍 Checking Compact language version..."
LANGUAGE_OUTPUT=$("$COMPACT_HOME/compact" compile --language-version)
COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | tail -n 1)

if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then
echo "::error::❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION"
exit 1
fi
echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION"

3 changes: 3 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
name: Run Checks
runs-on: ubuntu-24.04

env:
COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }}

steps:
- name: Check out code
uses: actions/checkout@v5
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
matrix:
language: ["javascript", "typescript"]

env:
COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }}

steps:
- name: Check out code
uses: actions/checkout@v5
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Update version on new release branch

on:
create:

permissions:
contents: write
pull-requests: write

jobs:
update_version:
if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/release-v')
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
cache: "yarn"

- name: Extract current version
run: |
CURRENT_VERSION=$(node -p "require('./contracts/package.json').version")
echo "CURRENT_VERSION=$CURRENT_VERSION" >> "$GITHUB_ENV"

- name: Extract new version number
run: echo "NEW_VERSION=${GITHUB_REF#refs/heads/release-v}" >> "$GITHUB_ENV"

- name: Validate new version
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
echo "Branch: $BRANCH"
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"

# 1) Branch must match release-v<semver>
if ! echo "$BRANCH" | grep -Eq '^release-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
echo "Error: Branch '$BRANCH' must match 'release-v<semver>' (e.g., release-v1.2.3)." >&2
exit 1
fi

# 2) NEW_VERSION must be valid semver
node -e "const v=process.env.NEW_VERSION; const semver=/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/; if(!semver.test(v)){ console.error('Error: NEW_VERSION is not valid semver:', v); process.exit(1); }"
if [ $? -ne 0 ]; then
exit 1
fi

# 3) NEW_VERSION must differ from CURRENT_VERSION
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Error: NEW_VERSION equals CURRENT_VERSION ($CURRENT_VERSION). Nothing to release." >&2
exit 1
fi

- name: Replace version in files
env:
NEW_VERSION: ${{ env.NEW_VERSION }}
run: |
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"

# Update package.json version field manually
yarn workspace @openzeppelin-compact/contracts version "$NEW_VERSION"

# Escape special characters for sed
ESCAPED_CURRENT=$(printf '%s' "$CURRENT_VERSION" | sed -e 's/[\/&]/\\&/g')
ESCAPED_NEW=$(printf '%s' "$NEW_VERSION" | sed -e 's/[\/&]/\\&/g')

# Replace version in contracts/src/
find ./contracts/src/ -type d -name '.*' -prune -o \
-type f -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} +

# Replace version in docs/, excluding package-lock.json
find ./docs/ -type d -name '.*' -prune -o \
-type f ! -name 'package-lock.json' -exec sed -i "s#$ESCAPED_CURRENT#$ESCAPED_NEW#g" {} +

- name: Auto-commit changes
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 #v6.0.1
with:
commit_message: Bump version to ${{ env.NEW_VERSION }}
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish Package on Release

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write

env:
COMPACT_INSTALLER_URL: ${{ vars.COMPACT_INSTALLER_URL }}

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Environment
uses: ./.github/actions/setup

- name: Build contracts
run: turbo build --filter=!'docs'

- name: Validate version consistency
run: |
RELEASE_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./contracts/package.json').version")
if [ "$RELEASE_VERSION" != "$PACKAGE_VERSION" ]; then
echo "❌ Version mismatch: Release $RELEASE_VERSION vs Package $PACKAGE_VERSION"
exit 1
fi
echo "✅ Version consistency validated: $RELEASE_VERSION"

- name: Setup npm registry
uses: actions/setup-node@v6
with:
registry-url: "https://registry.npmjs.org"

- name: Pack tarball
id: pack
run: |
cd contracts/dist
TARBALL=$(npm pack | tail -1)
echo "tarball_name=$TARBALL" >> $GITHUB_OUTPUT
echo "tarball=$(pwd)/$TARBALL" >> $GITHUB_OUTPUT

# Determine dist-tag based on semver prerelease
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [[ "$PACKAGE_VERSION" =~ -.*$ ]]; then
# Has prerelease suffix (anything after -)
if [[ "$PACKAGE_VERSION" =~ -(alpha|beta|rc) ]]; then
echo "tag=beta" >> $GITHUB_OUTPUT
else
echo "tag=next" >> $GITHUB_OUTPUT
fi
else
# Stable release
echo "tag=latest" >> $GITHUB_OUTPUT
fi

- name: Verify tarball integrity
run: |
echo "=== Verifying tarball contents ==="
PACKAGE_NAME=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .name)
PACKAGE_VERSION=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .version)
PRIVATE_FIELD=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r '.private // "not found"')

echo "📦 Package: $PACKAGE_NAME@$PACKAGE_VERSION"
echo "🏷️ Tag: ${{ steps.pack.outputs.tag }}"
echo "🔒 Private field: $PRIVATE_FIELD"

# Ensure no private field
if [ "$PRIVATE_FIELD" = "true" ]; then
echo "❌ Tarball contains private: true - cannot publish"
exit 1
fi

- name: Publish to npm
run: |
# Publish the tarball with appropriate tag
npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public --provenance
env:
NPM_CONFIG_PROVENANCE: true

- name: Log success
run: |
PACKAGE_NAME=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .name)
PACKAGE_VERSION=$(tar xfO "${{ steps.pack.outputs.tarball }}" package/package.json | jq -r .version)
echo "✅ Successfully published $PACKAGE_NAME@$PACKAGE_VERSION to npm with tag ${{ steps.pack.outputs.tag }}"
echo "📦 Install with: npm install $PACKAGE_NAME@${{ steps.pack.outputs.tag }}"
Loading
Loading