Skip to content

Commit 8e5c005

Browse files
committed
Add release script
1 parent 80b991c commit 8e5c005

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2ray-plugin
1+
v2ray-plugin*

Diff for: build-release.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
sum="sha1sum"
3+
4+
if ! hash sha1sum 2>/dev/null; then
5+
if ! hash shasum 2>/dev/null; then
6+
echo "I can't see 'sha1sum' or 'shasum'"
7+
echo "Please install one of them!"
8+
exit
9+
fi
10+
sum="shasum"
11+
fi
12+
13+
UPX=false
14+
if hash upx 2>/dev/null; then
15+
UPX=true
16+
fi
17+
18+
VERSION=`date -u +%Y%m%d`
19+
LDFLAGS="-X main.VERSION=$VERSION -s -w"
20+
GCFLAGS=""
21+
22+
OSES=(linux darwin windows freebsd)
23+
ARCHS=(amd64 386)
24+
25+
# Get go
26+
go get -u v2ray.com/core/...
27+
go get -u v2ray.com/ext/...
28+
29+
for os in ${OSES[@]}; do
30+
for arch in ${ARCHS[@]}; do
31+
suffix=""
32+
if [ "$os" == "windows" ]
33+
then
34+
suffix=".exe"
35+
fi
36+
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o v2ray-plugin_${os}_${arch}${suffix}
37+
if $UPX; then upx -9 v2ray-plugin_${os}_${arch}${suffix};fi
38+
tar -zcf v2ray-plugin-${os}-${arch}-$VERSION.tar.gz v2ray-plugin_${os}_${arch}${suffix}
39+
$sum v2ray-plugin-${os}-${arch}-$VERSION.tar.gz
40+
done
41+
done
42+
43+
# ARM
44+
ARMS=(5 6 7)
45+
for v in ${ARMS[@]}; do
46+
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=$v go build -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o v2ray-plugin_linux_arm$v
47+
done
48+
if $UPX; then upx -9 v2ray-plugin_linux_arm*;fi
49+
tar -zcf v2ray-plugin-linux-arm-$VERSION.tar.gz v2ray-plugin_linux_arm*
50+
$sum v2ray-plugin-linux-arm-$VERSION.tar.gz

0 commit comments

Comments
 (0)