Set version automatically

Convert the check script to a script that sets the version to match
whatever Riot is being packaged.

Add a README because the two ways of interacting with versions are
starting to get complex to reason about.

Also add a docker build script.
This commit is contained in:
David Baker
2019-12-12 19:33:29 +00:00
parent c43a742df4
commit 3b58fdc8d9
6 changed files with 128 additions and 17 deletions
-15
View File
@@ -1,15 +0,0 @@
#!/usr/bin/env node
const fs = require('fs').promises;
async function main() {
try {
const webappDir = await fs.stat('webapp.asar');
return 0;
} catch (e) {
console.log("No 'webapp.asar' found. Run 'yarn run fetch'");
return 1;
}
}
main().then((ret) => process.exit(ret));
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# Taken from https://www.electron.build/multi-platform-build#docker
docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder yarn run build
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env node
/*
* Checks for the pre3sence of a webapp, inspects its version and sets the
* version metadata of the package to match.
*/
const fs = require('fs').promises;
const asar = require('asar');
const child_process = require('child_process');
async function main() {
try {
const webappDir = await fs.stat('webapp.asar');
} catch (e) {
console.log("No 'webapp.asar' found. Run 'yarn run fetch'");
return 1;
}
const ver = asar.extractFile('webapp.asar', 'version').toString().trim();
await new Promise((resolve, reject) => {
child_process.execFile('yarn', [
'version',
'-s',
'--no-git-tag-version', // This also means "don't commit to git" as it turns out
'--new-version',
ver,
], (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
console.log("Version set to " + ver);
}
main().then((ret) => process.exit(ret));