Embed git SHA at build time via define flag
This commit is contained in:
parent
dfb865e433
commit
0ae4e6e9b2
|
|
@ -9,6 +9,7 @@ import { join } from 'path'
|
|||
|
||||
const DIST_DIR = join(import.meta.dir, '..', 'dist')
|
||||
const ENTRY_POINT = join(import.meta.dir, '..', 'src', 'cli', 'index.ts')
|
||||
const GIT_SHA = Bun.spawnSync(['git', 'rev-parse', '--short', 'HEAD']).stdout.toString().trim() || 'unknown'
|
||||
|
||||
interface BuildTarget {
|
||||
arch: string
|
||||
|
|
@ -40,6 +41,7 @@ async function buildCurrent() {
|
|||
'bun',
|
||||
'--minify',
|
||||
'--sourcemap=external',
|
||||
`--define=__GIT_SHA__="${GIT_SHA}"`,
|
||||
'--outfile',
|
||||
output,
|
||||
], {
|
||||
|
|
@ -73,6 +75,7 @@ async function buildTarget(target: BuildTarget) {
|
|||
`bun-${target.os}-${target.arch}`,
|
||||
'--minify',
|
||||
'--sourcemap=external',
|
||||
`--define=__GIT_SHA__="${GIT_SHA}"`,
|
||||
'--outfile',
|
||||
output,
|
||||
], {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
const result = Bun.spawnSync(['git', 'rev-parse', '--short', 'HEAD'])
|
||||
declare var __GIT_SHA__: string
|
||||
|
||||
export const SHA = result.stdout.toString().trim()
|
||||
export const SHA: string = typeof __GIT_SHA__ !== 'undefined' ? __GIT_SHA__ : 'dev'
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user