mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-22 07:07:53 +00:00
ci: add build summary
This commit is contained in:
parent
6c5404e508
commit
1913d063b9
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -54,6 +54,12 @@ jobs:
|
|||||||
name: engine-chronocat-event-${{ github.sha }}
|
name: engine-chronocat-event-${{ github.sha }}
|
||||||
path: build/dist/engine-chronocat-event
|
path: build/dist/engine-chronocat-event
|
||||||
|
|
||||||
|
- name: Upload Build Metadata
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: meta-${{ github.sha }}
|
||||||
|
path: build/meta
|
||||||
|
|
||||||
- name: Publish LiteLoaderQQNT-Plugin-Chronocat
|
- name: Publish LiteLoaderQQNT-Plugin-Chronocat
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import { analyzeMetafile, context } from 'esbuild'
|
import { analyzeMetafile, context } from 'esbuild'
|
||||||
import { join } from 'node:path'
|
import { appendFile, mkdir, writeFile } from 'node:fs/promises'
|
||||||
|
import { join, resolve } from 'node:path'
|
||||||
import { cwd } from 'node:process'
|
import { cwd } from 'node:process'
|
||||||
|
|
||||||
const wd = cwd()
|
const wd = cwd()
|
||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
||||||
const { version } = require(join(wd, 'package.json'))
|
const packageJson = require(join(wd, 'package.json')) as {
|
||||||
|
name: string
|
||||||
|
version: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = packageJson.name.slice(11)
|
||||||
|
|
||||||
const ctx = await context({
|
const ctx = await context({
|
||||||
entryPoints: [join(wd, 'src/index.ts')],
|
entryPoints: [join(wd, 'src/index.ts')],
|
||||||
@ -24,7 +30,7 @@ void (async () => {
|
|||||||
tsconfig: join(wd, 'tsconfig.json'),
|
tsconfig: join(wd, 'tsconfig.json'),
|
||||||
|
|
||||||
define: {
|
define: {
|
||||||
__DEFINE_CHRONO_VERSION__: `'${version}'`,
|
__DEFINE_CHRONO_VERSION__: `'${packageJson.version}'`,
|
||||||
},
|
},
|
||||||
external: ['electron'],
|
external: ['electron'],
|
||||||
|
|
||||||
@ -36,6 +42,27 @@ void (async () => {
|
|||||||
color: true,
|
color: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(await analyzeMetafile((await ctx.rebuild()).metafile))
|
const result = await ctx.rebuild()
|
||||||
|
|
||||||
|
const metafile = result.metafile
|
||||||
|
const metaLog = await analyzeMetafile(metafile)
|
||||||
|
const metaDir = resolve(__dirname, '../build/meta')
|
||||||
|
const metaFilePath = join(metaDir, `${name}.meta.json`)
|
||||||
|
|
||||||
|
await mkdir(metaDir, {
|
||||||
|
recursive: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
await writeFile(metaFilePath, JSON.stringify(metafile))
|
||||||
|
|
||||||
|
if ('GITHUB_ACTIONS' in process.env) {
|
||||||
|
// CI
|
||||||
|
const summary = `## ${name} 的构建一览\n\n\`\`\`txt\n${metaLog}\n\n\`\`\`\n\n要获得旭日图或火焰图,下载 \`meta-xxx.zip\` 后上传至 [Bundle Size Analyzer](https://esbuild.github.io/analyze/)。\n\n`
|
||||||
|
await appendFile(process.env['GITHUB_STEP_SUMMARY'] as string, summary)
|
||||||
|
} else {
|
||||||
|
// Local build
|
||||||
|
console.log(metaLog)
|
||||||
|
}
|
||||||
|
|
||||||
await ctx.dispose()
|
await ctx.dispose()
|
||||||
})()
|
})()
|
||||||
|
Loading…
Reference in New Issue
Block a user