-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild.sh
executable file
·29 lines (29 loc) · 1.11 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
version="1.5.5"
sourceVer=$(git log --date=iso --pretty=format:"%h %cd" -1)
buildTime="$(date '+%Y-%m-%d %H:%M:%S') by $(go version|sed 's/go version //')"
cat <<EOF | gofmt >common/version.go
package common
var (
version = "$version"
sourceVer = "$sourceVer"
buildTime = "$buildTime"
)
EOF
# tags 支持linux、windows、macos
echo build for Linux-amd64...
GOOS=linux GOARCH=amd64 go build -tags "linux" -ldflags "-w -s" -o m4s-converter-linux_amd64 main.go
#
echo build for windows-amd64...
GOOS=windows GOARCH=amd64 go build -tags "windows" -ldflags "-w -s" -o m4s-converter-amd64.exe
#
#echo build for Linux-arm64...
#GOOS=linux GOARCH=arm64 GOARM=7 go build -tags "linux" -ldflags "-w -s" -o m4s-converter-linux_arm64 main.go
# 设置目标操作系统为darwin(MacOS)
echo build for darwin-amd64...
GOOS=darwin GOARCH=amd64 go build -tags "darwin" -ldflags "-w -s" -o m4s-converter-darwin_amd64 main.go
#
echo build for darwin-arm64...
GOOS=darwin GOARCH=arm64 go build -tags "darwin" -ldflags "-w -s" -o m4s-converter-darwin_arm64 main.go
# 压缩
upx --lzma m4s-converter-amd64.exe m4s-converter-linux_amd64