-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·37 lines (35 loc) · 955 Bytes
/
make.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
35
36
37
#!/bin/bash
VERSION=$(git describe --tags)
echo $VERSION
THIS_GOOS=$(go env GOOS)
THIS_GOARCH=$(go env GOARCH)
RELEASE_DIR="release"
ARTIFACT_DIR="artifact"
RELEASE_TARGET=("linux/arm" "linux/arm64" "linux/amd64" "windows/amd64" "darwin/amd64" "darwin/arm64")
# remove old artifacts
rm -rf $ARTIFACT_DIR
for t in ${RELEASE_TARGET[@]}
do
DIST=$RELEASE_DIR"/"$t"/mcpick_"$VERSION
tmp=(${t//// })
GOOS=${tmp[0]}
GOARCH=${tmp[1]}
SUFFIX=""
if [ $GOOS = "windows" ]
then
SUFFIX=".exe"
fi
DIST_BIN=$DIST"/mcpick"$SUFFIX
go build -o $DIST_BIN -ldflags "-X main.version=$VERSION"
cp LICENSE README.md $DIST
mkdir -p $ARTIFACT_DIR 2>/dev/null
if [ $GOOS = "linux" ]
then
tar cfvz $ARTIFACT_DIR"/mcpick_"$GOOS"_"$GOARCH".tar.gz" $DIST
else
zip -r $ARTIFACT_DIR"/mcpick_"$GOOS"_"$GOARCH".zip" $DIST
fi
done
GOOS=THIS_GOOS
GOARCH=THIS_GOARCH
rm -rf $RELEASE_DIR