Skip to content

Commit ad00bc8

Browse files
committed
ci: fix scripts
1 parent 46fcb53 commit ad00bc8

4 files changed

Lines changed: 43 additions & 78 deletions

File tree

.github/workflows/pages.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
"packageManager": "pnpm@10.13.1",
66
"license": "MIT",
77
"scripts": {
8-
"lint": "eslint --cache"
8+
"lint": "eslint --cache",
9+
"build": "node --experimental-strip-types scripts/build.mts"
910
},
1011
"devDependencies": {
1112
"@antfu/eslint-config": "^5.2.1",
12-
"eslint": "^9.33.0"
13+
"eslint": "^9.33.0",
14+
"zx": "^8.8.0"
1315
}
1416
}

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build.mts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { $ } from 'zx'
2+
3+
// Build Go service
4+
console.log('Building Go service...')
5+
const ldflags = `-s -w -X 'logic.version=${new Date().toISOString().slice(0, 10).replace(/-/g, '')}' -X 'logic.appBaseUrl=http://uni-token.app'`
6+
const releaseDir = 'frontend/public/release'
7+
8+
await $`mkdir -p ${releaseDir}`
9+
10+
// Build for different platforms
11+
await $`GOOS=linux GOARCH=amd64 go -C service build -ldflags=${ldflags} -o ../${releaseDir}/service-linux-amd64 ./main.go`
12+
await $`GOOS=windows GOARCH=amd64 go -C service build -ldflags=${ldflags} -o ../${releaseDir}/service-windows-amd64.exe ./main.go`
13+
await $`GOOS=darwin GOARCH=amd64 go -C service build -ldflags=${ldflags} -o ../${releaseDir}/service-darwin-amd64 ./main.go`
14+
15+
// Compress binaries with UPX (if available)
16+
try {
17+
console.log('Compressing binaries...')
18+
await $`upx --best --lzma ${releaseDir}/service-linux-amd64`
19+
await $`upx --best --lzma ${releaseDir}/service-windows-amd64.exe`
20+
}
21+
catch (err: any) {
22+
console.log(`UPX not available, skipping compression. ${err}`)
23+
}
24+
25+
// Build frontend
26+
console.log('Building frontend...')
27+
await $`pnpm -C frontend build`
28+
29+
console.log('Build complete! Files are in frontend/dist/')

0 commit comments

Comments
 (0)