-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcross-compile.sh
executable file
·34 lines (29 loc) · 1.05 KB
/
cross-compile.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
30
31
32
33
34
#!/usr/bin/env bash
set -euxo pipefail
rm -rf ./bin
build_commands=('
apk add make curl git \
; GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o bin/linux-arm64/alvu \
; GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/linux-amd64/alvu \
; GOOS=linux GOARCH=arm go build -ldflags="-s -w" -o bin/linux-arm/alvu \
; GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o bin/windows-386/alvu \
; GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o bin/windows-amd64/alvu \
; GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o bin/darwin-amd64/alvu \
; GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o bin/darwin-arm64/alvu
')
# run a docker container with osxcross and cross compile everything
docker run -it --rm -v $(pwd):/usr/local/src -w /usr/local/src \
golang:alpine3.16 \
sh -c "$build_commands"
# create archives
cd bin
for dir in $(ls -d *);
do
cp ../readme.md $dir
cp ../license $dir
mkdir -p $dir/docs
cp -r ../docs/pages/* $dir/docs
tar cfzv "$dir".tgz $dir
rm -rf $dir
done
cd ..