forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (51 loc) · 1.63 KB
/
index.js
File metadata and controls
64 lines (51 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const core = require('@actions/core');
const github = require('@actions/github');
const exec = require('@actions/exec');
const fs = require('fs');
const path = require('path');
process.on('unhandledRejection', function(reason, _) {
handleError(reason);
});
function addToPath(_path) {
console.log(`adding ${_path} to Path`);
process.env['Path'] = _path + ';' + process.env['Path'];
}
main().catch(handleError)
async function main() {
const exePath = core.getInput('exe');
const version = github.context.ref.replace('refs/tags/', '');
console.log(`Building MSI for version ${version}`);
const wixPath = process.env['WIX'] + '\\bin';
addToPath(wixPath);
await go_msi(version, exePath);
}
async function go_msi(version, exePath) {
const cwd = process.cwd();
// go-msi was struggling with its default temp dir; it wanted something relative to the source dir
// for some reason.
console.log('making build path');
const buildPath = path.join(cwd, 'build');
fs.mkdirSync(buildPath);
console.log('making bin path');
const binPath = path.join(cwd, 'bin');
fs.mkdirSync(binPath);
console.log(`moving ${exePath} to bin/gh.exe`);
fs.renameSync(exePath, path.join(binPath, 'gh.exe'));
const msiPath = path.join(cwd, 'gh.msi');
try {
await exec.exec(
'"C:\\Program Files\\go-msi\\go-msi.exe"',
['make',
'--msi', msiPath,
'--out', buildPath,
'--version', version]);
console.log(`build MSI at ${msiPath}`);
core.setOutput('msi', msiPath);
} catch(e) {
core.setFailed(e.message);
}
}
async function handleError(err) {
console.error(err);
core.setFailed(err.message);
}