Skip to content

Commit b962075

Browse files
committed
refactor(build): extract build variables
1 parent a5746f2 commit b962075

File tree

6 files changed

+55
-55
lines changed

6 files changed

+55
-55
lines changed

build/build-all-by-docker.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
cd $(dirname "$0")
4+
5+
# init variable `builds`
6+
source ./build-all.inc.sh
7+
8+
prefix=$(realpath ../)
9+
rm -rf "$prefix/output/"
10+
11+
buildByDocker() {
12+
gover="$1"
13+
shift
14+
docker pull golang:"$gover"
15+
16+
docker run \
17+
--rm \
18+
-v "$prefix":/mnt \
19+
-e EX_UID="$(id -u)" \
20+
-e EX_GID="$(id -g)" \
21+
golang:"$gover" \
22+
/bin/bash -c '
23+
sed -i -e "s;://[^/ ]*;://mirrors.aliyun.com;" /etc/apt/sources.list;
24+
apt-get update;
25+
apt-get install -yq git zip;
26+
/bin/bash /mnt/build/build.sh "$@";
27+
chown -R $EX_UID:$EX_GID /mnt/output;
28+
' \
29+
'argv_0_placeholder' \
30+
"$@"
31+
}
32+
33+
gover=latest
34+
buildByDocker "$gover" "${builds[@]}"
35+
36+
#gover=1.16
37+
#builds=('darwin amd64 -10.12-sierra')
38+
#buildByDocker "$gover" "${builds[@]}"

build/build-all-docker.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

build/build-all.inc.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
builds=('linux 386' 'linux amd64' 'linux arm' 'linux arm64' 'linux riscv64' 'windows 386' 'windows amd64' 'windows arm' 'windows arm64' 'darwin amd64' 'darwin arm64')
2+
builds=("${builds[@]}" 'freebsd 386' 'freebsd amd64' 'freebsd arm' 'freebsd arm64')
3+
builds=("${builds[@]}" 'openbsd 386' 'openbsd amd64' 'openbsd arm' 'openbsd arm64')
4+
builds=("${builds[@]}" 'netbsd 386' 'netbsd amd64' 'netbsd arm' 'netbsd arm64')
5+
builds=("${builds[@]}" 'dragonfly amd64')
6+
builds=("${builds[@]}" 'plan9 386' 'plan9 amd64' 'plan9 arm')

build/build-all.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
cd $(dirname "$0")
44
rm -rf ../output/
55

6-
builds=('linux 386' 'linux amd64' 'linux arm' 'linux arm64' 'linux riscv64' 'windows 386' 'windows amd64' 'windows arm' 'windows arm64' 'darwin amd64' 'darwin arm64')
7-
builds=("${builds[@]}" 'freebsd 386' 'freebsd amd64' 'freebsd arm' 'freebsd arm64')
8-
builds=("${builds[@]}" 'openbsd 386' 'openbsd amd64' 'openbsd arm' 'openbsd arm64')
9-
builds=("${builds[@]}" 'netbsd 386' 'netbsd amd64' 'netbsd arm' 'netbsd arm64')
10-
builds=("${builds[@]}" 'dragonfly amd64')
11-
builds=("${builds[@]}" 'plan9 386' 'plan9 amd64' 'plan9 arm')
6+
# init variable `builds`
7+
source ./build-all.inc.sh
8+
129
bash ./build.sh "${builds[@]}"

build/build.inc.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
TMP='/tmp'
2+
OUTDIR='../output'
3+
MAINNAME='ghfs'
4+
MOD=$(go list ../src/)
5+
VERSION=$(git describe --abbrev=0 --tags 2> /dev/null || git rev-parse --abbrev-ref HEAD 2> /dev/null)
6+
LDFLAGS="-s -w -X $MOD/version.appVer=$VERSION"
7+
LICENSE='../LICENSE'

build/build.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33
cd $(dirname "$0")
44

55
export GO111MODULE=auto
6-
7-
TMP='/tmp'
8-
OUTDIR='../output'
9-
MAINNAME='ghfs'
10-
MOD=$(go list ../src/)
11-
VERSION=$(git describe --abbrev=0 --tags 2> /dev/null || git rev-parse --abbrev-ref HEAD 2> /dev/null)
12-
LDFLAGS="-s -w -X $MOD/version.appVer=$VERSION"
13-
LICENSE='../LICENSE'
6+
source ./build.inc.sh
147

158
mkdir -p "$OUTDIR"
169

0 commit comments

Comments
 (0)