Task: Add build.js for build in cross platforms and all profiles in github actions

This commit is contained in:
Sambo Chea 2021-08-09 12:09:51 +07:00
parent b8fcde6a0d
commit b4c173759c
2 changed files with 66 additions and 1 deletions

View File

@ -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: |

62
build.js Normal file
View File

@ -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}`);
// });
});