1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00
tobspr_shapez.io/gulp/buildutils.js
LeopoldTal b9b8592a07
Build, sign, notarise, & upload on OS X (#687)
* sign & notarise darwin package

* upload bundle as github release

* allow unsigned build and full build with release

* deref darwin bundle symlinks only when building on win32

Windows [mangles symlinks](https://github.com/electron/electron-packager/issues/71). Currently we work around this by placing several copies of the frameworks in OS X app bundles (see 1e5aa3867d). However:

- This is invalid: the framework toplevel must [only contain symlinks](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html). `codesign` [refuses to sign](https://stackoverflow.com/questions/25969946/osx-10-9-5-code-signing-v2-signing-a-framework-with-bundle-format-is-ambiguou) this invalid structure.

- It seriously bloats the bundle.

Since there's no fix for the Windows misbehaviour, keep the workaround, but only when cross-building on win32 for darwin; and log a warning.
2020-09-27 23:14:43 +02:00

48 lines
1.3 KiB
JavaScript

const glob = require("glob");
const execSync = require("child_process").execSync;
const trim = require("trim");
const fs = require("fs");
const path = require("path");
module.exports = {
getRevision: function (useLast = false) {
const commitHash = execSync("git rev-parse --short " + (useLast ? "HEAD^1" : "HEAD")).toString(
"ascii"
);
return commitHash.replace(/^\s+|\s+$/g, "");
},
getAllResourceImages() {
return glob
.sync("res/**/*.@(png|svg|jpg)", { cwd: ".." })
.map(f => f.replace(/^res\//gi, ""))
.filter(f => {
if (f.indexOf("ui") >= 0) {
// We drop all ui images except for the noinline ones
return f.indexOf("noinline") >= 0;
}
return true;
});
},
getTag() {
try {
return execSync("git describe --tag --exact-match").toString("ascii");
} catch (e) {
throw new Error('Current git HEAD is not a version tag');
}
},
getVersion() {
return trim(fs.readFileSync(path.join(__dirname, "..", "version")).toString());
},
/**
* @param {string} url
* @param {string} commitHash
*/
cachebust(url, commitHash) {
return "/v/" + commitHash + "/" + url;
},
};