Skip to content

Commit e06b5cb

Browse files
author
Oppodelldog
committed
introducing make recipe to test the build without git actions
added arm7 to build list :D
1 parent 061b82c commit e06b5cb

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

.release/build.sh

+34-21
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,53 @@
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}
1621
fi
1722

18-
git checkout $tag
19-
2023
target_folder=".release"
2124
package="github.com/Oppodelldog/git-commit-hook/cmd"
2225
ldflags=-ldflags="-X github.com/Oppodelldog/git-commit-hook/version.Number=${tag}"
2326

2427
package_split=(${package//\// })
2528
package_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

2932
for platform in "${platforms[@]}"
3033
do
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
@@ -49,9 +59,12 @@ do
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}
5464
done
5565

56-
57-
git checkout ${workingBranch}
66+
if [ $1 = "test" ]; then
67+
echo "test release done"
68+
else
69+
git checkout ${workingBranch}
70+
fi

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ install: ## Install to <gopath>/src
5555
build-release: ## builds the checked out version into the .release/${tag} folder
5656
.release/build.sh
5757

58+
build-release-test: ## builds the checked out version into the .release/${tag} folder
59+
.release/build.sh test
60+
5861
# Self-Documented Makefile see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
5962
help:
6063
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)