• 发布
    • Set your tokens and environment variables
    • 决定从哪个版本发布
    • 找出需要哪个版本更改
    • 运行 prepare-release 脚本
      • Major 版本更改
      • Minor 版本更改
      • Patch 版本更改
      • Beta 版本更改
      • 促进 beta 稳定
    • 等待构建 ⏳
    • 编译发布说明
      • Patch 发布
      • Minor 发布
      • Major 发布
      • Beta 发布
    • 编辑发布草稿
    • 发布版本
    • 发布到 npm
  • 故障排查
    • 重新运行中断的构建
      • Rerun all linux builds:
      • Rerun all macOS builds:
      • Rerun all Windows builds:
    • 手动修复发行版的缺失二进制文件

    发布

    本文档描述了发布 Electron 版本的过程。

    Set your tokens and environment variables

    You'll need Electron S3 credentials in order to create and upload an Electron release. Contact a team member for more information.

    There are a handful of *_TOKEN environment variables needed by the release scripts:

    • ELECTRON_GITHUB_TOKEN: Create this by visiting https://github.com/settings/tokens/new?scopes=repo
    • APPVEYOR_TOKEN: Create a token from https://windows-ci.electronjs.org/api-token If you don't have an account, ask a team member to add you.
    • CIRCLE_TOKEN: Create a token from "Personal API Tokens" at https://circleci.com/account/api
    • VSTS_TOKEN: Create a Personal Access Token at https://github.visualstudio.com/_usersSettings/tokens or https://github.visualstudio.com/_details/security/tokens with the scope of Build (read and execute).
    • ELECTRON_S3_BUCKET:
    • ELECTRON_S3_ACCESS_KEY:
    • ELECTRON_S3_SECRET_KEY: If you don't have these, ask a team member to help you.
      一旦你生成了这些令牌,把它们放到工程根目录的.env文件中,这个文件是git忽略的,将会被分发的脚本加载到环境中

    决定从哪个版本发布

    • 如果发布beta版本,请从master运行以下脚本。
    • 如果发布稳定版本,请从你要试图稳定的分支运行下列脚本。

    找出需要哪个版本更改

    运行npm run prepare-release — —notesOnly来查看自动生成的发布说明。 生成的记录会帮助你判断这是主要的、次要的、补丁或者是公测版本变化 请参考版本变更规则以获取更多信息。

    注意: 如果从一个分支发布,例如1-8-x,使用 git checkout 1-8-x 检出分支而不是 git checkout -b remotes/origin/1-8-x。 这脚本需要git rev-parse —abbrev-ref HEAD返回一个短名称, 例如:no remotes/origin/

    运行 prepare-release 脚本

    准备好的分发脚本将会做以下事情: 1. 校验一个分布是否已经在 process 中,如果是,将会停止。 2. 创建一个发布分支。 3. 碰撞个几文件的版本号 参照这冲突提交这个例子 4. 用自动生成的发布记录在GitHub上创建一个发布草案 5. 推送release分支 6. 调用API以运行release构建

    一旦你确定需要的版本改变类型,用你需要参数运行prepare-release脚本: -[major|minor|patch|beta]增量一个版本号,或者 - —stable 来表明这是一个稳定版本

    例如:

    Major 版本更改

    1. npm run prepare-release -- major

    Minor 版本更改

    1. npm run prepare-release -- minor

    Patch 版本更改

    1. npm run prepare-release -- patch --stable

    Beta 版本更改

    1. npm run prepare-release -- beta

    促进 beta 稳定

    1. npm run prepare-release -- --stable

    Tip: You can test the new version number before running prepare-release with a dry run of the bump-version script with the same major/minor/patch/beta arguments, e.g.:

    1. $ ./script/bump-version.py --bump minor --dry-run

    等待构建 ⏳

    prepare-release 脚本将通过 API 调用触发生成。要监视生成进度, 请参阅以下页面:

    • electron-release-mas-x64 for MAS builds.
    • electron-release-osx-x64 for OSX builds.
    • circleci.com/gh/electron/electron for Linux builds.
    • windows-ci.electronjs.org/project/AppVeyor/electron-39ng6 for Windows 32-bit builds.
    • windows-ci.electronjs.org/project/AppVeyor/electron for Windows 64-bit builds.

    编译发布说明

    编写发行说明是在生成运行时保持忙碌的好方法。 有关以前的技术, 请参阅 发布页 上的现有版本。

    Tips: - Each listed item should reference a PR on electron/electron, not an issue, nor a PR from another repo like libcc. - No need to use link markup when referencing PRs. Strings like #123 will automatically be converted to links on github.com. - To see the version of Chromium, V8, and Node in every version of Electron, visit atom.io/download/electron/index.json.

    Patch 发布

    对于 修补程序 版本, 请使用以下格式:

    1. ## Bug 修复
    2. * 修复跨平台问题. #123
    3. ### Linux
    4. * 修复 Linux 问题. #123
    5. ### macOS
    6. * 修复 macOS 问题. #123
    7. ### Windows
    8. * 修复 Windows 问题. #1234

    Minor 发布

    对于 次要 版本, 如 1.8.0, 请使用以下格式:

    1. ## 升级
    2. - 升级 Node `oldVersion` `newVersion`. #123
    3. ## API 变更
    4. * 变更内容. #123
    5. ### Linux
    6. * 变更 Linux 内容. #123
    7. ### macOS
    8. * 变更 macOS 内容. #123
    9. ### Windows
    10. * 变更 Windows 内容. #123

    Major 发布

    1. ## 升级
    2. - 升级 Chromium `oldVersion` `newVersion`. #123
    3. - 升级 Node `oldVersion` `newVersion`. #123
    4. ## 破坏性 API 变更
    5. * 变更内容. #123
    6. ### Linux
    7. * 变更 Linux 内容. #123
    8. ### macOS
    9. * 变更 macOS 内容. #123
    10. ### Windows
    11. * 变更 Windows 内容. #123
    12. ## 其它变更
    13. - 其它变更内容. #123

    Beta 发布

    使用与上述建议相同的格式,但在变更日志的开头添加以下内容:

    1. **注意:** 这是一个测试版本并很可能会有一些不稳定和/或复原。
    2. 请为您在其中找到的任何错误提出新问题。
    3. This release is published to [npm](https://www.npmjs.com/package/electron)
    4. under the `beta` tag and can be installed via `npm install electron@beta`.

    编辑发布草稿

    • 访问 发行页面 然后你将看到一个新的带有发行说明的草稿版本。
    • 编辑版本并添加发行说明.
    • 点击 'Save draft'. 不要点 'Publish release'!
    • 等待所有生成通过, 然后再继续。
    • In the branch, verify that the release's files have been created:
    1. $ npm run release -- --validateRelease

    Note, if you need to run —validateRelease more than once to check the assets, run it as above the first time, then node ./script/release.js —validateRelease for subsequent calls so that you don't have to rebuild each time you want to check the assets.

    发布版本

    Once the merge has finished successfully, run the release script via npm run release to finish the release process. 这个脚本会完成下列内容:1. Build the project to validate that the correct version number is being released. 2. Download the binaries and generate the node headers and the .lib linker used on Windows by node-gyp to build native modules. 3. Create and upload the SHASUMS files stored on S3 for the node files. 4. 创建并上传储存在GitHub发布中的SHASUMS256.txt文件。 5. Validate that all of the required files are present on GitHub and S3 and have the correct checksums as specified in the SHASUMS files. 6. 在Github上发布release

    发布到 npm

    在发布到npm之前,您会需要作为Electron登入npm。 Optionally, you may find npmrc to be a useful way to keep Electron's profile side-by-side with your own:

    1. $ sudo npm install -g npmrc
    2. $ npmrc -c electron
    3. Removing old .npmrc (default)
    4. Activating .npmrc "electron"

    The Electron account's credentials are kept by GitHub in a password manager. You'll also need to have access to an 2FA authenticator app with the appropriate OTP generator code to log in.

    1. $ npm login
    2. Username: electron-nightly
    3. Password: <This can be found under NPM Electron Nightly on LastPass>
    4. Email: (this IS public) electron@github.com

    Publish the release to npm. Before running this you'll need to have set ELECTRON_NPM_OTP as an environment variable using a code from the aforementioned 2FA authenticator app.

    1. $ npm whoami
    2. electron-nightly
    3. $ npm run publish-to-npm

    After publishing, you can check the latest release:

    1. $ npm dist-tag ls electron

    If for some reason npm run publish-to-npm fails, you can tag the release manually:

    1. npm dist-tag add electron@&lt;version&gt; &lt;tag&gt;

    例如:

    1. npm dist-tag add electron@2.0.0 latest

    故障排查

    重新运行中断的构建

    如果一个分发构建因某些原因失败,你可以用script/ci-release-build.js重新运行一次分发构建:

    Rerun all linux builds:

    1. node script/ci-release-build.js --ci=CircleCI --ghRelease TARGET_BRANCH
    2. (TARGET_BRANCH) is the branch you are releasing from.

    Rerun all macOS builds:

    1. node script/ci-release-build.js --ci=VSTS --ghRelease TARGET_BRANCH
    2. (TARGET_BRANCH) is the branch you are releasing from.

    Rerun all Windows builds:

    1. node script/ci-release-build.js --ci=AppVeyor --ghRelease TARGET_BRANCH
    2. (TARGET_BRANCH) is the branch you are releasing from.

    Additionally you can pass a job name to the script to run an individual job, eg:

    1. node script/ci-release-build.js --ci=AppVeyor --ghRelease --job=electron-x64 TARGET_BRANCH

    手动修复发行版的缺失二进制文件

    在发布版本受损的情况下,则可能需要重新上传已发布版本的二进制文件。

    第一步是转到Releases页面,并使用 SHASUMS256.txt校验文件和删除损坏的二进制文件。

    然后手动为每个平台创建分发并上传它们:

    1. # 检出要重新上传的版本。
    2. git checkout vX.Y.Z
    3. # Create release build
    4. gn gen out/Release --args="import(\"//electron/build/args/release.gn\") $GN_EXTRA_ARGS"
    5. # To compile for specific arch, instead set
    6. gn gen out/Release-<TARGET_ARCH> --args='import(\"//electron/build/args/release.gn\") target_cpu = "[arm|x64|ia32]"'
    7. # Build by running ninja with the electron target
    8. ninja -C out/Release electron
    9. ninja -C out/Release electron:dist_zip
    10. # Explicitly allow overwriting a published release.
    11. ./script/upload.py --overwrite

    Allowable values for target_cpu and target_os.

    重新上传所有发行版之后,再次发布以上载校验和文件:

    1. npm run release