Update release script to use prerelease versions#3845
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the release script to replace the "preview" release type with a more flexible prerelease system using a --pre flag. Instead of embedding prerelease identifiers in the version string (e.g., 11.0.0-preview.1), the new approach stores clean semantic versions in package.json (e.g., 11.0.1) and appends -pre to git tags only (e.g., v11.0.1-pre).
Key changes:
- Replaced
previewrelease type with--preflag that works with any release type (major/minor/patch) - Simplified version parsing to only accept X.Y.Z format, removing prerelease version logic
- Manual versions can now be used with any release type, not just previews
| console.error( | ||
| " pnpm release patch --pre - 11.0.0 -> 11.0.1 (tag: v11.0.1-pre)", | ||
| ); | ||
| console.error(" pnpm release minor 12.1.0 - Use specific version"); |
There was a problem hiding this comment.
The example suggests that any release type can be used with a manual version (pnpm release minor 12.1.0), but the validation at line 128-136 doesn't enforce that the manual version is consistent with the release type. For example, pnpm release patch 13.0.0 would be accepted even though 13.0.0 represents a major version bump. Consider adding validation to ensure the manual version is semantically consistent with the specified release type, or clarify in the documentation that the release type is ignored when a manual version is provided.
| * pnpm release major - Bump major version (11.0.0 -> 12.0.0) | ||
| * pnpm release minor - Bump minor version (11.0.0 -> 11.1.0) | ||
| * pnpm release patch - Bump patch version (11.0.0 -> 11.0.1) | ||
| * pnpm release patch --pre - Patch as prerelease (tag: v11.0.1-pre) |
There was a problem hiding this comment.
The documentation states "Patch as prerelease" but the behavior actually bumps the patch version before applying the prerelease tag. If the current version is 11.0.0, running pnpm release patch --pre will result in version 11.0.1 with tag v11.0.1-pre, not 11.0.0-pre. Consider clarifying this as "Bump patch and mark as prerelease" or "Patch bump with prerelease tag" to avoid confusion.
| * pnpm release patch --pre - Patch as prerelease (tag: v11.0.1-pre) | |
| * pnpm release patch --pre - Bump patch and mark as prerelease (tag: v11.0.1-pre) |
| function parseVersion(version) { | ||
| // Handle prerelease versions like "11.1.0-preview.1" | ||
| const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-([a-z]+)\.(\d+))?$/i); | ||
| const match = version.match(/^(\d+)\.(\d+)\.(\d+)$/); | ||
| if (!match) { | ||
| throw new Error(`Invalid version format: ${version}`); | ||
| } | ||
| return { | ||
| major: parseInt(match[1], 10), | ||
| minor: parseInt(match[2], 10), | ||
| patch: parseInt(match[3], 10), | ||
| prerelease: match[4] || null, | ||
| prereleaseNum: match[5] ? parseInt(match[5], 10) : null, | ||
| }; | ||
| } |
There was a problem hiding this comment.
The updated parseVersion function only accepts semver versions in X.Y.Z format and will fail if the current package.json version contains a prerelease identifier from the old system (e.g., 11.0.1-preview.1). This could break the script during the transition period. Consider adding backward compatibility to handle the old prerelease format, or document that package.json must be manually updated to a clean semver version before using this new script version.
| manualVersion || calculateNewVersion(currentVersion, releaseType); | ||
|
|
||
| console.log(`\nRelease: ${releaseType}`); | ||
| const tagName = isPrerelease ? `v${newVersion}-pre` : `v${newVersion}`; |
There was a problem hiding this comment.
The tag suffix -pre is not recognized by the GitHub workflow's prerelease detection logic. The workflow at .github/workflows/main.yaml:90 checks for -preview|-beta|-alpha|-rc patterns but not -pre. This means prereleases created with this script will be published as stable releases. Either update the workflow to include -pre in the regex pattern, or change this script to use -preview instead of -pre to maintain compatibility with the existing workflow.
No description provided.