-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-build-tags.js
63 lines (55 loc) · 2.04 KB
/
update-build-tags.js
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
// nicked from archmage
const yargs = require('yargs');
const fs = require('fs');
const argv = yargs
.option('branch', {
'type': 'string',
description: 'specifies the branch (CI_COMMIT_BRANCH)'
})
.option('gitlabpath', {
type: 'string',
description: 'The path on gitlab where this branch is stored (CI_PROJECT_PATH)'
})
.option('jobname', {
'type': 'string',
description: 'specifies the job name (CI_JOB_NAME)'
})
.option('tag', {
type: 'string',
description: 'The git tag used for this version (CI_COMMIT_TAG)'
})
.option('versionpre', {
type: 'string',
description: 'specifies the timestamp as a prefix on beta builds (CI_PIPELINE_IID)'
})
.demandOption(['branch', 'gitlabpath', 'jobname'])
.argv;
const systemRaw = fs.readFileSync('./system.json');
let system = JSON.parse(systemRaw);
// Calculate the version.
if (argv.branch && argv.branch == 'beta' && argv.versionpre) {
// TODO: Refactor this.
// let newVersionSplit = system.version.split('.');
// // Set the beta version.
// newVersionSplit[1]++;
// newVersionSplit[2] = 0;
// let newVersion = newVersionSplit.join('.');
// system.version = `beta${argv.versionpre ? argv.versionpre + '-' : ''}${newVersion}`;
}
else if (argv.tag) {
system.version = argv.tag;
}
// Set the artifact path.
let artifactBranch = argv.branch ? argv.branch : 'master';
let artifactVersion = argv.tag ? argv.tag : argv.branch;
// Update URLs.
system.url = `https://gitlab.com/${argv.gitlabpath}`;
system.download = `https://gitlab.com/${argv.gitlabpath}/-/jobs/artifacts/${artifactVersion}/raw/archmage.zip?job=${argv.jobname}`;
// Update manifest.
if (artifactBranch !== 'master') {
system.manifest = `https://gitlab.com/${argv.gitlabpath}/-/jobs/artifacts/${artifactVersion}/raw/system.json?job=${argv.jobname}`;
}
fs.writeFileSync('./system.json', JSON.stringify(system, null, 2));
console.log(`Build: ${system.version}`);
console.log(`Manifest: ${system.manifest}`);
console.log(`Download: ${system.download}`);