Skip to content

Commit 27a3681

Browse files
committed
build(ui-scripts): add prerelease option to the bump script for security releases
1 parent eefa5bd commit 27a3681

5 files changed

Lines changed: 20 additions & 8 deletions

File tree

docs/contributor-docs/release.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,17 @@ git checkout -b release
110110

111111
##### 3. Run Pnpm Bump Command
112112

113-
- This will propose new version numbers.
113+
- This will propose new version numbers. It can be forced to generate certain versions: patch, minor, major. Also has a prerelease option that'll produce a security postfixed release for private, security releases.
114114

115115
```bash
116116
---
117117
type: code
118118
---
119119
pnpm run bump
120+
pnpm run bump:patch
121+
pnpm run bump:minor
122+
pnpm run bump:major
123+
pnpm run bump:prerelease
120124
```
121125

122126
- Check if the proposed version numbers are correct. If they are, accept them.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"export:icons": "pnpm --filter @instructure/ui-icons export",
3939
"create-component-version": "ui-scripts create-component-version",
4040
"bump": "ui-scripts bump",
41+
"bump:patch": "ui-scripts bump --releaseType=patch",
42+
"bump:minor": "ui-scripts bump --releaseType=minor",
43+
"bump:major": "ui-scripts bump --releaseType=major",
44+
"bump:private": "ui-scripts bump --releaseType=prerelease",
4145
"release": "ui-scripts publish",
4246
"publish-private": "ui-scripts publish-private",
4347
"husky:pre-commit": "lint-staged && node scripts/checkTSReferences.js",

packages/ui-scripts/lib/commands/bump.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ const calcNextVersionType = () => {
4444

4545
export default {
4646
command: 'bump',
47-
desc: 'bump version in all package.json-s, generate changelogs and commit this change',
47+
desc: "bump version in all package.json-s, generate changelogs and commit this change. Use the releaseType param to explicitely tell lerna what version to bump to. (patch, minor, major, prerelease. Prerelease means that it'll publish a security postfixed version)",
4848
builder: (yargs) => {
4949
yargs.option('releaseType', {
5050
type: 'string',
5151
describe:
52-
'optional release type/version argument: major, minor, patch, [version]'
52+
'optional release type/version argument: major, minor, patch, prerelease, [version]'
5353
})
5454
},
5555
handler: async (argv) => {
5656
const pkgJSON = pkgUtils.getPackageJSON(undefined)
57-
// optional release type/version argument: major, minor, patch, [version]
58-
// e.g. ui-scripts bump major
57+
// optional release type/version argument: major, minor, patch, prerelease [version]
58+
// e.g. ui-scripts bump --releaseType=major
5959
await bump(pkgJSON.name, argv.releaseType)
6060
}
6161
}

packages/ui-scripts/lib/utils/addNewExportsEntiresToPackageJSONs.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ import pkgUtils from './pkg-utils/index.js'
3535
* @param {string} version - Semver string (e.g. "11.9.0")
3636
*/
3737
export const addNewExportsEntiresToPackageJSONs = async (version) => {
38+
if (version.includes('SECURITY')) {
39+
return
40+
}
3841
const formattedVersion = `v${version.split('.').slice(0, 2).join('_')}`
3942
const packages = await pkgUtils.getDetailedPackageList()
4043

4144
const res = packages.map(({ data, path }) => {
4245
//if no exports field, do nothing
43-
if (!data.exports) {
46+
if (!data?.exports) {
4447
return
4548
}
4649
//if the currently releasing version is already exists, do nothing

packages/ui-scripts/lib/utils/npm.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function bumpPackages(packageName, requestedVersion) {
5959
let bumpVersion = requestedVersion
6060

6161
if (bumpVersion) {
62-
if (!['major', 'minor', 'patch'].includes(bumpVersion)) {
62+
if (!['major', 'minor', 'patch', 'prerelease'].includes(bumpVersion)) {
6363
bumpVersion = semver.valid(bumpVersion)
6464

6565
if (!bumpVersion) {
@@ -88,7 +88,8 @@ export async function bumpPackages(packageName, requestedVersion) {
8888
'--no-push', // do not execute `git push`
8989
'--no-git-tag-version', // do not add git tag or commit
9090
'--force-publish=*', // bump all packages even if they have no changes
91-
'--conventional-commits' // determines new version and updates Changelog
91+
'--conventional-commits', // determines new version and updates Changelog
92+
'--preid=SECURITY' // postfixes releases if type is prerelease
9293
])
9394

9495
releaseVersion = await syncRootPackageVersion(true)

0 commit comments

Comments
 (0)