Electron 版本管理

详细查看我们的版本控制策略和实现。

As of version 2.0.0, Electron follows the SemVer spec. 以下命令将安装最新稳定版的 Electron:

  • npm
  • Yarn
  1. npm install --save-dev electron
  1. yarn add --dev electron

现有项目更新到最新的稳定版本:

  • npm
  • Yarn
  1. npm install --save-dev electron@latest
  1. yarn add --dev electron@latest

Versioning scheme

There are several major changes from our 1.x strategy outlined below. Each change is intended to satisfy the needs and priorities of developers/maintainers and app developers.

  1. Strict use of the SemVer spec
  2. 引入符合 semver 的 -beta 标签
  3. 引入常规提交消息
  4. 明确定义的稳定分支
  5. main分支没有版本信息,只有稳定分支会包含版本信息。

我们将详细介绍 git 分支是如何工作的,npm 标记是如何工作的,开发人员应该看到什么,以及如何能够支持更改。

SemVer

下面是一个表格,明确地将变化的类型映射到它们对应的 SemVer 类别 (例如Major,Minor,Patch)。

Major 版本增量Minor 版本增量Patch 版本增量
Electron 突破性 API 变更Electron 无突破性 API 变更Electron bug fixes
Node.js 重大版本更新Node.js 次要版本更新Node.js patch 版本更新
Chromium 版本更新修复相关的 chromium 补丁

For more information, see the Semantic Versioning 2.0.0 spec.

请注意,大多数 Chromium 更新都将被认为是破坏性的。 Fixes that can be backported will likely be cherry-picked as patches.

Stabilization branches

Stabilization branches are branches that run parallel to main, taking in only cherry-picked commits that are related to security or stability. These branches are never merged back to main.

稳定分支

自 Electron 8 以来,稳定分支始终为 marjar 版本,并且根据以下模板 $MAJOR-x-y 例如: 8-x-y。 在此之前,我们使用 minor 版本行,并将它们命名为 $MAJOR-$MINOR-x 例如: 2-0-x.

We allow for multiple stabilization branches to exist simultaneously, one for each supported version. For more details on which versions are supported, see our Electron Release Timelines doc.

多个稳定分支

Older lines will not be supported by the Electron project, but other groups can take ownership and backport stability and security fixes on their own. 我们不鼓励这样做,但是认识到它使得许多应用程序开发人员的生活更轻松。

Beta releases and bug fixes

开发人员想知道哪个版本可以 安全 使用。 即使是简单的功能也会使应用程序变得复杂。 同时,锁定到一个固定的版本是很危险的,因为你忽略了自你的版本以来可能出现的安全补丁和错误修复。 我们的目标是在 package.json 中允许以下标准的 semver 范围:

  • 使用 ~ 2.0. 0 只接受您的 2.0.0 版本的稳定性或安全性相关的修复程序。
  • 使用 ^ 2.0. 0 可允许不破坏性的 合理稳定 功能以及安全性和 bug 修复。

第二点重要的是使用 ^ 的应用程序仍然能够期望合理的稳定性水平。 为了达到这个目的,SemVer允许使用一个 pre-release 标识 来表示一个特定的版本还不够 安全稳定

无论你选择什么,你将定期不得不在 package.json 中打破版本,因为突破性变更是 Chromium 的一个常态。

过程如下:

  1. All new major and minor releases lines begin with a beta series indicated by SemVer prerelease tags of beta.N, e.g. 2.0.0-beta.1. After the first beta, subsequent beta releases must meet all of the following conditions:
    1. 更改是落后的 API 兼容 (允许废弃)
    2. 实现我们稳定的时间表的危险必须是低的。
  2. 如果允许更改需要在释放测试版之后进行,则使用并增加预放标签,例如2.0.0-beta.2
  3. 如果特定的beta版本通常被认为是稳定的,那么它将作为稳定版本被重新发布,只改变版本信息。例如.0。 例如 2.0.0-beta.1. 在第一个稳定之后,所有的变化都必须落后兼容的 bug 或安全修复。
  4. 如果未来错误修复或安全补丁一旦发布稳定,它们将被应用,并且 补丁 版本被增量 ,例如 2.0.1

特别地,上述步骤意味着:

  1. 在测试周期的第 3 周前允许非破坏性的 API 更改,即使这些变化有可能造成适度的副影响。
  2. Admitting feature-flagged changes, that do not otherwise alter existing code paths, at most points in the beta cycle is okay. Users can explicitly enable those flags in their apps.
  3. Admitting features of any sort after Week 3 in the beta cycle is 👎 without a very good reason.

对于每个主要和次要的颠覆,你都应该像以下示例一样进行操作:

  1. 2.0.0-beta.1
  2. 2.0.0-beta.2
  3. 2.0.0-beta.3
  4. 2.0.0
  5. 2.0.1
  6. 2.0.2

图片中的生命周期示例:

  • A new release branch is created that includes the latest set of features. 它会被发布为 2.0.0-beta.1新发行版
  • A bug fix comes into master that can be backported to the release branch. The patch is applied, and a new beta is published as 2.0.0-beta.2. 修复的 bug 移植至测试版
  • 测试版被认为是 一般稳定 的, 它在 2.0.0 下作为非 beta 版本再次被发布。 测试版至稳定版
  • 之后有个 0day 漏洞被发现,然后对 master 采取了修复措施。 We backport the fix to the 2-0-x line and release 2.0.1. 安全移植

几个不同的 SemVer 范围将如何接收新版本的示例:

Semvers 和发行版

Feature flags

功能标志是 Chromium 的一种常见的做法, 在网络开发生态系统中得到了很好的确立。 在 Electron 环境中, 功能标志或 软分支 必须具有以下属性:

  • 是在运行时或生成时启用/禁用的。我们不支持请求作用域功能标志的概念
  • 它完全细分新的和旧的代码路径; 重构旧代码以允许新功能 违反 功能标志内容
  • 在合并功能后, 功能标志最终将被删除

Semantic commits

All pull requests must adhere to the Conventional Commits spec, which can be summarized as follows:

  • 会导致 SemVer major 版本改变的提交必须以BREAKING CHANGE:开头。
  • 会导致 SemVer minor 版本改变的提交必须以 feat: 开头。
  • 会导致 SemVer patch 版本改变的提交必须以 fix: 开头。

The electron/electron repository also enforces squash merging, so you only need to make sure that your pull request has the correct title prefix.

Versioned main branch

  • The main branch will always contain the next major version X.0.0-nightly.DATE in its package.json.
  • Release branches are never merged back to main.
  • 发布分支 package.json 中包含正确的版本.
  • As soon as a release branch is cut for a major, main must be bumped to the next major (i.e. main is always versioned as the next theoretical release branch).

Historical versioning (Electron 1.X)

小于 2.0 的 Electron 版本编号并不遵循 SemVer 规范: major 版本对应最终用户 API 的变更, minor 版本更新对应 Chromium 的主版本更新, patch 版本更新会带来新功能和 bug 修复。 虽然方便开发人员合并功能,但却为面向客户端应用程序的开发人员带来了麻烦。 The QA testing cycles of major apps like Slack, Teams, Skype, VS Code, and GitHub Desktop can be lengthy and stability is a highly desired outcome. 尝试吸收错误修复时,采用新功能的风险很高。

以下是 1.x 策略的一个例子:

1.x 版本

使用 1.8.1开发的应用程序无法吸收 1.8.2 的功能,或者通过反向移植修复和维护新的发行版,无法采用 1.8.3错误修复。