Skip to content

Commit 9600267

Browse files
committed
ci: add linux-musl-amd64/arm64 to dev build
1 parent a66b0e0 commit 9600267

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

build.sh

+21-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,30 @@ BuildWinArm64() {
5454

5555
BuildDev() {
5656
rm -rf .git/
57-
xgo -targets=linux/amd64,windows/amd64,darwin/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
5857
mkdir -p "dist"
58+
muslflags="--extldflags '-static -fpic' $ldflags"
59+
BASE="https://musl.nn.ci/"
60+
FILES=(x86_64-linux-musl-cross aarch64-linux-musl-cross)
61+
for i in "${FILES[@]}"; do
62+
url="${BASE}${i}.tgz"
63+
curl -L -o "${i}.tgz" "${url}"
64+
sudo tar xf "${i}.tgz" --strip-components 1 -C /usr/local
65+
done
66+
OS_ARCHES=(linux-musl-amd64 linux-musl-arm64)
67+
CGO_ARGS=(x86_64-linux-musl-gcc aarch64-linux-musl-gcc)
68+
for i in "${!OS_ARCHES[@]}"; do
69+
os_arch=${OS_ARCHES[$i]}
70+
cgo_cc=${CGO_ARGS[$i]}
71+
echo building for ${os_arch}
72+
export GOOS=${os_arch%%-*}
73+
export GOARCH=${os_arch##*-}
74+
export CC=${cgo_cc}
75+
export CGO_ENABLED=1
76+
go build -o ./dist/$appName-$os_arch -ldflags="$muslflags" -tags=jsoniter .
77+
done
78+
xgo -targets=windows/amd64,darwin/amd64 -out "$appName" -ldflags="$ldflags" -tags=jsoniter .
5979
mv alist-* dist
6080
cd dist
61-
upx -9 ./alist-linux*
6281
cp ./alist-windows-amd64.exe ./alist-windows-amd64-upx.exe
6382
upx -9 ./alist-windows-amd64-upx.exe
6483
find . -type f -print0 | xargs -0 md5sum >md5.txt

0 commit comments

Comments
 (0)