Skip to content

Commit b915ce7

Browse files
committed
create build.ps1
1 parent 16cf068 commit b915ce7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

build.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
npm ci
2+
npm run build
3+
4+
$build_dir="build"
5+
if(Test-Path $build_dir){
6+
Remove-Item -Force -Recurse $build_dir
7+
}
8+
New-Item -Name $build_dir -ItemType "directory"
9+
10+
$importpath="github.com/scutrobotlab/asuwave/helper"
11+
$gittag=$(git describe --tags --abbrev=0)
12+
$build_prefix="asuwave_"
13+
$os_list="linux", "darwin", "windows"
14+
$arch_list="amd64", "arm64"
15+
$flags="-w -s -X '${importpath}.GitTag=${gittag}' -X '${importpath}.GitHash=$(git describe --tags --long)' -X '${importpath}.BuildTime=$(Get-Date -Format 'yyyy-MM-dd HH:mm')' -X '${importpath}.GoVersion=$(go version)'"
16+
17+
foreach ($os in $os_list) {
18+
foreach ($arch in $arch_list) {
19+
$suffix=""
20+
if ($os -eq "windows") {
21+
if($arch -eq "arm64"){
22+
continue
23+
}else{
24+
$suffix=".exe"
25+
}
26+
}
27+
$file="${build_dir}\${build_prefix}${gittag}_${os}_${arch}"
28+
$out="${build_dir}\${build_prefix}${os}_${arch}${suffix}"
29+
$Env:CGO_ENABLED=0
30+
$Env:GOOS=${os}
31+
$Env:GOARCH=${arch}
32+
go build -tags release -ldflags="$flags" -o $out
33+
upx -q -9 $out
34+
Compress-Archive -CompressionLevel "Optimal" -Path $out -DestinationPath "${file}.zip"
35+
}
36+
}
37+

0 commit comments

Comments
 (0)