Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
890b5c3
ci: automate the v-next release process using changesets
galargh Apr 10, 2025
c45cf55
chore: fix the hardhat-ethers version
galargh Apr 10, 2025
32a8235
fix: update lockfile after changeset version
galargh Apr 10, 2025
1b01042
fix: change the expected value of hasChangesets output
galargh Apr 10, 2025
5764c24
fix: authenticate with the npmjs registry
galargh Apr 10, 2025
79e71bd
chore: replace complex logic with js scripts
galargh Apr 11, 2025
a95cb21
fix: syntax and error handling in release scripts
galargh Apr 11, 2025
3b67142
fix: do not run dependency install tests on release PR merges
galargh Apr 11, 2025
43e9c5d
chore: revert the hardhat-ethers version change
galargh May 5, 2025
0ab8274
Merge remote-tracking branch 'origin/v-next' into v-next-release
galargh May 5, 2025
43d4625
chore: revert the hardhat-ethers version change
galargh May 5, 2025
6ab7aa3
ci: do not include hardhat-ether in the set of fixed packages
galargh May 5, 2025
7545b1b
ci: use version-alpha script as the versioning script
galargh May 5, 2025
269ef94
ci: update the changeset check
galargh May 5, 2025
2c99e91
fix: the changeset workflow
galargh May 5, 2025
1384c36
chore: rearrange the changeset check
galargh May 6, 2025
90febd1
chore: move release logic to a script
galargh May 6, 2025
5366fbf
ci: fetch base ref
galargh May 6, 2025
d0382d5
ci: fix the merge group validation
galargh May 6, 2025
4d9a915
ci: accept release token from secrets
galargh May 7, 2025
5fe4b0d
ci: create draft releases only
galargh May 7, 2025
8d0921f
ci: include version in the github release prepare output
galargh May 7, 2025
af53084
ci: use github-api to create the pull request
galargh May 7, 2025
86d3f40
ci: use pat in both places
galargh May 7, 2025
3c333bd
Merge remote-tracking branch 'origin/v-next' into v-next-release
galargh May 7, 2025
a3f98e5
ci: handle hardhat-toolbox-viem correctly
galargh May 7, 2025
debec91
docs: apply suggestions from code review
galargh May 8, 2025
644d4ef
chore: remove duplicate package json reading function
galargh May 8, 2025
6805975
Merge remote-tracking branch 'origin/v-next' into v-next-release
galargh May 8, 2025
71e94b4
Merge branch 'v-next' into v-next-release
kanej May 14, 2025
43693af
Update scripts/validate-merge-group.mjs
galargh May 14, 2025
7b58bd6
Merge branch 'v-next' into v-next-release
galargh May 14, 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
25 changes: 24 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.6.0/schema.json",
"changelog": false,
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "public",
Expand All @@ -11,6 +11,29 @@
"@nomicfoundation/template-package",
"template-*"
],
"fixed": [

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we ever wanted to stop releasing all the packages together, we could group the ones linked through peer dependency relations here instead.

[
"hardhat",
"@nomicfoundation/hardhat-errors",
"@nomicfoundation/hardhat-ethers",
Comment thread
galargh marked this conversation as resolved.
Outdated
"@nomicfoundation/hardhat-ethers-chai-matchers",
"@nomicfoundation/hardhat-ignition",
"@nomicfoundation/ignition-core",
"@nomicfoundation/hardhat-ignition-ethers",
"@nomicfoundation/ignition-ui",
"@nomicfoundation/hardhat-ignition-viem",
"@nomicfoundation/hardhat-keystore",
"@nomicfoundation/hardhat-mocha",
"@nomicfoundation/hardhat-network-helpers",
"@nomicfoundation/hardhat-node-test-reporter",
"@nomicfoundation/hardhat-node-test-runner",
"@nomicfoundation/hardhat-test-utils",
"@nomicfoundation/hardhat-typechain",
"@nomicfoundation/hardhat-utils",
"@nomicfoundation/hardhat-viem",
"@nomicfoundation/hardhat-zod-utils"
]
],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ runs:
- uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}
- uses: actions/setup-node@v4
id: setup-node
- id: setup-node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.cache-save == 'true' && 'pnpm' || '' }}
cache-dependency-path: "**/pnpm-lock.yaml"
registry-url: https://registry.npmjs.org
- id: pnpm
if: inputs.cache-save == 'false'
run: pnpm store path --silent | xargs -I {} -0 echo "path={}" | tee -a $GITHUB_OUTPUT
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/check-changeset-added.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ jobs:
check-if-changeset:
name: Check that PR has a changeset
runs-on: ubuntu-latest
# don't run this check in the changesets PR
if: github.head_ref != 'changeset-release/main'
steps:
- uses: actions/github-script@v7
with:
script: |
const isMergeGroup = context.eventName === "merge_group";

