Unverified Commit c8f3be7e authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Clean up new release process (#85458)

parent d8cde2a5
# Changesets
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "vercel/next.js" }],
"commit": false,
"fixed": [["next", "@next/swc"]],
"linked": [],
"access": "public",
"baseBranch": "canary",
"updateInternalDependencies": "patch",
"ignore": []
}
---
"next": patch
---
Enable `ppr` when `cacheComponents` is enabled
---
'next': patch
---
Add `regions` to the function config manifest file
---
'next': patch
---
Resolved bug where hitting the parameterized path directly would cause a fallback shell generation instead of just rendering the route with the parameterized placeholders.
---
'next': patch
---
Fix the unexpected clearing of symbolic link directories
---
'next': patch
---
Fix dangling promise in unstable_cache
---
"next": patch
---
Always pass implicit/soft tags into the `CacheHandler.get` method
---
'next': patch
---
Fix to use https urls in meta data images when using --experimental-https flag
---
"next": patch
---
Do not cache fetches with 'no-store' in "use cache" during SSG
---
"next": patch
---
[TypeScript Plugin] Match method signature (`someFunc(): void`) type for client boundary warnings.
---
'next': patch
---
Fixed rewrite params of the interception routes not being parsed correctly in certain deployed environments
---
"next": patch
---
Use `onPostpone` to determine if segment prefetch is partial
---
"next": patch
---
[TypeScript Plugin] Moved the diagnostics' positions to the prop's type instead of the value for client-boundary warnings.
---
'@next/swc': patch
---
Added an experimental option for using the system CA store for fetching Google Fonts in Turbopack
---
'next': patch
---
[dev-overlay] Show error overlay on any thrown value
We used to only show the error overlay on thrown values with a stack property.
On other thrown values we kept the overlay collapsed.
---
"next": patch
---
[Segment Cache] Fix: Ensure server references can be prerendered
---
'next': patch
---
Sourcemap errors during prerender if `experimental.enablePrerenderSourceMaps` is enabled
---
"next": patch
---
Fix name tracking for closures in server actions transform
---
"next": patch
---
[cacheComponents] Avoid timeout errors with dynamic params in `"use cache"`
...@@ -19,11 +19,6 @@ env: ...@@ -19,11 +19,6 @@ env:
# #
# See https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#os-version for more details # See https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#os-version for more details
MACOSX_DEPLOYMENT_TARGET: 11.0 MACOSX_DEPLOYMENT_TARGET: 11.0
# This will become "true" if the latest commit (merged release PR) is either:
# - "Version Packages (#<number>)"
# - "Version Pacakges (canary/rc) (#<number>)"
# set from scripts/check-is-release.js
__NEW_RELEASE: 'false'
jobs: jobs:
deploy-target: deploy-target:
...@@ -53,13 +48,7 @@ jobs: ...@@ -53,13 +48,7 @@ jobs:
# 'staging' for canary branch since that will eventually be published i.e. become the production build. # 'staging' for canary branch since that will eventually be published i.e. become the production build.
id: deploy-target id: deploy-target
run: | run: |
# TODO: Remove the new release check once the new release workflow is fully replaced. if [[ $(node ./scripts/check-is-release.js 2> /dev/null || :) == v* ]];
RELEASE_CHECK=$(node ./scripts/check-is-release.js 2> /dev/null || :)
if [[ $RELEASE_CHECK == 'new-release' ]];
then
echo "__NEW_RELEASE=true" >> $GITHUB_ENV
echo "value=production" >> $GITHUB_OUTPUT
elif [[ $RELEASE_CHECK == v* ]];
then then
echo "value=production" >> $GITHUB_OUTPUT echo "value=production" >> $GITHUB_OUTPUT
elif [ '${{ github.ref }}' == 'refs/heads/canary' ] elif [ '${{ github.ref }}' == 'refs/heads/canary' ]
...@@ -611,41 +600,10 @@ jobs: ...@@ -611,41 +600,10 @@ jobs:
- run: npm i -g npm@10.4.0 # need latest version for provenance (pinning to avoid bugs) - run: npm i -g npm@10.4.0 # need latest version for provenance (pinning to avoid bugs)
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: ./scripts/publish-native.js - run: ./scripts/publish-native.js
# Legacy release process
- run: ./scripts/publish-release.js - run: ./scripts/publish-release.js
if: ${{ env.__NEW_RELEASE == 'false' }}
env: env:
RELEASE_BOT_GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} RELEASE_BOT_GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
# New release process
- name: Publish to NPM
id: changesets
# TODO: Change to IS_RELEASE condition when new release becomes stable.
if: ${{ env.__NEW_RELEASE == 'true' }}
uses: changesets/action@v1
with:
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
- name: Send a Slack notification of the publish status
# TODO: Change to IS_RELEASE condition when new release becomes stable.
if: ${{ env.__NEW_RELEASE == 'true' && (steps.changesets.outputs.published == 'true' || steps.changesets.outputs.published == 'false') }}
run: pnpm tsx scripts/release/slack.ts
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
RELEASE_STATUS: ${{ steps.changesets.outputs.published }}
WORKFLOW_LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
WORKFLOW_ACTOR: ${{ github.actor }}
- name: Upload npm log artifact
if: steps.changesets.outputs.published == 'true'
uses: actions/upload-artifact@v4
with:
name: npm-publish-logs
path: /home/runner/.npm/_logs/*
publish-turbopack-npm-packages: publish-turbopack-npm-packages:
# Matches the commit message written by turbopack/xtask/src/publish.rs:377 # Matches the commit message written by turbopack/xtask/src/publish.rs:377
if: "${{(github.ref == 'refs/heads/canary') && startsWith(github.event.head_commit.message, 'chore: release turbopack npm packages')}}" if: "${{(github.ref == 'refs/heads/canary') && startsWith(github.event.head_commit.message, 'chore: release turbopack npm packages')}}"
......
...@@ -39,8 +39,7 @@ jobs: ...@@ -39,8 +39,7 @@ jobs:
- name: check for release - name: check for release
id: is-release id: is-release
run: | run: |
RELEASE_CHECK=$(node ./scripts/check-is-release.js 2> /dev/null || :) if [[ $(node ./scripts/check-is-release.js 2> /dev/null || :) == v* ]];
if [[ $RELEASE_CHECK == "new-release" || $RELEASE_CHECK == v* ]];
then then
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
else else
......
name: Force Merge Canary Release PR
on: pull_request
permissions:
# To bypass and merge PR
pull-requests: write
jobs:
force-merge-canary-release-pr:
runs-on: ubuntu-latest
# Validate the login, PR title, and the label to ensure the PR is
# from the release PR and prevent spoofing.
if: |
github.event.pull_request.user.login == 'vercel-release-bot' &&
github.event.pull_request.title == 'Version Packages (canary)' &&
contains(github.event.pull_request.labels.*.name, 'created-by: CI')
steps:
- name: Bypass required status checks and merge PR
run: gh pr merge --admin --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
name: Trigger Release (New)
on:
# Run every day at 23:15 UTC
# TODO: Disabled cron for now, but uncomment
# once replaced the old release workflow.
# schedule:
# - cron: '15 23 * * *'
# Run manually
workflow_dispatch:
inputs:
releaseType:
description: Release Type
required: true
type: choice
# Cron job will run canary release
default: canary
options:
- canary
- stable
- release-candidate
- beta
force:
description: Forced Release
default: false
type: boolean
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
NAPI_CLI_VERSION: 2.18.4
TURBO_VERSION: 2.5.5
NODE_LTS_VERSION: 20
permissions:
# To create PR
pull-requests: write
jobs:
start:
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
# we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo
NEXT_SKIP_NATIVE_POSTINSTALL: 1
environment: release-${{ github.event.inputs.releaseType }}
steps:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true
# Since actions/checkout won't include the latest tag information,
# use the old clone workflow while still preserving branch specific
# checkout behavior to support backports.
# x-ref: https://github.com/vercel/next.js/pull/63167
- name: Clone Next.js repository
run: git clone https://github.com/vercel/next.js.git --depth=25 --single-branch --branch ${GITHUB_REF_NAME:-canary} .
- name: Check token
run: gh auth status
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
- name: Get commit of the latest tag
run: echo "LATEST_TAG_COMMIT=$(git rev-list -n 1 $(git describe --tags --abbrev=0))" >> $GITHUB_ENV
- name: Get latest commit
run: echo "LATEST_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Check if new commits since last tag
if: ${{ github.event.inputs.releaseType != 'stable' && github.event.inputs.force != true }}
run: |
if [ "$LATEST_TAG_COMMIT" = "$LATEST_COMMIT" ]; then
echo "No new commits. Exiting..."
exit 1
fi
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- name: Setup corepack
run: |
npm i -g corepack@0.31
corepack enable
pnpm --version
- id: get-store-path
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT
- uses: actions/cache@v4
timeout-minutes: 5
id: cache-pnpm-store
with:
path: ${{ steps.get-store-path.outputs.STORE_PATH }}
key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-
pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install
- run: pnpm run build
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
version: pnpm ci:version
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
RELEASE_TYPE: ${{ github.event.inputs.releaseType }}
# Add label to verify the PR is created from this workflow.
- name: Add label to PR
if: steps.changesets.outputs.pullRequestNumber
run: 'gh pr edit ${{ steps.changesets.outputs.pullRequestNumber }} --add-label "created-by: CI"'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
...@@ -17,7 +17,6 @@ packages/next/wasm/@next ...@@ -17,7 +17,6 @@ packages/next/wasm/@next
packages/next/errors.json packages/next/errors.json
.github/actions/next-stats-action/.work .github/actions/next-stats-action/.work
.changeset/*.md
crates/**/tests/**/output* crates/**/tests/**/output*
crates/core/tests/loader/issue-32553/input.js crates/core/tests/loader/issue-32553/input.js
......
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
"lerna": "lerna", "lerna": "lerna",
"dev": "turbo run dev --parallel", "dev": "turbo run dev --parallel",
"pack-next": "tsx scripts/pack-next.ts", "pack-next": "tsx scripts/pack-next.ts",
"ci:version": "tsx ./scripts/release/version-packages.ts",
"ci:publish": "tsx ./scripts/release/publish-npm.ts",
"test-types": "tsc", "test-types": "tsc",
"test-unit": "jest test/unit/ packages/next/ packages/font", "test-unit": "jest test/unit/ packages/next/ packages/font",
"test-dev-inner": "cross-env NEXT_TEST_MODE=dev pnpm testheadless", "test-dev-inner": "cross-env NEXT_TEST_MODE=dev pnpm testheadless",
...@@ -122,8 +120,6 @@ ...@@ -122,8 +120,6 @@
"@babel/plugin-syntax-explicit-resource-management": "7.25.7", "@babel/plugin-syntax-explicit-resource-management": "7.25.7",
"@babel/plugin-transform-object-rest-spread": "7.25.9", "@babel/plugin-transform-object-rest-spread": "7.25.9",
"@babel/preset-react": "7.26.3", "@babel/preset-react": "7.26.3",
"@changesets/changelog-github": "0.5.1",
"@changesets/cli": "2.29.3",
"@edge-runtime/jest-environment": "4.0.0", "@edge-runtime/jest-environment": "4.0.0",
"@emotion/cache": "11.11.0", "@emotion/cache": "11.11.0",
"@emotion/react": "11.11.1", "@emotion/react": "11.11.1",
......
This diff is collapsed.
...@@ -13,17 +13,10 @@ const checkIsRelease = async () => { ...@@ -13,17 +13,10 @@ const checkIsRelease = async () => {
const versionString = commitMsg.split(' ').pop().trim() const versionString = commitMsg.split(' ').pop().trim()
const publishMsgRegex = /^v\d{1,}\.\d{1,}\.\d{1,}(-\w{1,}\.\d{1,})?$/ const publishMsgRegex = /^v\d{1,}\.\d{1,}\.\d{1,}(-\w{1,}\.\d{1,})?$/
const newPublishMsgRegex = /^Version Packages( \((canary|rc)\))?( \(#\d+\))?$/
// When the "Version Packages" PR is merged, it may contain "\n"
// in the message when co-authored, so split and get the first one.
const newPublishPrMessage = commitMsg.split('\n')[0]
if (publishMsgRegex.test(versionString)) { if (publishMsgRegex.test(versionString)) {
console.log(versionString) console.log(versionString)
process.exit(0) process.exit(0)
} else if (newPublishMsgRegex.test(newPublishPrMessage)) {
console.log('new-release')
process.exit(0)
} else { } else {
console.log('not publish commit', { commitId, commitMsg, versionString }) console.log('not publish commit', { commitId, commitMsg, versionString })
process.exit(1) process.exit(1)
......
#!/usr/bin/env bash #!/usr/bin/env bash
RELEASE_CHECK=$(node ./scripts/check-is-release.js 2> /dev/null || :) if [[ $(node ./scripts/check-is-release.js 2> /dev/null || :) == v* ]];
if [[ $RELEASE_CHECK == "new-release" || $RELEASE_CHECK == v* ]];
then then
echo "Publish occurred, running release stats..." echo "Publish occurred, running release stats..."
else else
......
import execa from 'execa'
import semver from 'semver'
import { existsSync } from 'fs'
import { join } from 'path'
import { readdir, readFile } from 'fs/promises'
async function fetchTagsFromRegistry(packageName: string) {
const res = await fetch(
`https://registry.npmjs.org/-/package/${packageName}/dist-tags`
)
const tags = await res.json()
return tags
}
async function getTag({
name,
version,
latest,
}: {
name: string
version: string
latest: string
}): Promise<string> {
const preConfigPath = join(process.cwd(), '.changeset', 'pre.json')
if (existsSync(preConfigPath)) {
const { tag, mode } = JSON.parse(await readFile(preConfigPath, 'utf-8'))
if (mode === 'pre') {
if (!version.includes('-')) {
throw new Error(
`The changeset is in pre mode, but the version of "${name}@${version}" is not prerelease. It is likely a bug from versioning the packages.`
)
}
return tag
}
}
if (version.includes('-')) {
throw new Error(
`The changeset is not in pre mode, but the version of "${name}@${version}" is prerelease. It is likely a bug from versioning the packages.`
)
}
// If the current version is less than the latest,
// it means this is a backport release. Since NPM
// sets the 'latest' tag by default during publishing,
// when users install `next@latest`, they might get the
// backported version instead of the actual "latest"
// version. Hence, we explicitly set the tag as
// 'stable' for backports.
if (semver.lt(version, latest)) {
return 'stable'
}
return 'latest'
}
async function publishNpm() {
if (!process.env.NPM_TOKEN) {
throw new Error('NPM_TOKEN is not set')
}
const packagesDir = join(process.cwd(), 'packages')
const packageDirs = await readdir(packagesDir, {
withFileTypes: true,
})
for (const packageDir of packageDirs) {
if (!packageDir.isDirectory()) {
continue
}
const pkgJson = JSON.parse(
await readFile(
join(process.cwd(), 'packages', packageDir.name, 'package.json'),
'utf-8'
)
)
if (pkgJson.private) {
continue
}
const tags = await fetchTagsFromRegistry(pkgJson.name)
// If the current version is already published in the
// registry, skip the process.
if (semver.eq(pkgJson.version, tags.latest)) {
console.log(
`Skipping ${pkgJson.name}@${pkgJson.version} because it is already published.`
)
continue
}
const tag = await getTag({
name: pkgJson.name,
version: pkgJson.version,
latest: tags.latest,
})
const packagePath = join(packagesDir, packageDir.name)
const args = ['publish', packagePath, '--tag', tag]
console.log(
`Running command: "pnpm ${args.join(' ')}" for ${pkgJson.name}@${pkgJson.version}`
)
await execa('pnpm', args, { stdio: 'inherit' })
}
}
publishNpm()
import { WebClient } from '@slack/web-api'
async function slack() {
if (!process.env.SLACK_TOKEN) {
throw new Error('SLACK_TOKEN not set')
}
const workflowLink = process.env.WORKFLOW_LINK
if (!workflowLink) {
throw new Error('WORKFLOW_LINK not set')
}
const channel = process.env.SLACK_CHANNEL_ID ?? 'C0668R2391V' // #next-releases
// TODO: Configure SLACK_ envs for dry run testing to not ping the oncall.
// TODO: It'll become `@oncall-nextjs`
const ping = process.env.SLACK_PING ?? '@nextjs-oncall'
const message =
(process.env.SLACK_MESSAGE ?? process.env.RELEASE_STATUS === 'true')
? `Successfully published a new release!\n<https://github.com/vercel/next.js/releases|Releases Link>`
: `Failed to publish a new release triggered by "${process.env.WORKFLOW_ACTOR}". ${ping}\n<${workflowLink}|Workflow Link>`
const slackClient = new WebClient(process.env.SLACK_TOKEN)
const res = await slackClient.chat.postMessage({
channel,
text: message,
username: 'Next.js Bot',
icon_emoji: ':nextjs:',
})
if (!res.ok) {
throw new Error(
`Failed to send message "${message}" to Slack channel #next-releases: ${res.error}`
)
}
console.log('Successfully sent message to Slack!')
}
slack()
import execa from 'execa'
import { existsSync } from 'fs'
import { writeFile, readFile, unlink } from 'fs/promises'
import { join } from 'path'
// NOTE: This type may change over time.
type ChangesetStatusJson = {
changesets: {
releases: {
name: string
type: string
summary: string
id: string
}[]
}[]
releases: {
name: string
type: string
oldVersion: string
changesets: string[]
newVersion: string
}[]
}
async function versionPackages() {
const preConfigPath = join(process.cwd(), '.changeset', 'pre.json')
// Exit previous pre mode to prepare for the next release.
if (existsSync(preConfigPath)) {
if (require(preConfigPath).mode !== 'exit') {
// Since current repository is in pre mode, need
// to exit before versioning the packages.
await execa('pnpm', ['changeset', 'pre', 'exit'], {
stdio: 'inherit',
})
}
}
// For prereleases, we need to set the "mode" on `pre.json`, which
// can be done by running `changeset pre enter <mode>`.
const releaseType = process.env.RELEASE_TYPE
switch (releaseType) {
case 'canary': {
// Enter pre mode as "canary" tag.
await execa('pnpm', ['changeset', 'pre', 'enter', 'canary'], {
stdio: 'inherit',
})
console.log(
'▲ Preparing to bump the canary version, checking if there are any changesets.'
)
// Create an empty changeset for `next` to bump the canary version
// even if there are no changesets for `next`.
await execa('pnpm', [
'changeset',
'status',
'--output',
'./changeset-status.json',
])
let hasNextChangeset = false
if (existsSync('./changeset-status.json')) {
const changesetStatus: ChangesetStatusJson = JSON.parse(
await readFile('./changeset-status.json', 'utf8')
)
console.log('▲ Changeset Status:')
console.log(changesetStatus)
hasNextChangeset =
changesetStatus.releases.find(
(release) => release.name === 'next'
) !== undefined
await unlink('./changeset-status.json')
}
if (!hasNextChangeset) {
console.log(
'▲ No changesets found for `next`, creating an empty changeset.'
)
// TODO: Since this is temporary until we hard-require a changeset, we will
// need to remove this in the future to prevent publishing empty releases.
await writeFile(
join(process.cwd(), '.changeset', `next-canary-${Date.now()}.md`),
`---\n'next': patch\n---`
)
}
break
}
case 'release-candidate': {
// Enter pre mode as "rc" tag.
await execa('pnpm', ['changeset', 'pre', 'enter', 'rc'], {
stdio: 'inherit',
})
break
}
case 'beta': {
// Enter pre mode as "beta" tag.
await execa('pnpm', ['changeset', 'pre', 'enter', 'beta'], {
stdio: 'inherit',
})
break
}
case 'stable': {
// No additional steps needed for 'stable' releases since we've already
// exited any pre-release mode. Only need to run `changeset version` after.
break
}
default: {
throw new Error(`Invalid release type: ${releaseType}`)
}
}
await execa('pnpm', ['changeset', 'version'], {
stdio: 'inherit',
})
// TODO: Update the pnpm-lock.yaml since the packages' depend on
// each other. Remove this once they use `workspace:` protocol.
await execa('pnpm', ['install', '--no-frozen-lockfile'], {
stdio: 'inherit',
})
}
versionPackages()
...@@ -10,7 +10,6 @@ const CHANGE_ITEM_GROUPS = { ...@@ -10,7 +10,6 @@ const CHANGE_ITEM_GROUPS = {
'apps/docs', 'apps/docs',
'errors', 'errors',
'examples', 'examples',
'.changeset',
'UPGRADING.md', 'UPGRADING.md',
'contributing.md', 'contributing.md',
'contributing', 'contributing',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment