From b4c173759c11e0203a69fa5a1aec75a1dcd7b046 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Mon, 9 Aug 2021 12:09:51 +0700 Subject: [PATCH] Task: Add build.js for build in cross platforms and all profiles in github actions --- .github/workflows/electron-sandbox.yml | 5 ++- build.js | 62 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 build.js diff --git a/.github/workflows/electron-sandbox.yml b/.github/workflows/electron-sandbox.yml index eab0fcf..58a212c 100644 --- a/.github/workflows/electron-sandbox.yml +++ b/.github/workflows/electron-sandbox.yml @@ -28,7 +28,10 @@ jobs: yarn install - name: Publish run: | - yarn run dist + node build.js clinic && yarn dist + node build.js dr && yarn dist + node build.js em && yarn dist + node build.js kesor && yarn dist - name: Cleanup artifacts Linux and macOS if: matrix.os != 'windows-latest' run: | diff --git a/build.js b/build.js new file mode 100644 index 0000000..8099af7 --- /dev/null +++ b/build.js @@ -0,0 +1,62 @@ +const fs = require("fs"); +const argProfile = process.argv.slice(2); +// const { exec } = require('child_process'); + +if (argProfile.length === 0) { + return; +} + +argProfile.forEach((profile) => { + const profileEnv = `./profile/${profile}.dev`; + const profileJs = `./profile/${profile}.js`; + + console.log("Generating for electron-builder.env"); + fs.readFile(profileEnv, "utf8", (err, data) => { + if (err) { + console.log(err); + return; + } + + console.log(data); + + fs.writeFile("./electron-builder.env", data, "utf8", (err) => { + if (err) { + console.log(err); + return; + } + + console.log("file saved"); + }); + }); + + console.log("Generating for lib.js"); + fs.readFile(profileJs, "utf8", (err, data) => { + if (err) { + console.log(err); + return; + } + + console.log(data); + + fs.writeFile("./lib.js", data, "utf8", (err) => { + if (err) { + console.log(err); + return; + } + + console.log("file saved"); + }); + }); + + // console.log("Building for " + profile + "...!"); + // exec('yarn dist', (err, stdout, stderr) => { + // if (err) { + // console.log(err); + // return; + // } + + // console.log(`stdout: ${stdout}`); + // console.log(`stderr: ${stderr}`); + // }); + +});