1
1
#! /usr/bin/env bash
2
+ if [ $1 = " test" ]; then
3
+ tag=" v0.0.0"
4
+ else
5
+ workingBranch=$( git rev-parse --abbrev-ref HEAD)
2
6
3
- workingBranch=$( git rev-parse --abbrev-ref HEAD)
7
+ cleanWorkspace=$( git diff --exit-code)
8
+ if [ $? -ne 0 ]; then
9
+ echo " git workspace is not clean, commit or stash your changes"
10
+ exit 1
11
+ fi
4
12
5
- cleanWorkspace=$( git diff --exit-code)
6
- if [ $? -ne 0 ]; then
7
- echo " git workspace is not clean, commit or stash your changes"
8
- exit 1
9
- fi
13
+ git fetch --tags
14
+ tag=$( git describe --tags ` git rev-list --tags --max-count=1` )
15
+ if [ -z ${tag} ]; then
16
+ echo " could not find latest tag"
17
+ exit 1
18
+ fi
10
19
11
- git fetch --tags
12
- tag=$( git describe --tags ` git rev-list --tags --max-count=1` )
13
- if [ -z $tag ]; then
14
- echo " could not find latest tag"
15
- exit 1
20
+ git checkout ${tag}
16
21
fi
17
22
18
- git checkout $tag
19
-
20
23
target_folder=" .release"
21
24
package=" github.com/Oppodelldog/git-commit-hook/cmd"
22
25
ldflags=-ldflags=" -X github.com/Oppodelldog/git-commit-hook/version.Number=${tag} "
23
26
24
27
package_split=(${package// \/ / } )
25
28
package_name=${package_split[-1]}
26
29
27
- platforms=(" linux/amd64" " windows/amd64" " windows/386" )
30
+ platforms=(" linux/amd64" " windows/amd64" " windows/386" " linux/arm/7 " )
28
31
29
32
for platform in " ${platforms[@]} "
30
33
do
31
34
platform_split=(${platform// \/ / } )
32
35
GOOS=${platform_split[0]}
33
36
GOARCH=${platform_split[1]}
34
- output_folder=" ${GOOS} -${GOARCH} "
35
- output_name=$package_name
36
- if [ $GOOS = " windows" ]; then
37
+ GOARM=
38
+
39
+ if [ ${GOARCH} = " arm" ]; then
40
+ GOARM=${platform_split[2]}
41
+
42
+ fi
43
+
44
+ output_folder=" ${GOOS} -${GOARCH}${GOARM} "
45
+ output_name=${package_name}
46
+ if [ ${GOOS} = " windows" ]; then
37
47
output_name+=' .exe'
38
48
fi
39
49
40
- env GOOS=$GOOS GOARCH=$GOARCH go build " ${ldflags} " -o " ${target_folder} /${tag} /${output_folder} /${output_name} " $package
50
+ env GOOS=${ GOOS} GOARCH=${ GOARCH} GOARM= ${GOARM} go build " ${ldflags} " -o " ${target_folder} /${tag} /${output_folder} /${output_name} " ${ package}
41
51
if [ $? -ne 0 ]; then
42
52
echo ' An error has occurred! Aborting the script execution...'
43
53
exit 1
49
59
50
60
tar -cvzf ../${output_name} -${output_folder} .tar.gz ${output_name}
51
61
52
- cd $currentWd
62
+ cd ${ currentWd}
53
63
rm -rf ${target_folder} /${tag} /${output_folder}
54
64
done
55
65
56
-
57
- git checkout ${workingBranch}
66
+ if [ $1 = " test" ]; then
67
+ echo " test release done"
68
+ else
69
+ git checkout ${workingBranch}
70
+ fi
0 commit comments