diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 1092fced82811..6823286571a5f 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -454,7 +454,7 @@ step-delete-git-directories: &step-delete-git-directories command: | if [ "`uname`" == "Darwin" ]; then cd src - ( find . -type d -name ".git" -not -path "./third_party/angle/*" -not -path "./third_party/dawn/*" ) | xargs rm -rf + ( find . -type d -name ".git" -not -path "./third_party/angle/*" -not -path "./third_party/dawn/*" -not -path "./electron/*" ) | xargs rm -rf fi # On macOS the yarn install command during gclient sync was run on a linux @@ -813,7 +813,7 @@ step-maybe-zip-symbols: &step-maybe-zip-symbols cd src export BUILD_PATH="$PWD/out/Default" ninja -C out/Default electron:licenses - ninja -C out/Default electron:electron_version + ninja -C out/Default electron:electron_version_file DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b $BUILD_PATH step-maybe-cross-arch-snapshot: &step-maybe-cross-arch-snapshot @@ -873,12 +873,12 @@ step-touch-sync-done: &step-touch-sync-done step-maybe-restore-src-cache: &step-maybe-restore-src-cache restore_cache: keys: - - v14-src-cache-{{ checksum "src/electron/.depshash" }} + - v15-src-cache-{{ checksum "src/electron/.depshash" }} name: Restoring src cache step-maybe-restore-src-cache-marker: &step-maybe-restore-src-cache-marker restore_cache: keys: - - v14-src-cache-marker-{{ checksum "src/electron/.depshash" }} + - v15-src-cache-marker-{{ checksum "src/electron/.depshash" }} name: Restoring src cache marker # Restore exact or closest git cache based on the hash of DEPS and .circle-sync-done @@ -954,13 +954,14 @@ step-minimize-workspace-size-from-checkout: &step-minimize-workspace-size-from-c rm -rf third_party/electron_node/deps/openssl rm -rf third_party/electron_node/deps/v8 rm -rf chrome/test/data/xr/webvr_info + rm -rf src/third_party/angle/third_party/VK-GL-CTS/src # Save the src cache based on the deps hash step-save-src-cache: &step-save-src-cache save_cache: paths: - /var/portal - key: v14-src-cache-{{ checksum "/var/portal/src/electron/.depshash" }} + key: v15-src-cache-{{ checksum "/var/portal/src/electron/.depshash" }} name: Persisting src cache step-make-src-cache-marker: &step-make-src-cache-marker run: @@ -970,7 +971,7 @@ step-save-src-cache-marker: &step-save-src-cache-marker save_cache: paths: - .src-cache-marker - key: v14-src-cache-marker-{{ checksum "/var/portal/src/electron/.depshash" }} + key: v15-src-cache-marker-{{ checksum "/var/portal/src/electron/.depshash" }} step-maybe-early-exit-no-doc-change: &step-maybe-early-exit-no-doc-change run: diff --git a/BUILD.gn b/BUILD.gn index 6966cd3c5c9fd..ce88ef64530d9 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -107,6 +107,14 @@ branding = read_file("shell/app/BRANDING.json", "json") electron_project_name = branding.project_name electron_product_name = branding.product_name electron_mac_bundle_id = branding.mac_bundle_id +electron_version = exec_script("script/print-version.py", + [], + "trim string", + [ + ".git/packed-refs", + ".git/HEAD", + "script/lib/get-version.js", + ]) if (is_mas_build) { assert(is_mac, @@ -302,12 +310,9 @@ npm_action("electron_version_args") { outputs = [ "$target_gen_dir/electron_version.args" ] - args = rebase_path(outputs) + args = rebase_path(outputs) + [ "$electron_version" ] - inputs = [ - "ELECTRON_VERSION", - "script/generate-version-json.js", - ] + inputs = [ "script/generate-version-json.js" ] } templated_file("electron_version_header") { @@ -319,6 +324,39 @@ templated_file("electron_version_header") { args_files = get_target_outputs(":electron_version_args") } +templated_file("electron_win_rc") { + deps = [ ":electron_version_args" ] + + template = "build/templates/electron_rc.tmpl" + output = "$target_gen_dir/win-resources/electron.rc" + + args_files = get_target_outputs(":electron_version_args") +} + +copy("electron_win_resource_files") { + sources = [ + "shell/browser/resources/win/electron.ico", + "shell/browser/resources/win/resource.h", + ] + outputs = [ "$target_gen_dir/win-resources/{{source_file_part}}" ] +} + +templated_file("electron_version_file") { + deps = [ ":electron_version_args" ] + + template = "build/templates/version_string.tmpl" + output = "$root_build_dir/version" + + args_files = get_target_outputs(":electron_version_args") +} + +group("electron_win32_resources") { + public_deps = [ + ":electron_win_rc", + ":electron_win_resource_files", + ] +} + action("electron_fuses") { script = "build/fuses/build.py" @@ -755,7 +793,6 @@ if (is_mac) { electron_helper_name = "$electron_product_name Helper" electron_login_helper_name = "$electron_product_name Login Helper" electron_framework_version = "A" - electron_version = read_file("ELECTRON_VERSION", "trim string") mac_xib_bundle_data("electron_xibs") { sources = [ "shell/common/resources/mac/MainMenu.xib" ] @@ -1196,6 +1233,7 @@ if (is_mac) { ":default_app_asar", ":electron_app_manifest", ":electron_lib", + ":electron_win32_resources", ":packed_resources", "//components/crash/core/app", "//content:sandbox_helper_win", @@ -1229,8 +1267,7 @@ if (is_mac) { if (is_win) { sources += [ - # TODO: we should be generating our .rc files more like how chrome does - "shell/browser/resources/win/electron.rc", + "$target_gen_dir/win-resources/electron.rc", "shell/browser/resources/win/resource.h", ] @@ -1412,15 +1449,10 @@ group("licenses") { ] } -copy("electron_version") { - sources = [ "ELECTRON_VERSION" ] - outputs = [ "$root_build_dir/version" ] -} - dist_zip("electron_dist_zip") { data_deps = [ ":electron_app", - ":electron_version", + ":electron_version_file", ":licenses", ] if (is_linux) { diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION deleted file mode 100644 index ab3add4d87bc7..0000000000000 --- a/ELECTRON_VERSION +++ /dev/null @@ -1 +0,0 @@ -21.2.0 \ No newline at end of file diff --git a/shell/browser/resources/win/electron.rc b/build/templates/electron_rc.tmpl similarity index 87% rename from shell/browser/resources/win/electron.rc rename to build/templates/electron_rc.tmpl index 55164305f4d69..2f75d9003b84b 100644 --- a/shell/browser/resources/win/electron.rc +++ b/build/templates/electron_rc.tmpl @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 21,2,0,0 - PRODUCTVERSION 21,2,0,0 + FILEVERSION $major,$minor,$patch,$prerelease_number + PRODUCTVERSION $major,$minor,$patch,$prerelease_number FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -68,12 +68,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "21.2.0" + VALUE "FileVersion", "$major.$minor.$patch" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "21.2.0" + VALUE "ProductVersion", "$major.$minor.$patch" VALUE "SquirrelAwareVersion", "1" END END diff --git a/build/templates/version_string.tmpl b/build/templates/version_string.tmpl new file mode 100644 index 0000000000000..02e5f9c0d4f9f --- /dev/null +++ b/build/templates/version_string.tmpl @@ -0,0 +1 @@ +$full_version \ No newline at end of file diff --git a/package.json b/package.json index d2c128b107202..61a3b21a85797 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "21.2.0", + "version": "0.0.0-development", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 5d4cdbaa54944..46a6911044f47 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -125,3 +125,4 @@ fix_crash_loading_non-standard_schemes_in_iframes.patch create_browser_v8_snapshot_file_name_fuse.patch cherry-pick-c83640db21b5.patch fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch +build_allow_electron_to_use_exec_script.patch diff --git a/patches/chromium/build_allow_electron_to_use_exec_script.patch b/patches/chromium/build_allow_electron_to_use_exec_script.patch new file mode 100644 index 0000000000000..5a3e943452136 --- /dev/null +++ b/patches/chromium/build_allow_electron_to_use_exec_script.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard +Date: Fri, 21 Oct 2022 16:29:06 -0700 +Subject: build: allow electron to use exec_script + +This is similar to the //build usecase so we're OK adding ourselves here + +diff --git a/.gn b/.gn +index 7b9768eb315ef8a4d8d61bcf07d43c70f3ea9582..0857ee17a35dabc19c2a04f6a5dd7d631e4b7ee8 100644 +--- a/.gn ++++ b/.gn +@@ -169,4 +169,6 @@ exec_script_whitelist = + + "//tools/grit/grit_rule.gni", + "//tools/gritsettings/BUILD.gn", ++ ++ "//electron/BUILD.gn" + ] diff --git a/script/generate-version-json.js b/script/generate-version-json.js index 5c41d0543394d..8a981f81738fb 100644 --- a/script/generate-version-json.js +++ b/script/generate-version-json.js @@ -3,8 +3,7 @@ const path = require('path'); const semver = require('semver'); const outputPath = process.argv[2]; - -const currentVersion = fs.readFileSync(path.resolve(__dirname, '../ELECTRON_VERSION'), 'utf8').trim(); +const currentVersion = process.argv[3]; const parsed = semver.parse(currentVersion); @@ -20,9 +19,11 @@ const { } = parsed; fs.writeFileSync(outputPath, JSON.stringify({ + full_version: currentVersion, major, minor, patch, prerelease, + prerelease_number: prerelease ? parsed.prerelease[parsed.prerelease.length - 1] : '0', has_prerelease: prerelease === '' ? 0 : 1 }, null, 2)); diff --git a/script/lib/get-version.js b/script/lib/get-version.js new file mode 100644 index 0000000000000..45a120482b05d --- /dev/null +++ b/script/lib/get-version.js @@ -0,0 +1,22 @@ +const { spawnSync } = require('child_process'); +const path = require('path'); + +module.exports.getElectronVersion = () => { + // Find the nearest tag to the current HEAD + // This is equivilant to our old logic of "use a value in package.json" for the following reasons + // + // 1. Whenever we updated the package.json we ALSO pushed a tag with the same version + // 2. Whenever we _reverted_ a bump all we actually did was push a commit that deleted the tag and changed the version number back + // + // The only difference in the "git describe" technique is that technically a commit can "change" it's version + // number if a tag is created / removed retroactively. i.e. the first time a commit is pushed it will be 1.2.3 + // and after the tag is made rebuilding the same commit will result in it being 1.2.4 + const output = spawnSync('git', ['describe', '--tags', '--abbrev=0'], { + cwd: path.resolve(__dirname, '..', '..') + }); + if (output.status !== 0) { + console.error(output.stderr); + throw new Error('Failed to get current electron version'); + } + return output.stdout.toString().trim().replace(/^v/g, ''); +}; diff --git a/script/lib/util.py b/script/lib/util.py index 05d476e93ab26..7911d2da79fcf 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -15,7 +15,9 @@ from urllib2 import urlopen import zipfile -from lib.config import is_verbose_mode +# from lib.config import is_verbose_mode +def is_verbose_mode(): + return False ELECTRON_DIR = os.path.abspath( os.path.dirname(os.path.dirname(os.path.dirname(__file__))) @@ -149,11 +151,17 @@ def get_electron_branding(): with open(branding_file_path) as f: return json.load(f) + +cached_electron_version = None def get_electron_version(): - SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..')) - version_file = os.path.join(SOURCE_ROOT, 'ELECTRON_VERSION') - with open(version_file) as f: - return 'v' + f.read().strip() + global cached_electron_version + if cached_electron_version is None: + cached_electron_version = str.strip(execute([ + 'node', + '-p', + 'require("./script/lib/get-version").getElectronVersion()' + ], cwd=ELECTRON_DIR).decode()) + return cached_electron_version def store_artifact(prefix, key_prefix, files): # Azure Storage diff --git a/script/print-version.py b/script/print-version.py new file mode 100644 index 0000000000000..20ec2231a2635 --- /dev/null +++ b/script/print-version.py @@ -0,0 +1,3 @@ +from lib.util import get_electron_version + +print(get_electron_version()) diff --git a/script/release/publish-to-npm.js b/script/release/publish-to-npm.js index 081274d83edac..cef87cb30c169 100644 --- a/script/release/publish-to-npm.js +++ b/script/release/publish-to-npm.js @@ -6,6 +6,7 @@ const got = require('got'); const semver = require('semver'); const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils'); +const { getElectronVersion } = require('../lib/get-version'); const rootPackageJson = require('../../package.json'); const { Octokit } = require('@octokit/rest'); @@ -34,7 +35,6 @@ const files = [ const jsonFields = [ 'name', - 'version', 'repository', 'description', 'license', @@ -44,6 +44,9 @@ const jsonFields = [ let npmTag = ''; +const currentElectronVersion = getElectronVersion(); +const isNightlyElectronVersion = currentElectronVersion.includes('nightly'); + new Promise((resolve, reject) => { temp.mkdir('electron-npm', (err, dirPath) => { if (err) { @@ -68,6 +71,7 @@ new Promise((resolve, reject) => { jsonFields.forEach((fieldName) => { packageJson[fieldName] = rootPackageJson[fieldName]; }); + packageJson.version = currentElectronVersion; fs.writeFileSync( path.join(tempDir, 'package.json'), JSON.stringify(packageJson, null, 2) @@ -75,27 +79,27 @@ new Promise((resolve, reject) => { return octokit.repos.listReleases({ owner: 'electron', - repo: rootPackageJson.version.indexOf('nightly') > 0 ? 'nightlies' : 'electron' + repo: isNightlyElectronVersion ? 'nightlies' : 'electron' }); }) .then((releases) => { // download electron.d.ts from release const release = releases.data.find( - (release) => release.tag_name === `v${rootPackageJson.version}` + (release) => release.tag_name === `v${currentElectronVersion}` ); if (!release) { - throw new Error(`cannot find release with tag v${rootPackageJson.version}`); + throw new Error(`cannot find release with tag v${currentElectronVersion}`); } return release; }) .then(async (release) => { const tsdAsset = release.assets.find((asset) => asset.name === 'electron.d.ts'); if (!tsdAsset) { - throw new Error(`cannot find electron.d.ts from v${rootPackageJson.version} release assets`); + throw new Error(`cannot find electron.d.ts from v${currentElectronVersion} release assets`); } const typingsContent = await getAssetContents( - rootPackageJson.version.indexOf('nightly') > 0 ? 'nightlies' : 'electron', + isNightlyElectronVersion ? 'nightlies' : 'electron', tsdAsset.id ); @@ -106,11 +110,11 @@ new Promise((resolve, reject) => { .then(async (release) => { const checksumsAsset = release.assets.find((asset) => asset.name === 'SHASUMS256.txt'); if (!checksumsAsset) { - throw new Error(`cannot find SHASUMS256.txt from v${rootPackageJson.version} release assets`); + throw new Error(`cannot find SHASUMS256.txt from v${currentElectronVersion} release assets`); } const checksumsContent = await getAssetContents( - rootPackageJson.version.indexOf('nightly') > 0 ? 'nightlies' : 'electron', + isNightlyElectronVersion ? 'nightlies' : 'electron', checksumsAsset.id ); @@ -127,7 +131,7 @@ new Promise((resolve, reject) => { .then(async (release) => { const currentBranch = await getCurrentBranch(); - if (release.tag_name.indexOf('nightly') > 0) { + if (isNightlyElectronVersion) { // TODO(main-migration): Simplify once main branch is renamed. if (currentBranch === 'master' || currentBranch === 'main') { // Nightlies get published to their own module, so they should be tagged as latest @@ -164,7 +168,7 @@ new Promise((resolve, reject) => { .then(() => childProcess.execSync('npm pack', { cwd: tempDir })) .then(() => { // test that the package can install electron prebuilt from github release - const tarballPath = path.join(tempDir, `${rootPackageJson.name}-${rootPackageJson.version}.tgz`); + const tarballPath = path.join(tempDir, `${rootPackageJson.name}-${currentElectronVersion}.tgz`); return new Promise((resolve, reject) => { const result = childProcess.spawnSync('npm', ['install', tarballPath, '--force', '--silent'], { env: { ...process.env, electron_config_cache: tempDir }, @@ -190,7 +194,7 @@ new Promise((resolve, reject) => { }); }) .then((tarballPath) => { - const existingVersionJSON = childProcess.execSync(`npm view electron@${rootPackageJson.version} --json`).toString('utf-8'); + const existingVersionJSON = childProcess.execSync(`npx npm@7 view ${rootPackageJson.name}@${currentElectronVersion} --json`).toString('utf-8'); // It's possible this is a re-run and we already have published the package, if not we just publish like normal if (!existingVersionJSON) { childProcess.execSync(`npm publish ${tarballPath} --tag ${npmTag} --otp=${process.env.ELECTRON_NPM_OTP}`); @@ -198,22 +202,21 @@ new Promise((resolve, reject) => { }) .then(() => { const currentTags = JSON.parse(childProcess.execSync('npm show electron dist-tags --json').toString()); - const localVersion = rootPackageJson.version; - const parsedLocalVersion = semver.parse(localVersion); + const parsedLocalVersion = semver.parse(currentElectronVersion); if (rootPackageJson.name === 'electron') { // We should only customly add dist tags for non-nightly releases where the package name is still // "electron" if (parsedLocalVersion.prerelease.length === 0 && - semver.gt(localVersion, currentTags.latest)) { - childProcess.execSync(`npm dist-tag add electron@${localVersion} latest --otp=${process.env.ELECTRON_NPM_OTP}`); + semver.gt(currentElectronVersion, currentTags.latest)) { + childProcess.execSync(`npm dist-tag add electron@${currentElectronVersion} latest --otp=${process.env.ELECTRON_NPM_OTP}`); } if (parsedLocalVersion.prerelease[0] === 'beta' && - semver.gt(localVersion, currentTags.beta)) { - childProcess.execSync(`npm dist-tag add electron@${localVersion} beta --otp=${process.env.ELECTRON_NPM_OTP}`); + semver.gt(currentElectronVersion, currentTags.beta)) { + childProcess.execSync(`npm dist-tag add electron@${currentElectronVersion} beta --otp=${process.env.ELECTRON_NPM_OTP}`); } if (parsedLocalVersion.prerelease[0] === 'alpha' && - semver.gt(localVersion, currentTags.alpha)) { - childProcess.execSync(`npm dist-tag add electron@${localVersion} alpha --otp=${process.env.ELECTRON_NPM_OTP}`); + semver.gt(currentElectronVersion, currentTags.alpha)) { + childProcess.execSync(`npm dist-tag add electron@${currentElectronVersion} alpha --otp=${process.env.ELECTRON_NPM_OTP}`); } } }) diff --git a/script/release/release-artifact-cleanup.js b/script/release/release-artifact-cleanup.js index 080b078f49284..0079696c3afd8 100755 --- a/script/release/release-artifact-cleanup.js +++ b/script/release/release-artifact-cleanup.js @@ -18,26 +18,6 @@ require('colors'); const pass = '✓'.green; const fail = '✗'.red; -function getLastBumpCommit (tag) { - const data = execSync(`git log -n1 --grep "Bump ${tag}" --format='format:{"hash": "%H", "message": "%s"}'`).toString(); - return JSON.parse(data); -} - -async function revertBumpCommit (tag) { - const branch = await getCurrentBranch(); - const commitToRevert = getLastBumpCommit(tag).hash; - await GitProcess.exec(['pull', '--rebase']); - await GitProcess.exec(['revert', commitToRevert], ELECTRON_DIR); - const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], ELECTRON_DIR); - if (pushDetails.exitCode === 0) { - console.log(`${pass} successfully reverted release commit.`); - } else { - const error = GitProcess.parseError(pushDetails.stderr); - console.error(`${fail} could not push release commit: `, error); - process.exit(1); - } -} - async function deleteDraft (releaseId, targetRepo) { try { const result = await octokit.repos.getRelease({ @@ -80,9 +60,6 @@ async function cleanReleaseArtifacts () { const releaseId = args.releaseID.length > 0 ? args.releaseID : null; const isNightly = args.tag.includes('nightly'); - // try to revert commit regardless of tag and draft deletion status - await revertBumpCommit(args.tag); - if (releaseId) { if (isNightly) { await deleteDraft(releaseId, 'nightlies'); diff --git a/script/release/release.js b/script/release/release.js index c3c8d6363b120..f600d7a27c42c 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -12,8 +12,6 @@ const args = require('minimist')(process.argv.slice(2), { const fs = require('fs'); const { execSync } = require('child_process'); const got = require('got'); -const pkg = require('../../package.json'); -const pkgVersion = `v${pkg.version}`; const path = require('path'); const temp = require('temp').track(); const { URL } = require('url'); @@ -25,8 +23,11 @@ const pass = '✓'.green; const fail = '✗'.red; const { ELECTRON_DIR } = require('../lib/utils'); +const { getElectronVersion } = require('../lib/get-version'); const getUrlHash = require('./get-url-hash'); +const pkgVersion = `v${getElectronVersion()}`; + const octokit = new Octokit({ auth: process.env.ELECTRON_GITHUB_TOKEN }); diff --git a/script/release/version-bumper.js b/script/release/version-bumper.js index 279f1f3e46096..51865bc46439c 100644 --- a/script/release/version-bumper.js +++ b/script/release/version-bumper.js @@ -1,17 +1,10 @@ #!/usr/bin/env node -const { GitProcess } = require('dugite'); -const { promises: fs } = require('fs'); const semver = require('semver'); -const path = require('path'); const minimist = require('minimist'); -const { ELECTRON_DIR } = require('../lib/utils'); +const { getElectronVersion } = require('../lib/get-version'); const versionUtils = require('./version-utils'); -const supported = path.resolve(ELECTRON_DIR, 'docs', 'tutorial', 'support.md'); - -const writeFile = fs.writeFile; -const readFile = fs.readFile; function parseCommandLine () { let help; @@ -37,7 +30,7 @@ function parseCommandLine () { // run the script async function main () { const opts = parseCommandLine(); - const currentVersion = await versionUtils.getElectronVersion(); + const currentVersion = getElectronVersion(); const version = await nextVersion(opts.bump, currentVersion); const parsed = semver.parse(version); @@ -54,20 +47,6 @@ async function main () { return 0; } - if (shouldUpdateSupported(opts.bump, currentVersion, version)) { - await updateSupported(version, supported); - } - - // update all version-related files - await Promise.all([ - updateVersion(version), - updatePackageJSON(version), - updateWinRC(components) - ]); - - // commit all updated version-related files - await commitVersionBump(version); - console.log(`Bumped to version: ${version}`); } @@ -118,10 +97,6 @@ async function nextVersion (bumpType, version) { return version; } -function shouldUpdateSupported (bump, current, version) { - return isMajorStable(bump, current) || isMajorNightly(version, current); -} - function isMajorStable (bump, currentVersion) { if (versionUtils.isBeta(currentVersion) && (bump === 'stable')) return true; return false; @@ -134,59 +109,6 @@ function isMajorNightly (version, currentVersion) { return false; } -// update VERSION file with latest release info -async function updateVersion (version) { - const versionPath = path.resolve(ELECTRON_DIR, 'ELECTRON_VERSION'); - await writeFile(versionPath, version, 'utf8'); -} - -// update package metadata files with new version -async function updatePackageJSON (version) { - const filePath = path.resolve(ELECTRON_DIR, 'package.json'); - const file = require(filePath); - file.version = version; - await writeFile(filePath, JSON.stringify(file, null, 2)); -} - -// push bump commit to release branch -async function commitVersionBump (version) { - const gitArgs = ['commit', '-a', '-m', `Bump v${version}`, '-n']; - await GitProcess.exec(gitArgs, ELECTRON_DIR); -} - -// updates electron.rc file with new semver values -async function updateWinRC (components) { - const filePath = path.resolve(ELECTRON_DIR, 'shell', 'browser', 'resources', 'win', 'electron.rc'); - const data = await readFile(filePath, 'utf8'); - const arr = data.split('\n'); - arr.forEach((line, idx) => { - if (line.includes('FILEVERSION')) { - arr[idx] = ` FILEVERSION ${versionUtils.makeVersion(components, ',', versionUtils.preType.PARTIAL)}`; - arr[idx + 1] = ` PRODUCTVERSION ${versionUtils.makeVersion(components, ',', versionUtils.preType.PARTIAL)}`; - } else if (line.includes('FileVersion')) { - arr[idx] = ` VALUE "FileVersion", "${versionUtils.makeVersion(components, '.')}"`; - arr[idx + 5] = ` VALUE "ProductVersion", "${versionUtils.makeVersion(components, '.')}"`; - } - }); - await writeFile(filePath, arr.join('\n')); -} - -// updates support.md file with new semver values (stable only) -async function updateSupported (version, filePath) { - const v = parseInt(version); - const newVersions = [`* ${v}.x.y`, `* ${v - 1}.x.y`, `* ${v - 2}.x.y`, `* ${v - 3}.x.y`]; - const contents = await readFile(filePath, 'utf8'); - const previousVersions = contents.split('\n').filter((elem) => { - return (/[^\n]*\.x\.y[^\n]*/).test(elem); - }, []); - - const newContents = previousVersions.reduce((contents, current, i) => { - return contents.replace(current, newVersions[i]); - }, contents); - - await writeFile(filePath, newContents, 'utf8'); -} - if (process.mainModule === module) { main().catch((error) => { console.error(error); @@ -194,4 +116,4 @@ if (process.mainModule === module) { }); } -module.exports = { nextVersion, shouldUpdateSupported, updateSupported }; +module.exports = { nextVersion }; diff --git a/script/release/version-utils.js b/script/release/version-utils.js index 2e9c9a88ddf2b..1bd6668339cfd 100644 --- a/script/release/version-utils.js +++ b/script/release/version-utils.js @@ -68,12 +68,6 @@ async function nextBeta (v) { return tags.length === 0 ? `${next}-beta.1` : semver.inc(tags.pop(), 'prerelease'); } -async function getElectronVersion () { - const versionPath = path.resolve(ELECTRON_DIR, 'ELECTRON_VERSION'); - const version = await readFile(versionPath, 'utf8'); - return version.trim(); -} - async function nextNightly (v) { let next = semver.valid(semver.coerce(v)); const pre = `nightly.${getCurrentDate()}`; @@ -114,7 +108,6 @@ module.exports = { nextAlpha, nextBeta, makeVersion, - getElectronVersion, nextNightly, preType }; diff --git a/spec-main/version-bump-spec.ts b/spec-main/version-bump-spec.ts index 7a8ef9113ce01..8c561deaa28e4 100644 --- a/spec-main/version-bump-spec.ts +++ b/spec-main/version-bump-spec.ts @@ -1,15 +1,9 @@ import { expect } from 'chai'; import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite'; -import { nextVersion, shouldUpdateSupported, updateSupported } from '../script/release/version-bumper'; +import { nextVersion } from '../script/release/version-bumper'; import * as utils from '../script/release/version-utils'; import * as sinon from 'sinon'; import { ifdescribe } from './spec-helpers'; -const { promises: fs } = require('fs'); -const path = require('path'); - -const fixtureDir = path.resolve(__dirname, 'fixtures', 'version-bumper', 'fixture_support.md'); -const readFile = fs.readFile; -const writeFile = fs.writeFile; class GitFake { branches: { @@ -96,94 +90,6 @@ describe('version-bumper', () => { }); }); - describe('updateSupported', () => { - let restore: any; - before(async () => { - restore = await readFile(fixtureDir, 'utf8'); - }); - - afterEach(async () => { - await writeFile(fixtureDir, restore, 'utf8'); - }); - - it('updates correctly when a new stable version is promoted from beta', async () => { - const version = '4.0.0'; - const currentVersion = '4.0.0-beta.29'; - if (shouldUpdateSupported('stable', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('4.x.y\n* 3.x.y\n* 2.x.y'); - }); - - it('should not update when a new stable patch version is promoted', async () => { - const version = '3.0.1'; - const currentVersion = '3.0.0'; - if (shouldUpdateSupported('stable', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('3.x.y\n* 2.x.y\n* 1.x.y'); - }); - - it('should not update when a new stable minor version is promoted', async () => { - const version = '3.1.0'; - const currentVersion = '3.0.0'; - if (shouldUpdateSupported('minor', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('3.x.y\n* 2.x.y\n* 1.x.y'); - }); - - it('should not update when a new beta.1 version is promoted', async () => { - const version = '5.0.0-beta.1'; - const currentVersion = '4.0.0-beta.29'; - if (shouldUpdateSupported('beta', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('3.x.y\n* 2.x.y\n* 1.x.y'); - }); - - it('should not update when a new beta.12 version is promoted', async () => { - const version = '4.0.0-beta.12'; - const currentVersion = '4.0.0-beta.11'; - if (shouldUpdateSupported('beta', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('3.x.y\n* 2.x.y\n* 1.x.y'); - }); - - it('should update when a new major nightly version is promoted', async () => { - const version = '4.0.0-nightly.19950901'; - const currentVersion = '3.0.0-nightly.19950828'; - if (shouldUpdateSupported('nightly', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('4.x.y\n* 3.x.y\n* 2.x.y'); - }); - - it('should not update when a new nightly version is promoted', async () => { - const version = '3.0.0-nightly.19950901'; - const currentVersion = '3.0.0-nightly.19950828'; - if (shouldUpdateSupported('nightly', currentVersion, version)) { - await updateSupported(version, fixtureDir); - } - const contents = await readFile(fixtureDir, 'utf8'); - - expect(contents).to.contain('3.x.y\n* 2.x.y\n* 1.x.y'); - }); - }); - // On macOS Circle CI we don't have a real git environment due to running // gclient sync on a linux machine. These tests therefore don't run as expected. ifdescribe(!(process.platform === 'linux' && process.arch.indexOf('arm') === 0) && process.platform !== 'darwin')('nextVersion', () => {