Skip to content

Commit deb75ce

Browse files
build: update version-bumper to support alpha (electron#30165)
* build: update version-bumper to support alpha * build: seperate alpha bump version tests For easier deletion. If we want to continue supporting an alpha channel, they can be reintegrated with main tests. * chore: fix regex Co-authored-by: Samuel Attard <sam@electronjs.org> Co-authored-by: Samuel Attard <sam@electronjs.org>
1 parent d35fb2a commit deb75ce

File tree

6 files changed

+229
-82
lines changed

6 files changed

+229
-82
lines changed

script/release/notes/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ const runGit = async (args) => {
2525
};
2626

2727
const tagIsSupported = tag => tag && !tag.includes('nightly') && !tag.includes('unsupported');
28+
const tagIsAlpha = tag => tag && tag.includes('alpha');
2829
const tagIsBeta = tag => tag && tag.includes('beta');
29-
const tagIsStable = tag => tagIsSupported(tag) && !tagIsBeta(tag);
30+
const tagIsStable = tag => tagIsSupported(tag) && !tagIsBeta(tag) && !tagIsAlpha(tag);
3031

3132
const getTagsOf = async (point) => {
3233
try {

script/release/prepare-release.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const pass = '✓'.green;
2525
const fail = '✗'.red;
2626

2727
if (!bumpType && !args.notesOnly) {
28-
console.log('Usage: prepare-release [stable | minor | beta | nightly]' +
28+
console.log('Usage: prepare-release [stable | minor | beta | alpha | nightly]' +
2929
' (--stable) (--notesOnly) (--automaticRelease) (--branch)');
3030
process.exit(1);
3131
}
@@ -93,6 +93,11 @@ async function createRelease (branchToTarget, isBeta) {
9393
'for any bugs you find in it.\n \n This release is published to npm ' +
9494
'under the electron-nightly package and can be installed via `npm install electron-nightly`, ' +
9595
`or \`npm install electron-nightly@${newVersion.substr(1)}\`.\n \n ${releaseNotes.text}`;
96+
} else if (newVersion.indexOf('alpha') > 0) {
97+
releaseBody = 'Note: This is an alpha release. Please file new issues ' +
98+
'for any bugs you find in it.\n \n This release is published to npm ' +
99+
'under the alpha tag and can be installed via `npm install electron@alpha`, ' +
100+
`or \`npm install electron@${newVersion.substr(1)}\`.\n \n ${releaseNotes.text}`;
96101
} else {
97102
releaseBody = 'Note: This is a beta release. Please file new issues ' +
98103
'for any bugs you find in it.\n \n This release is published to npm ' +
@@ -182,7 +187,8 @@ async function promptForVersion (version) {
182187

183188
// function to determine if there have been commits to main since the last release
184189
async function changesToRelease () {
185-
const lastCommitWasRelease = new RegExp('^Bump v[0-9.]*(-beta[0-9.]*)?(-nightly[0-9.]*)?$', 'g');
190+
// eslint-disable-next-line no-useless-escape
191+
const lastCommitWasRelease = new RegExp('^Bump v[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?(-alpha\.[0-9]+)?(-nightly\.[0-9]+)?$', 'g');
186192
const lastCommit = await GitProcess.exec(['log', '-n', '1', '--pretty=format:\'%s\''], ELECTRON_DIR);
187193
return !lastCommitWasRelease.test(lastCommit.stdout);
188194
}

script/release/publish-to-npm.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ new Promise((resolve, reject) => {
135135
} else if (!release.prerelease) {
136136
// Tag the release with a `2-0-x` style tag
137137
npmTag = currentBranch;
138+
} else if (release.tag_name.indexOf('alpha') > 0) {
139+
// Tag the release with an `alpha-3-0-x` style tag
140+
npmTag = `alpha-${currentBranch}`;
138141
} else {
139142
// Tag the release with a `beta-3-0-x` style tag
140143
npmTag = `beta-${currentBranch}`;
@@ -175,6 +178,10 @@ new Promise((resolve, reject) => {
175178
semver.gt(localVersion, currentTags.beta)) {
176179
childProcess.execSync(`npm dist-tag add electron@${localVersion} beta --otp=${process.env.ELECTRON_NPM_OTP}`);
177180
}
181+
if (parsedLocalVersion.prerelease[0] === 'alpha' &&
182+
semver.gt(localVersion, currentTags.alpha)) {
183+
childProcess.execSync(`npm dist-tag add electron@${localVersion} alpha --otp=${process.env.ELECTRON_NPM_OTP}`);
184+
}
178185
}
179186
})
180187
.catch((err) => {

script/release/version-bumper.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,20 @@ async function main () {
7171
console.log(`Bumped to version: ${version}`);
7272
}
7373

74-
// get next version for release based on [nightly, beta, stable]
74+
// get next version for release based on [nightly, alpha, beta, stable]
7575
async function nextVersion (bumpType, version) {
76-
if (versionUtils.isNightly(version) || versionUtils.isBeta(version)) {
76+
if (
77+
versionUtils.isNightly(version) ||
78+
versionUtils.isAlpha(version) ||
79+
versionUtils.isBeta(version)
80+
) {
7781
switch (bumpType) {
7882
case 'nightly':
7983
version = await versionUtils.nextNightly(version);
8084
break;
85+
case 'alpha':
86+
version = await versionUtils.nextAlpha(version);
87+
break;
8188
case 'beta':
8289
version = await versionUtils.nextBeta(version);
8390
break;
@@ -92,6 +99,8 @@ async function nextVersion (bumpType, version) {
9299
case 'nightly':
93100
version = versionUtils.nextNightly(version);
94101
break;
102+
case 'alpha':
103+
throw new Error('Cannot bump to alpha from stable.');
95104
case 'beta':
96105
throw new Error('Cannot bump to beta from stable.');
97106
case 'minor':

script/release/version-utils.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const getCurrentDate = () => {
2323
};
2424

2525
const isNightly = v => v.includes('nightly');
26+
const isAlpha = v => v.includes('alpha');
2627
const isBeta = v => v.includes('beta');
2728
const isStable = v => {
2829
const parsed = semver.parse(v);
@@ -39,9 +40,22 @@ const makeVersion = (components, delim, pre = preType.NONE) => {
3940
return version;
4041
};
4142

42-
async function nextBeta (v) {
43+
async function nextAlpha (v) {
4344
const next = semver.coerce(semver.clean(v));
45+
const tagBlob = await GitProcess.exec(['tag', '--list', '-l', `v${next}-alpha.*`], ELECTRON_DIR);
46+
const tags = tagBlob.stdout.split('\n').filter(e => e !== '');
47+
tags.sort((t1, t2) => {
48+
const a = parseInt(t1.split('.').pop(), 10);
49+
const b = parseInt(t2.split('.').pop(), 10);
50+
return a - b;
51+
});
52+
53+
// increment the latest existing alpha tag or start at alpha.1 if it's a new alpha line
54+
return tags.length === 0 ? `${next}-alpha.1` : semver.inc(tags.pop(), 'prerelease');
55+
}
4456

57+
async function nextBeta (v) {
58+
const next = semver.coerce(semver.clean(v));
4559
const tagBlob = await GitProcess.exec(['tag', '--list', '-l', `v${next}-beta.*`], ELECTRON_DIR);
4660
const tags = tagBlob.stdout.split('\n').filter(e => e !== '');
4761
tags.sort((t1, t2) => {
@@ -94,8 +108,10 @@ function getNextReleaseBranch (branches) {
94108

95109
module.exports = {
96110
isStable,
111+
isAlpha,
97112
isBeta,
98113
isNightly,
114+
nextAlpha,
99115
nextBeta,
100116
makeVersion,
101117
getElectronVersion,

0 commit comments

Comments
 (0)