mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
Set version in fetch script
Which plays better with doing develop builds.
This commit is contained in:
parent
c0e4ad4aff
commit
40dc1d9384
@ -14,13 +14,12 @@
|
||||
"scripts": {
|
||||
"mkdirs": "mkdirp packages deploys",
|
||||
"fetch": "yarn run mkdirs && node scripts/fetch-package.js",
|
||||
"setversion": "node scripts/set-version.js",
|
||||
"start": "electron .",
|
||||
"lint": "eslint src/ scripts/ hak/",
|
||||
"build:native": "yarn run hak",
|
||||
"build32": "yarn run setversion && electron-builder --ia32",
|
||||
"build64": "yarn run setversion && electron-builder --x64",
|
||||
"build": "yarn run setversion && electron-builder",
|
||||
"build32": "electron-builder --ia32",
|
||||
"build64": "electron-builder --x64",
|
||||
"build": "electron-builder",
|
||||
"docker:setup": "docker build -t riot-desktop-dockerbuild dockerbuild",
|
||||
"docker:build:native": "scripts/in-docker.sh yarn run hak",
|
||||
"docker:build": "scripts/in-docker.sh yarn run build",
|
||||
|
@ -15,6 +15,8 @@ const PUB_KEY_URL = "https://packages.riot.im/riot-release-key.asc";
|
||||
const PACKAGE_URL_PREFIX = "https://github.com/vector-im/riot-web/releases/download/";
|
||||
const ASAR_PATH = 'webapp.asar';
|
||||
|
||||
const {setPackageVersion, setDebVersion} = require('./set-version.js');
|
||||
|
||||
async function getLatestDevelopUrl(bkToken) {
|
||||
const buildsResult = await needle('get',
|
||||
"https://api.buildkite.com/v2/organizations/matrix-dot-org/pipelines/riot-web/builds",
|
||||
@ -116,6 +118,7 @@ async function main() {
|
||||
let targetVersion;
|
||||
let filename;
|
||||
let url;
|
||||
let setVersion = false;
|
||||
|
||||
while (process.argv.length > 2) {
|
||||
switch (process.argv[2]) {
|
||||
@ -146,6 +149,8 @@ async function main() {
|
||||
|
||||
if (targetVersion === undefined) {
|
||||
targetVersion = 'v' + riotDesktopPackageJson.version;
|
||||
filename = 'riot-' + targetVersion + '.tar.gz';
|
||||
url = PACKAGE_URL_PREFIX + targetVersion + '/' + filename;
|
||||
} else if (targetVersion === 'develop') {
|
||||
const buildKiteApiKey = process.env.BUILDKITE_API_KEY;
|
||||
if (buildKiteApiKey === undefined) {
|
||||
@ -161,6 +166,7 @@ async function main() {
|
||||
} else {
|
||||
filename = 'riot-' + targetVersion + '.tar.gz';
|
||||
url = PACKAGE_URL_PREFIX + targetVersion + '/' + filename;
|
||||
setVersion = true;
|
||||
}
|
||||
|
||||
const haveGpg = await new Promise((resolve) => {
|
||||
@ -272,6 +278,14 @@ async function main() {
|
||||
|
||||
console.log("Pack " + expectedDeployDir + " -> " + ASAR_PATH);
|
||||
await asar.createPackage(expectedDeployDir, ASAR_PATH);
|
||||
|
||||
if (setVersion) {
|
||||
const semVer = targetVersion.slice(1);
|
||||
console.log("Updating version to " + semVer);
|
||||
await setPackageVersion(semVer);
|
||||
await setDebVersion(semVer);
|
||||
}
|
||||
|
||||
console.log("Done!");
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ const fs = require('fs').promises;
|
||||
const asar = require('asar');
|
||||
const childProcess = require('child_process');
|
||||
|
||||
async function main() {
|
||||
async function versionFromAsar() {
|
||||
try {
|
||||
await fs.stat('webapp.asar');
|
||||
} catch (e) {
|
||||
@ -17,8 +17,10 @@ async function main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const ver = asar.extractFile('webapp.asar', 'version').toString().trim();
|
||||
return asar.extractFile('webapp.asar', 'version').toString().trim();
|
||||
}
|
||||
|
||||
async function setPackageVersion(ver) {
|
||||
// set version in package.json: electron-builder will use this to populate
|
||||
// all the various version fields
|
||||
await new Promise((resolve, reject) => {
|
||||
@ -36,7 +38,9 @@ async function main() {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function setDebVersion(ver) {
|
||||
// Also create a debian package control file with the version.
|
||||
// We use a custom control file so we need to do this ourselves
|
||||
const outFile = await fs.open('pkg/control', 'w');
|
||||
@ -48,4 +52,29 @@ async function main() {
|
||||
console.log("Version set to " + ver);
|
||||
}
|
||||
|
||||
main().then((ret) => process.exit(ret));
|
||||
async function main(args) {
|
||||
let setDeb = false;
|
||||
let setPkg = false;
|
||||
let version;
|
||||
|
||||
for (const arg of args) {
|
||||
if (arg === '--deb') {
|
||||
setDeb = true;
|
||||
} else if (arg === '--pkg') {
|
||||
setPkg = true;
|
||||
} else {
|
||||
version = arg;
|
||||
}
|
||||
}
|
||||
|
||||
if (version === undefined) version = await versionFromAsar();
|
||||
|
||||
if (setPkg) setDebVersion(ver);
|
||||
if (setDeb) setDebVersion(ver);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main(process.argv.slice(2)).then((ret) => process.exit(ret));
|
||||
}
|
||||
|
||||
module.exports = {versionFromAsar, setPackageVersion, setDebVersion};
|
||||
|
Loading…
Reference in New Issue
Block a user