-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Winbundle support * Fix config-default, paths * Add libcurl * Include libs contents
- Loading branch information
Showing
4 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Publish Windows Bundle | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '12' | ||
- name: Setup Env | ||
run: | | ||
npm i | ||
npm i -g nexe | ||
- name: Build bundle | ||
run: | | ||
npm run winbundle | ||
- name: Upload Bundle File | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Bundle | ||
path: dist\*.zip | ||
- name: Upload Bundle to Release | ||
uses: svenstaro/upload-release-action@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: dist\*.zip | ||
file_glob: true | ||
tag: ${{ github.ref }} | ||
overwrite: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,5 @@ | |
"stale-uploads-timeout": 0, | ||
"ssl-key": "", | ||
"ssl-cert": "", | ||
"asr": "", | ||
"asr": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
const fs = require('fs'); | ||
const spawnSync = require('child_process').spawnSync; | ||
const path = require('path'); | ||
const async = require('async'); | ||
const archiver = require('archiver'); | ||
|
||
const bundleName = "clusterodm-windows-x64.zip"; | ||
|
||
async.series([ | ||
cb => { | ||
// Cleanup directories | ||
console.log("Cleaning up folders"); | ||
for (let dir of ["data", "tmp"]){ | ||
for (let entry of fs.readdirSync(dir)){ | ||
if (entry !== ".gitignore"){ | ||
const e = path.join(dir, entry); | ||
console.log(`Removing ${e}`); | ||
if (fs.lstatSync(e).isDirectory()){ | ||
fs.rmdirSync(e, { recursive: true }); | ||
}else{ | ||
fs.unlinkSync(e); | ||
} | ||
} | ||
} | ||
} | ||
cb(); | ||
}, | ||
|
||
cb => { | ||
console.log("Building executable"); | ||
const code = spawnSync('nexe.cmd', ['index.js', '-t', 'windows-x64-12.16.3', '-o', 'clusterodm.exe', '-r', 'libs/**'], { stdio: "pipe"}).status; | ||
|
||
if (code === 0) cb(); | ||
else cb(new Error(`nexe returned non-zero error code: ${code}`)); | ||
}, | ||
cb => { | ||
// Zip | ||
const outFile = path.join("dist", bundleName); | ||
if (!fs.existsSync("dist")) fs.mkdirSync("dist"); | ||
if (fs.existsSync(outFile)) fs.unlinkSync(outFile); | ||
|
||
let output = fs.createWriteStream(outFile); | ||
let archive = archiver.create('zip', { | ||
zlib: { level: 5 } // Sets the compression level (1 = best speed since most assets are already compressed) | ||
}); | ||
|
||
archive.on('finish', () => { | ||
console.log("Done!"); | ||
cb(); | ||
}); | ||
|
||
archive.on('error', err => { | ||
console.error(`Could not archive .zip file: ${err.message}`); | ||
cb(err); | ||
}); | ||
|
||
const files = [ | ||
"data", | ||
"docs", | ||
"letsencrypt", | ||
"public", | ||
"tmp", | ||
"config-default.json", | ||
"LICENSE", | ||
"package.json", | ||
"clusterodm.exe" | ||
]; | ||
|
||
archive.pipe(output); | ||
files.forEach(file => { | ||
console.log(`Adding ${file}`); | ||
let stat = fs.lstatSync(file); | ||
if (stat.isFile()){ | ||
archive.file(file, {name: path.basename(file)}); | ||
}else if (stat.isDirectory()){ | ||
archive.directory(file, path.basename(file)); | ||
}else{ | ||
logger.error(`Could not add ${file}`); | ||
} | ||
}); | ||
|
||
// Plus node-libcurl | ||
console.log("Adding node_modules/node-libcurl") | ||
archive.directory(path.join("node_modules", "node-libcurl"), path.join("node_modules", "node-libcurl")); | ||
|
||
archive.finalize(); | ||
} | ||
], (err) => { | ||
if (err) console.log(`Bundle failed: ${err}`); | ||
else console.log(`Bundle ==> dist/${bundleName}`); | ||
}); | ||
|
||
|