Skip to content

Conversation

@andrew-fleming
Copy link
Contributor

@andrew-fleming andrew-fleming commented Aug 24, 2025

Types of changes

What types of changes does your code introduce to OpenZeppelin Midnight Contracts?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Fixes #134.
Waiting on #210.

PR Checklist

  • I have read the Contributing Guide
  • I have added tests that prove my fix is effective or that my feature works
  • I have added documentation of new methods and any new behavior or changes to existing behavior
  • CI Workflows Are Passing

Overview

  • Add a release workflow
  • Add a version bump (prepare-release) workflow
  • Move compact compiler installation to composite setup
  • Add releasing doc for instructions on how to release

Packaging

The build logic creates a dist directory and copies the repo structure but removes src/ from the path. Therefore, the path from contracts/ looks like this: contracts/dist/access/...

Each subdirectory includes the associated Compact modules and witnesses/. The files within witnesses/ are compiled to support .ts and .js (no source maps)

This packaging allows users to import compact modules and witnesses like this:

import "./node_modules/@openzeppelin-compact/contracts/access/AccessControl" prefix AccessControl_;
import "./node_modules/@openzeppelin-compact/contracts/access/witnesses/AccessControlWitnesses";

Release flow

The release process is more thoroughly documented in RELEASING.md, but here's the condensed flow:

  1. Checkout the branch to be released (main unless hotfix).
  2. Create a new release branch.
  3. Push and open a PR targeting main for manual review + approval.
    • This triggers the prepare-release workflow that bumps the version.
  4. Pull changes then create and push the release tag from the release branch.
  5. Publish release in GitHub.
    • This triggers the release workflow that will publish to npm.
  6. From the released tag, create and push a docs branch.
    • The docs aren't hooked up to a version yet, but this should be done as soon as the first release is shipped.

Other notes

  • This PR could also wait on the compact tool chain Integrate compact toolchain #200. This should simplify the compiler installation process in actions/setup/action.yml
  • There's support for skipping the compilation setup for docs-only PRs which can be easily integerated in the future
  • This PR adds metadata to contracts manifest but removes private to allow publishing

@andrew-fleming andrew-fleming marked this pull request as ready for review August 28, 2025 22:39
@andrew-fleming andrew-fleming requested a review from a team as a code owner August 28, 2025 22:39
@@ -0,0 +1,42 @@
# Releasing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we document when to use release-v0.2.0-alpha, release-v0.2.0-beta, release-v0.2.0-rc? Do we plan on having a stable and unstable branch in the future? It seems like the workflow changes are laying the groundwork for the latter, but I didn't see any explicit mention of it. I bring this up only for documentation purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions!

Should we document when to use release-v0.2.0-alpha, release-v0.2.0-beta, release-v0.2.0-rc?

This feels more like an internal discussion, but my initial take is that dist-tags aren't really necessary until there's a major release. The other argument though is to have a formal process right away and treat minor versions similar to major (until there's a major release) i.e. release-v0.1.0-rc0... rc1... -> release-v0.1.0

Do we plan on having a stable and unstable branch in the future?

I think it makes sense in the future (if not now) with audits, bug bounties, experimental features, etc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels more like an internal discussion, but my initial take is that dist-tags aren't really necessary until there's a major release. The other argument though is to have a formal process right away and treat minor versions similar to major (until there's a major release) i.e. release-v0.1.0-rc0... rc1... -> release-v0.1.0

I'm thinking we can put this off until we get closer to Compact 1.0

I think it makes sense in the future (if not now) with audits, bug bounties, experimental features, etc

I'm down to get this ball rolling sooner rather than later

Co-authored-by: ⟣ €₥ℵ∪ℓ ⟢ <[email protected]>
Signed-off-by: Andrew Fleming <[email protected]>
Copy link
Contributor

@emnul emnul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Approving, but we should wait for Son's review before merging

Copy link

@son-oz son-oz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to set up branch protection rule for the release-v* branch

# Publish the tarball with appropriate tag
npm publish "${{ steps.pack.outputs.tarball }}" --tag "${{ steps.pack.outputs.tag }}" --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to switch this over to Trusted Publishing later. I am tracking that on my side.

mkdir -p "$COMPACT_ZIP_DIR"
ZIP_FILE="compactc_v${COMPILER_VERSION}_x86_64-unknown-linux-musl.zip"
DOWNLOAD_URL="https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_${COMPILER_VERSION}/${ZIP_FILE}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to extract these out to Actions variables instead of hardcoding, can be a separate improvement PR later.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also would like to see some verification for the downloaded file, like a SHA256 hash or something.


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if nodejs is available in the runner?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is supported in the runner but I will add this part to be safe:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve contracts manifest metadata Add release workflow

4 participants