11#! /usr/bin/env bash
2+ if [ $1 = " test" ]; then
3+ tag=" v0.0.0"
4+ else
5+ workingBranch=$( git rev-parse --abbrev-ref HEAD)
26
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
412
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
1019
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}
1621fi
1722
18- git checkout $tag
19-
2023target_folder=" .release"
2124package=" github.com/Oppodelldog/git-commit-hook/cmd"
2225ldflags=-ldflags=" -X github.com/Oppodelldog/git-commit-hook/version.Number=${tag} "
2326
2427package_split=(${package// \/ / } )
2528package_name=${package_split[-1]}
2629
27- platforms=(" linux/amd64" " windows/amd64" " windows/386" )
30+ platforms=(" linux/amd64" " windows/amd64" " windows/386" " linux/arm/7 " )
2831
2932for platform in " ${platforms[@]} "
3033do
3134 platform_split=(${platform// \/ / } )
3235 GOOS=${platform_split[0]}
3336 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
3747 output_name+=' .exe'
3848 fi
3949
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}
4151 if [ $? -ne 0 ]; then
4252 echo ' An error has occurred! Aborting the script execution...'
4353 exit 1
4959
5060 tar -cvzf ../${output_name} -${output_folder} .tar.gz ${output_name}
5161
52- cd $currentWd
62+ cd ${ currentWd}
5363 rm -rf ${target_folder} /${tag} /${output_folder}
5464done
5565
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