web: Seal version data in the extension manifest, too.

This commit is contained in:
David Wendt 2023-01-29 15:55:20 -05:00 committed by Nathan Adams
parent 15c7b6520b
commit 6ad6912309
3 changed files with 29 additions and 5 deletions

View File

@ -319,6 +319,7 @@ jobs:
shell: bash -l {0}
working-directory: web
env:
BUILD_ID: ${{ github.run_number }}
ENABLE_VERSION_SEAL: "true"
run: node packages/core/tools/set_version.js

View File

@ -38,6 +38,7 @@ if (process.env.ENABLE_VERSION_SEAL === "true") {
version_channel: version_channel,
build_date: build_date,
commitHash: commitHash,
build_id: process.env.BUILD_ID,
};
fs.writeFileSync("version_seal.json", JSON.stringify(version_seal));

View File

@ -3,20 +3,42 @@
const path = require("path");
const json5 = require("json5");
const CopyPlugin = require("copy-webpack-plugin");
const fs = require("fs");
function transformManifest(content, env) {
const manifest = json5.parse(content);
const packageVersion = process.env.npm_package_version;
let packageVersion = process.env.npm_package_version;
let versionChannel = process.env.CFG_RELEASE_CHANNEL || "nightly";
let buildDate = new Date().toISOString().substring(0, 10);
let build_id = process.env.BUILD_ID;
const versionChannel = process.env.CFG_RELEASE_CHANNEL || "nightly";
if (process.env.ENABLE_VERSION_SEAL === "true") {
if (fs.existsSync("../../version_seal.json")) {
const version_seal = JSON.parse(
fs.readFileSync("../../version_seal.json")
);
const buildDate = new Date().toISOString().substring(0, 10);
packageVersion = version_seal.version_number;
versionChannel = version_seal.version_channel;
buildDate = version_seal.build_date.substring(0, 10);
build_id = version_seal.build_id;
} else {
throw new Error(
"Version seal requested but not found. Please run web/packages/core/tools/set_version.js with ENABLE_VERSION_SEAL to generate it."
);
}
}
// At this point all code below needs to be deterministic. If you want other
// information to be included here you must store it in the version seal
// when it gets generated in web/packages/core/tools/set_version.js and then
// load it in the code above.
// The extension marketplaces require the version to monotonically increase,
// so append the build number onto the end of the manifest version.
manifest.version = process.env.BUILD_ID
? `${packageVersion}.${process.env.BUILD_ID}`
manifest.version = build_id
? `${packageVersion}.${build_id}`
: packageVersion;
if (env.firefox) {