// Merge group context
if (isMergeGroup) {
console.log("Ignore changeset check for merge group.");
return;
}

const isReleasePr = process.env.GITHUB_HEAD_REF.startsWith("changeset-release/");
if (isReleasePr) {
console.log("Ignore changeset check for release PR.");
return;
}

// Single PR context
const pullNumber = context.issue.number;

Expand All @@ -51,7 +54,6 @@ jobs:

console.log("No changeset found");


const { data: pull } = await github.rest.pulls.get({
...context.issue,
pull_number: pullNumber
Expand Down
187 changes: 182 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,207 @@
name: Release

on:
# TODO: When a release PR is merged we should run a merge_group check to ensure:
# 1. The release PR is the only one in the merge group
# 2. The release PR is up-to-date with the target branch
# i.e. no other PR has been merged since the release PR was added to the merge queue
Comment thread
galargh marked this conversation as resolved.
Outdated
workflow_dispatch:
push:
branches:
- main
- v-next

defaults:
run:
shell: bash

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
contents: write # This allows us to push to the repository and create GitHub releases
pull-requests: write # This allows us to create pull requests
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- uses: ./.github/actions/setup-env
- name: Set up the environment
uses: ./.github/actions/setup-env

- name: Install Dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Create Release Pull Request
id: pr
env:
# NOTE: If we use the GITHUB_TOKEN to create the release PR, the checks will not be triggered automatically
GITHUB_TOKEN: ${{ github.token }}
Comment thread
galargh marked this conversation as resolved.
Outdated
uses: changesets/action@v1
with:
version: pnpm run version

- name: Build All Packages
if: steps.pr.outputs.hasChangesets == 'false'
run: pnpm run --recursive -no-bail --filter './v-next/**' --if-present build

- name: Publish All Packages (dry-run)
if: steps.pr.outputs.hasChangesets == 'false'
run: pnpm publish --filter "./v-next/**" -r --no-git-checks --tag next --access public --dry-run

# NOTE: When running publish on an already published package we expect it to succeed but not to release anything and not include + hardhat@ in the output.
# If it does, however, include + hardhat@ in the output, it's OK, because we'll just update the release without moving the release tag forward.
Comment thread
galargh marked this conversation as resolved.
Outdated
- name: Publish All Packages
id: publish
if: steps.pr.outputs.hasChangesets == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
echo "stdout<<EOF" >> $GITHUB_OUTPUT
pnpm publish --filter "./v-next/**" -r --no-git-checks --tag next --access public | tee -a $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Check if hardhat was published
id: hardhat
if: steps.pr.outputs.hasChangesets == 'false'
env:
STDOUT: ${{ steps.publish.outputs.stdout }}
uses: actions/github-script@v7
with:
script: |
const lines = process.env.STDOUT.split('\n')

core.info('Checking if Hardhat was published')

const line = lines.find(line => line.startsWith('+ hardhat@'))

if (line === undefined) {
core.info('Hardhat was not published')
core.setOutput('version', '')
process.exit(0)
}

const version = line.split('@')[1]
core.info(`Hardhat was published with version ${version}`)
core.setOutput('version', version)

- name: Check the version of the published package
id: version
if: steps.hardhat.outputs.version != ''
env:
VERSION: ${{ steps.hardhat.outputs.version }}
uses: actions/github-script@v7
with:
script: |
const version = process.env.VERSION

core.info('Checking if Hardhat was published as a prerelease')

// NOTE: This check would mark non-prerelease versions with - in the build tag as prereleases
Comment thread
galargh marked this conversation as resolved.
Outdated
const prerelease = version.includes('-')
if (prerelease) {
core.info('Hardhat was published as a prerelease')
core.setOutput('prerelease', true)
} else {
core.info('Hardhat was not published as a prerelease')
core.setOutput('prerelease', false)
}

core.info('Checking if this is the latest version')

if (prerelease) {
core.info('This is a prerelease, so this is not the latest version')
core.setOutput('latest', false)
process.exit(0)
}

try {
const { data: release } = await github.rest.repos.getLatestRelease(context.repo)

const latestVersion = release.tag_name.split('@')[1]
core.info(`Current latest version is ${latestVersion}`)

const [major, minor, patch] = version.split('.')
const [latestMajor, latestMinor, latestPatch] = latestVersion.split('.')

if (parseInt(major, 10) > parseInt(latestMajor, 10) ||
parseInt(minor, 10) > parseInt(latestMinor, 10) ||
parseInt(patch, 10) > parseInt(latestPatch, 10)) {
core.info('This is a new latest version')
core.setOutput('latest', true)
} else {
core.info('This is not a new latest version')
core.setOutput('latest', false)
}
} catch (error) {
if (error.status === 404) {
core.info('No existing latest release found, so this is the latest version')
core.setOutput('latest', true)
process.exit(0)
}
throw error
}

- name: Find the relevant changelog entry
id: changelog
if: steps.hardhat.outputs.version != ''
env:
VERSION: ${{ steps.hardhat.outputs.version }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs')

const changelog = fs.readFileSync('./v-next/hardhat/CHANGELOG.md').toString()
core.debug(`Changelog: ${changelog}`)

core.info('Parsing changelog...')
const lines = changelog.split('\n')
const headerIndex = lines.findIndex((line) => line == `## ${process.env.VERSION}`)

if (headerIndex == -1) {
core.error(`Changelog entry for version ${process.env.VERSION} not found in ./v-next/hardhat/CHANGELOG.md`)
process.exit(1)
}

const entryLines = [];

for (const line of lines.slice(headerIndex + 1)) {
if (line.startsWith('## ')) {
break
}
entryLines.push(line)
}

const entry = entryLines.join('\n').trim()

core.debug(`Entry: ${entry}`)
core.setOutput('entry', entry)

- name: Create GitHub Release
if: steps.hardhat.outputs.version != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
# NOTE: The action updates the release if it already exists
Comment thread
galargh marked this conversation as resolved.
Outdated
uses: galargh/action-gh-release@571276229e7c9e6ea18f99bad24122a4c3ec813f # https://github.com/galargh/action-gh-release/pull/1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we able to push this to Nomic to keep us self-contained?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like we should be able to use the https://github.com/softprops/action-gh-release version of the action instead of my fork now as both my PRs got merged there. I would leave it as a TODO for later though as I would like to carefully check what other things they introduced in their action.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah. What is it that drives pulling in an external task here? Is the GitHub API around releases just really cumbersome here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now that I think about it, we should be able to use the API directly in our case. This action is great for a little more advanced setups. Especially those where a draft gets updated over and over again. However, in our setup, we only ever create the draft once and that's it.

I'm going to update it to use the GitHub API directly. Thanks for pointing this out. I might not be able to finish it before our meeting though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool lets do that as a follow up PR.
I will mark this as approved.

with:
draft: false
tag_name: hardhat@${{ steps.hardhat.outputs.version }}
generate_release_notes: false
target_commitish: ${{ github.sha }}
make_latest: ${{ steps.version.outputs.latest == 'true' }}
prerelease: ${{ steps.version.outputs.prerelease == 'true' }}
body: |
# ${{ steps.hardhat.outputs.version }}

## Changes

${{ steps.changelog.outputs.entry }}

---
> 💡 **The Nomic Foundation is hiring! Check [our open positions](https://www.nomic.foundation/jobs).**
---
token: ${{ github.token }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"typescript": "~5.5.0"
},
"scripts": {
"version": "changeset version && pnpm install --lockfile-only",
Comment thread
galargh marked this conversation as resolved.
Outdated
"build": "pnpm run --recursive build",
"clean": "pnpm run --recursive clean",
"test": "pnpm run --recursive test",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v-next/example-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"hardhat": "workspace:^3.0.0-next.3",
"@nomicfoundation/hardhat-ethers-chai-matchers": "workspace:^3.0.0-next.3",
"@nomicfoundation/hardhat-errors": "workspace:^3.0.0-next.3",
"@nomicfoundation/hardhat-ethers": "workspace:^4.0.0-next.3",
"@nomicfoundation/hardhat-ethers": "workspace:^3.0.0-next.3",
"@nomicfoundation/hardhat-ignition": "workspace:^3.0.0-next.3",
"@nomicfoundation/ignition-core": "workspace:^3.0.0-next.3",
"@nomicfoundation/hardhat-ignition-viem": "workspace:^3.0.0-next.3",
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat-ethers-chai-matchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"peerDependencies": {
"hardhat": "workspace:^3.0.0-next.3",
"@nomicfoundation/hardhat-ethers": "workspace:^4.0.0-next.3",
"@nomicfoundation/hardhat-ethers": "workspace:^3.0.0-next.3",
"chai": "^5.1.2",
"ethers": "^6.13.4"
}
Expand Down
4 changes: 2 additions & 2 deletions v-next/hardhat-ethers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# @nomicfoundation/hardhat-ethers

## 4.0.0-next.2
## 3.0.0-next.2

### Patch Changes

- Hardhat 3 Alpha release (2025-03-20T08:38:27.809Z)

## 4.0.0-next.1
## 3.0.0-next.1

### Patch Changes

Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nomicfoundation/hardhat-ethers",
"version": "4.0.0-next.3",
"version": "3.0.0-next.3",
Comment thread
galargh marked this conversation as resolved.
Outdated
"description": "Hardhat plugin for ethers",
"homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-ethers",
"repository": {
Expand Down
Loading