Skip to content

Commit

Permalink
Update build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhou26 authored Apr 7, 2024
1 parent c685ce7 commit 53e0ef5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ upxPath=$(command -v upx)
for target in "${targets[@]}"; do
GOOS=${target%/*}
GOARCH=${target#*/}
output="bin/${GOOS}_${GOARCH}/${PKG}"
mkdir -p $(dirname ${output})
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w -extldflags '-static'" -o ${output} *.go
outputDir="bin/${GOOS}_${GOARCH}"
outputFile="${outputDir}/${PKG}"
archiveName="${PKG}-${GOOS}-${GOARCH}.tar.gz"
mkdir -p $(dirname ${outputFile})
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w -extldflags '-static'" -o ${outputFile} *.go
if [ -n "$upxPath" ]; then
$upxPath -9 ${output}
$upxPath -9 ${outputFile}
fi
done
# Archive the binary
if [ "$GOOS" = "windows" ]; then
zip -j "${outputDir}/${PKG}-${GOOS}-${GOARCH}.zip" "${outputFile}"
else
tar -C "${outputDir}" -czf "${outputDir}/${archiveName}" "${PKG}"
fi
done

0 comments on commit 53e0ef5

Please sign in to comment.