Skip to content

[release] use changesets/action for release-candidate #79039

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

Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
# See https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#os-version for more details
MACOSX_DEPLOYMENT_TARGET: 11.0
# This will become "true" if the latest commit is
# "Version Packages" or "Version Pacakges (canary)"
# "Version Packages" or "Version Pacakges \((canary|rc)\)"
# set from scripts/check-is-release.js
__NEW_RELEASE: 'false'

Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
run: |
# TODO: Remove the new release check once the new release workflow is fully replaced.
RELEASE_CHECK=$(node ./scripts/check-is-release.js 2> /dev/null || :)
if [[ $RELEASE_CHECK =~ ^Version\ Packages(\ \(canary\))?$ ]];
if [[ $RELEASE_CHECK =~ ^Version\ Packages(\ \((canary|rc)\))?$ ]];
then
echo "__NEW_RELEASE=true" >> $GITHUB_ENV
elif [[ $RELEASE_CHECK = v* ]];
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/trigger_release_new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ on:
options:
- canary
- stable
# TODO: Follow up enable the case.
# - release-candidate
- release-candidate

force:
description: Forced Release
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-is-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const checkIsRelease = async () => {

const versionString = commitMsg.split(' ').pop().trim()
const publishMsgRegex = /^v\d{1,}\.\d{1,}\.\d{1,}(-\w{1,}\.\d{1,})?$/
const newPublishMsgRegex = /^Version Packages( \(canary\))?$/
const newPublishMsgRegex = /^Version Packages( \((canary|rc)\))?$/

if (publishMsgRegex.test(versionString)) {
console.log(versionString)
Expand Down
96 changes: 58 additions & 38 deletions scripts/release/version-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,73 @@ async function versionPackages() {
}
}

// 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',
})

if (releaseType === '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.'
)

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',
])

// 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')
)

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)

console.log('▲ Changeset Status:')
console.log(changesetStatus)
hasNextChangeset =
changesetStatus.releases.find(
(release) => release.name === 'next'
) !== undefined

hasNextChangeset =
changesetStatus.releases.find((release) => release.name === 'next') !==
undefined
await unlink('./changeset-status.json')
}

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
}

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---`
)
case 'release-candidate': {
// Enter pre mode as "rc" tag.
await execa('pnpm', ['changeset', 'pre', 'enter', 'rc'], {
stdio: 'inherit',
})
break
}
case 'stable': {
Copy link
Member

Choose a reason for hiding this comment

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

how come stable has no command? worth a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Added!

// 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}`)
}
}

Expand Down
Loading