-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
github-build.mjs
48 lines (45 loc) · 1.62 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
import pkg from './lerna.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 {
const output = execSync(`npx lerna version ${version} --no-git-tag-version --no-push --yes`, { encoding: 'utf8' })
} catch (e) {
console.error('Cannot execute npm version:', e)
process.exit(1)
}
console.log('Rebuilding a components library. This may take a while')
try {
const builder = new Builder({
module: 'webpack',
mode: 'all',
preset: 'vue',
codeAnalysis: false,
outputLevel: Builder.outputLevels.MIN,
buildTime: buildDT
})
await builder.importConfig('config-github-build.mjs', 'packages/components/build')
await builder.runModules()
} catch (error) {
console.error('Build process failed:', error)
process.exit(2)
}
console.log('Rebuilding of a components library has been completed')
try {
core.default.setOutput('buildName',buildInfo.name)
core.default.setOutput('npmTag',npmTag)
} catch (error) {
console.error('Failed to set output variable:', error)
process.exit(3)
}
})()