-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-build.mjs
60 lines (55 loc) · 1.93 KB
/
github-build.mjs
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
import pkg from './package.json'
import Builder from 'alpheios-node-build'
import generateBuildInfo from './node_modules/alpheios-node-build/dist/support/build-info.mjs'
import { execFileSync, execSync } from 'child_process'
import * as core from '@actions/core'
(async function() {
const buildDT = Date.now()
const buildInfo = generateBuildInfo(buildDT)
const npmTag = buildInfo.branch === 'production' ? 'rc' : buildInfo.branch
console.log(`Starting build ${buildInfo.name}`)
const baseVersion = pkg.version.split('-')[0]
const version = `${baseVersion}-${buildInfo.name}`
console.log(`Setting a package version to ${version}`)
let output
try {
if (buildInfo.branch === 'qa' || buildInfo.branch === 'production') {
console.info(`Installing alpheios-core`)
output = execSync(`npm install https://github.com/alpheios-project/alpheios-core#${buildInfo.branch}`)
}
} catch (error) {
console.error('Components install failed:', error)
process.exit(1)
}
try {
const output = execSync(`npm version ${version} --no-git-tag-version --force`, { encoding: 'utf8' })
} catch (e) {
console.error('Cannot execute npm version:', e)
process.exit(2)
}
console.log('Rebuilding an embedded library. This may take a while')
try {
const builder = new Builder({
module: 'all',
mode: 'all',
preset: 'app',
codeAnalysis: false,
outputLevel: Builder.outputLevels.MIN,
buildTime: buildDT
})
await builder.importConfig('config.mjs', 'build')
await builder.runModules()
} catch (error) {
console.error('Build process failed:', error)
process.exit(3)
}
console.log('Rebuilding of an embedded library has been completed')
try {
console.info(core)
core.default.setOutput('buildName',buildInfo.name)
core.default.setOutput('npmTag',npmTag)
} catch (error) {
console.error('Failed to set output variable:', error)
process.exit(4)
}
})()