-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.ts
60 lines (51 loc) · 1.54 KB
/
release.ts
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 { existsSync } from 'fs'
import { appendFile, rm } from 'fs/promises'
import { glob } from 'glob'
import { join } from 'path'
import { BuildType, PluginBuilder, type BuildMetadata, type BuildOptions, type BuildRelease } from './build'
const outputDirectory = join(process.cwd(), 'releases')
const options: BuildOptions = {
entryFile: 'src/app.ts',
// signatureLength: 256,
outputDirectory,
}
const projects: BuildMetadata[] = [
{
path: 'plugins/*',
type: BuildType.File,
release: true,
prebuild: true,
options
},
{
path: 'packages/*',
type: BuildType.File,
options
},
{
path: 'core',
type: BuildType.Binary,
release: true,
options
}
]
const releases: BuildRelease[] = []
if (existsSync('releases') && !(process.env.BINARY || process.env.PREBUILD)) {
await rm('releases', { recursive: true })
}
for (const project of projects) {
if (
(process.env['BINARY'] && !(project.type === BuildType.Binary))
|| (process.env['PREBUILD'] && !project.prebuild)) continue
for (const path of await glob([project.path], { cwd: process.cwd() })) {
project.path = path
const builder = new PluginBuilder(project)
await builder.build()
if (project.options?.signatureLength) {
await builder.sign(join(process.cwd(), 'core/privateKey.pem'))
await builder.singCheck(join(process.cwd(), 'core/publicKey.pem'))
}
releases.push(await builder.release())
}
}
await appendFile(join(outputDirectory, 'metadata.json'), JSON.stringify(releases, null, 2), { encoding: 'utf-8' })