forked from AlistGo/alist
-
Notifications
You must be signed in to change notification settings - Fork 2
/
1.sh
executable file
·30 lines (26 loc) · 2.02 KB
/
1.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
export PATH=$PATH:/home/q1/go7/go/bin
#export PATH=$PATH:/usr/local/go/bin
appName="alist"
builtAt="$(date +'%F %T %z')"
goVersion=$(go version | sed 's/go version //')
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
gitCommit=$(git log --pretty=format:"%h" -1)
version=$(git describe --long --tags --dirty --always)
webVersion=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
ldflags="\
-w -s \
-X 'github.com/alist-org/alist/v3/internal/conf.BuiltAt=$builtAt' \
-X 'github.com/alist-org/alist/v3/internal/conf.GoVersion=$goVersion' \
-X 'github.com/alist-org/alist/v3/internal/conf.GitAuthor=$gitAuthor' \
-X 'github.com/alist-org/alist/v3/internal/conf.GitCommit=$gitCommit' \
-X 'github.com/alist-org/alist/v3/internal/conf.Version=$version' \
-X 'github.com/alist-org/alist/v3/internal/conf.WebVersion=$webVersion' \
"
# 设置目标平台为Windows
#GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=/usr/bin/i686-w64-mingw32-gcc go build -ldflags="$ldflags" -o "$appName.exe" .
#CC=/home/q1/123/armv7l-linux-musleabihf-cross/bin/armv7l-linux-musleabihf-gcc GOOS="linux" GOARCH="arm" CGO_ENABLED="1" GOARM="7" CGO_CFLAGS="-static" CGO_LDFLAGS="-static" go build -ldflags "$ldflags -extldflags '-static'" -o "alist-armv7l" .
#CC=/home/q1/下载/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" CGO_CFLAGS="-static" CGO_LDFLAGS="-static" go build -ldflags "$ldflags -extldflags '-static'" -o "$(date +%Y%m%d_%H%M%S)-alist-x64" .
#CC=/home/q1/下载/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc GOOS="linux" GOARCH="arm64" CGO_ENABLED="1" go build -ldflags="--extldflags '-static -fpic' $ldflags" -tags=jsoniter -o "alist-arm64" .
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=/usr/bin/x86_64-w64-mingw32-gcc go build -ldflags="$ldflags" -o "64-$(date +%Y%m%d_%H%M%S)-$appName.exe" .
#GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -ldflags="$ldflags" -o "64-$appName.exe" .