Skip to content

Use changesets for releases #528

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .changeset/add-account-contract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openzeppelin/wizard': patch
---

Add `account` contract types for ERC-4337. ([#486](https://github.com/OpenZeppelin/contracts-wizard/pull/486))
- **Potentially breaking changes**:
- Update pragma versions to 0.8.27. ([#486](https://github.com/OpenZeppelin/contracts-wizard/pull/486))
19 changes: 19 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "OpenZeppelin/contracts-wizard"
}
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": [
"@openzeppelin/wizard-cairo-alpha",
"ui"
]
}
5 changes: 5 additions & 0 deletions .changeset/remove-redundant-overrides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openzeppelin/wizard': patch
---

Remove redundant overrides in Governor. ([#522](https://github.com/OpenZeppelin/contracts-wizard/pull/522))
13 changes: 13 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Setup

runs:
using: composite
steps:
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: yarn

- name: Install dependencies
run: yarn --frozen-lockfile --prefer-offline
shell: bash
28 changes: 28 additions & 0 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: changeset

on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- labeled
- unlabeled

concurrency:
group: changeset-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-changeset') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Include history so Changesets finds merge-base
- name: Set up environment
uses: ./.github/actions/setup
- name: Check changeset
run: npx changeset status --since=origin/${{ github.base_ref }}
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
branches:
- master

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
changesets:
name: Update Release PR or Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # To get all tags
- name: Set up environment
uses: ./.github/actions/setup
- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
with:
title: Release Packages
commit: Release Packages
version: npm run version
publish: npm run publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 6 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
- name: Install dependencies
run: yarn install --network-concurrency 1
- name: Set up environment
uses: ./.github/actions/setup
- name: Check formatting
run: yarn format:check
- name: Run linter
Expand All @@ -29,12 +25,8 @@ jobs:
uses: denoland/setup-deno@v2
with:
deno-version: '1.46.3'
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
- name: Install dependencies and build wizard packages
run: yarn install --frozen-lockfile
- name: Set up environment
uses: ./.github/actions/setup
- name: Deno check API
run: yarn type:check:api

Expand All @@ -50,15 +42,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
- name: Set up environment
uses: ./.github/actions/setup
- name: Install Foundry
if: matrix.package == 'solidity'
uses: foundry-rs/foundry-toolchain@v1
- name: Install dependencies
run: yarn install
- name: Compile TypeScript
run: yarn tsc
working-directory: packages/core/${{matrix.package}}
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ Then from the `packages/ui` directory:
## Creating Pull Requests (PRs)

As a contributor, we ask that you fork this repository, work on your own fork and then submit pull requests. The pull requests will be reviewed and eventually merged into the main repo. See ["Fork-a-Repo"](https://help.github.com/articles/fork-a-repo/) for how this works.

### Adding Changesets
If your PR modifies code generation logic under `packages/core`, you will need to add changesets for the relevant packages to summarize the changes. The PR's `changeset` GitHub check will give an error if this condition is not satisfied.
- To add a changeset: from the root directory, run `yarn changeset`
- If your PR does not require a changelog entry: tag the PR with the label `ignore-changeset`
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "root",
"private": true,
"type": "module",
"scripts": {
"prepare": "wsrun -m prepare",
"lint": "eslint",
Expand All @@ -10,7 +11,9 @@
"dev:ui": "yarn --cwd ./packages/ui dev",
"dev:api": "yarn --cwd ./packages/ui dev:api",
"dev": "concurrently --kill-others-on-fail --names \"UI,API\" --prefix-colors \"magenta.bold,green.bold\" \"yarn dev:ui\" \"yarn dev:api\"",
"run:core": "node ./scripts/run-command.mjs"
"run:core": "node ./scripts/run-command.mjs",
"version": "bash scripts/release/version.sh",
"publish": "bash scripts/release/publish.sh"
},
"workspaces": {
"packages": [
Expand All @@ -33,6 +36,8 @@
"prettier-plugin-svelte": "^3.3.3",
"typescript": "^5.7.3",
"typescript-eslint": "^8.29.0",
"wsrun": "^5.2.4"
"wsrun": "^5.2.4",
"@changesets/cli": "^2.29.2",
"@changesets/changelog-github": "^0.5.1"
}
}
3 changes: 1 addition & 2 deletions packages/core/cairo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"prepublish": "rimraf dist *.tsbuildinfo",
"test": "ava",
"test:update-snapshots": "ava --update-snapshots",
"test:watch": "ava --watch",
"version": "node ../../../scripts/bump-changelog.js"
"test:watch": "ava --watch"
},
"devDependencies": {
"@types/node": "^18.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/cairo_alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"prepublish": "rimraf dist *.tsbuildinfo",
"test": "ava",
"test:update-snapshots": "ava --update-snapshots",
"test:watch": "ava --watch",
"version": "node ../../../scripts/bump-changelog.js"
"test:watch": "ava --watch"
},
"devDependencies": {
"@types/node": "^18.0.0",
Expand Down
14 changes: 4 additions & 10 deletions packages/core/solidity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# Changelog

## Unreleased

- Add `account` contract types for ERC-4337. ([#486](https://github.com/OpenZeppelin/contracts-wizard/pull/486))
- Remove redundant overrides in Governor. ([#522](https://github.com/OpenZeppelin/contracts-wizard/pull/522))

- **Potentially breaking changes**:
- Update pragma versions to 0.8.27. ([#486](https://github.com/OpenZeppelin/contracts-wizard/pull/486))

## 0.5.4 (2025-04-01)

- Add validation for ERC20 premint field. ([#488](https://github.com/OpenZeppelin/contracts-wizard/pull/488))
Expand All @@ -16,7 +8,7 @@
## 0.5.3 (2025-03-13)

- Add ERC20 Cross-Chain Bridging, SuperchainERC20. ([#436](https://github.com/OpenZeppelin/contracts-wizard/pull/436))
**Note:** Cross-Chain Bridging is experimental and may be subject to change.
**Note:** Cross-Chain Bridging is experimental and may be subject to change.

- **Potentially breaking changes**:
- Change order of constructor argument `recipient` when using `premint`.
Expand Down Expand Up @@ -46,11 +38,12 @@
## 0.4.5 (2024-11-18)

- Add `stablecoin` and `realWorldAsset` contract types. ([#404](https://github.com/OpenZeppelin/contracts-wizard/pull/404))
**Note:** `stablecoin` and `realWorldAsset` are experimental and may be subject to change.
**Note:** `stablecoin` and `realWorldAsset` are experimental and may be subject to change.

## 0.4.4 (2024-10-23)

### Potentially breaking changes

- Update pragma versions to 0.8.22. ([#401](https://github.com/OpenZeppelin/contracts-wizard/pull/401))

## 0.4.3 (2024-04-08)
Expand All @@ -68,6 +61,7 @@
## 0.4.0 (2023-10-05)

### Breaking changes

- Update to OpenZeppelin Contracts 5.0. ([#284](https://github.com/OpenZeppelin/contracts-wizard/pull/284))
- Require constructor or initializer arguments for initial owner or role assignments if using access control.
- Use token-specific pausable extensions.
Expand Down
1 change: 0 additions & 1 deletion packages/core/solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"test": "ava",
"test:update-snapshots": "ava --update-snapshots",
"test:watch": "ava --watch",
"version": "node ../../../scripts/bump-changelog.js",
"update-env": "rm ./src/environments/hardhat/package-lock.json && npm install --package-lock-only --prefix ./src/environments/hardhat && rm ./src/environments/hardhat/upgradeable/package-lock.json && npm install --package-lock-only --prefix ./src/environments/hardhat/upgradeable"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/stellar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"prepublish": "rimraf dist *.tsbuildinfo",
"test": "ava",
"test:update-snapshots": "ava --update-snapshots",
"test:watch": "ava --watch",
"version": "node ../../../scripts/bump-changelog.js"
"test:watch": "ava --watch"
},
"devDependencies": {
"@types/node": "^18.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/stylus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"prepare": "tsc",
"prepublish": "rimraf dist *.tsbuildinfo",
"test": "ava",
"test:watch": "ava --watch",
"version": "node ../../../scripts/bump-changelog.js"
"test:watch": "ava --watch"
},
"devDependencies": {
"@types/node": "^18.0.0",
Expand Down
19 changes: 0 additions & 19 deletions scripts/bump-changelog.js

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/language-input.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join } from 'path';

const coreSubfolderPath = './packages/core';

function getSupportedLanguageInCoreSubfolder() {
export function getSupportedLanguageInCoreSubfolder() {
return readdirSync(coreSubfolderPath).filter(subfolder => {
const subfolderPath = join(coreSubfolderPath, subfolder);
return statSync(subfolderPath).isDirectory();
Expand Down
42 changes: 42 additions & 0 deletions scripts/release/format-changelog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

// Adjusts the format of the changelog that changesets generates.

import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { getSupportedLanguageInCoreSubfolder } from '../language-input.mjs';

function formatChangelog(dir) {
const changelogPath = join(dir, 'CHANGELOG.md');

const changelog = readFileSync(changelogPath, 'utf8');

// Groups:
// - 1: Pull Request Number and URL
// - 2: Changeset entry
const RELEASE_LINE_REGEX = /^- (\[#.*?\]\(.*?\))?.*?! - (.*)$/gm;

// Captures X.Y.Z or X.Y.Z-rc.W
const VERSION_TITLE_REGEX = /^## (\d+\.\d+\.\d+(-rc\.\d+)?)$/gm;

const formatted = changelog
// Remove titles
.replace(/^### Major Changes\n\n/gm, '')
.replace(/^### Minor Changes\n\n/gm, '')
.replace(/^### Patch Changes\n\n/gm, '')
// Remove extra whitespace between items
.replace(/^(- \[.*\n)\n(?=-)/gm, '$1')
// Format each release line
.replace(RELEASE_LINE_REGEX, (_, pr, entry) => (pr ? `- ${entry} (${pr})` : `- ${entry}`))
// Add date to new version
.replace(VERSION_TITLE_REGEX, `\n## $1 (${new Date().toISOString().split('T')[0]})`);

writeFileSync(changelogPath, formatted);
}

const languageFolders = getSupportedLanguageInCoreSubfolder();
for (const languageFolder of languageFolders) {
console.log(`Formatting changelog for ${languageFolder}...`);
const languageFolderPath = join('./packages/core', languageFolder);
formatChangelog(languageFolderPath);
}
7 changes: 7 additions & 0 deletions scripts/release/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

yarn install --frozen-lockfile
changeset publish
git push --follow-tags
7 changes: 7 additions & 0 deletions scripts/release/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

changeset version

node scripts/release/format-changelog.mjs
Loading
Loading