-
Notifications
You must be signed in to change notification settings - Fork 287
Use changesets for releases, use Node 20 #1154
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
Changes from all commits
3985698
8205e0e
447a0ac
e8d91d5
0b8fb0f
ffc9bc5
fffad15
f54de13
6f52be5
3584648
00cad47
f21bc31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
| "changelog": [ | ||
| "@changesets/changelog-github", | ||
| { | ||
| "repo": "OpenZeppelin/openzeppelin-upgrades" | ||
| } | ||
| ], | ||
| "commit": false, | ||
| "fixed": [], | ||
| "linked": [], | ||
| "access": "public", | ||
| "baseBranch": "master", | ||
| "updateInternalDependencies": "patch", | ||
| "ignore": [] | ||
| } |
| 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@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 | ||
| 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 }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Publish Packages | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: version-or-publish-${{ github.ref }} | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Packages | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| environment: publish | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 | ||
| with: | ||
| fetch-depth: 0 # To get all tags | ||
| ref: ${{ github.ref }} | ||
| - name: Set up environment | ||
| uses: ./.github/actions/setup | ||
| - name: Create Prepare Release PR or Publish | ||
| id: changesets | ||
| uses: changesets/action@001cd79f0a536e733315164543a727bdf2d70aff # v1.5.1 | ||
| with: | ||
| title: Prepare Release | ||
| commit: Prepare Release | ||
| version: npm run version | ||
| publish: npm run publish | ||
| commitMode: github-api | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
ericglau marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future reference making comment to enable config provenance when pushing
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding link to related comment for tracking: OpenZeppelin/contracts-wizard#528 (comment) |
||
| - name: Check changesets status | ||
| if: steps.changesets.outputs.hasChangesets == 'true' | ||
| run: | | ||
| echo "Changesets found. Merge Prepare Release PR before publishing." | ||
| exit 1 | ||
| - name: Check publish status | ||
| if: steps.changesets.outputs.published == 'false' | ||
| run: | | ||
| echo "Publish failed. Check the logs for more details." | ||
| exit 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Version Packages | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| paths-ignore: | ||
| - 'docs/**' | ||
|
|
||
| concurrency: version-or-publish-${{ github.ref }} | ||
|
|
||
| jobs: | ||
| version: | ||
| name: Prepare Release PR | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 | ||
| with: | ||
| fetch-depth: 0 # To get all tags | ||
| ref: ${{ github.ref }} | ||
| - name: Set up environment | ||
| uses: ./.github/actions/setup | ||
| - name: Create Prepare Release PR | ||
| uses: changesets/action@001cd79f0a536e733315164543a727bdf2d70aff # v1.5.1 | ||
| with: | ||
| title: Prepare Release | ||
| commit: Prepare Release | ||
| version: npm run version | ||
| commitMode: github-api | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this specifically for signing commits or any other advantages over cli?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, according to the Changesets changelog,
|
||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 18 | ||
| 20 |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| // Adjusts the format of the changelog that changesets generates. | ||
|
|
||
| const { readFileSync, writeFileSync } = require('fs'); | ||
| const { join } = require('path'); | ||
|
|
||
| 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 packageFolders = ['core', 'plugin-hardhat']; | ||
| for (const folder of packageFolders) { | ||
| console.log(`Formatting changelog for ${folder}...`); | ||
| const packageDir = join('./packages', folder); | ||
| formatChangelog(packageDir); | ||
| } |
| 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 |
| 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.js |
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.
❤️