-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·49 lines (40 loc) · 1.03 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1.03 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
if [[ ! $GITHUB_REF =~ ^"refs/tags/v" ]]
then
echo >&2 "This is not commit tagged for release."
exit 0
fi
VERSION=${GITHUB_REF#refs/tags/v}
echo "Version $VERSION"
echo "Running tests..."
go test ./...
if [ $? -ne 0 ]; then
echo >&2 "Tests failed"
exit 1
fi
echo "Tests passed"
function build() {
echo "Building $1"
goos=${1%/*}
goarch=${1#*/}
mkdir -p bin
CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch go build \
-o bin/reg-$goos-$goarch \
--ldflags '-extldflags "-static"' \
--ldflags="-X 'github.com/burgrp/reg/cmd.Version=$VERSION'" \
main.go
}
rm -rf bin
# osarchs=$(go tool dist list | grep -E "^(linux|darwin|windows)\\/")
osarchs="darwin/amd64 darwin/arm64 linux/amd64 linux/arm linux/arm64 windows/amd64 windows/arm windows/arm64"
for osarch in $osarchs
do
build $osarch
done
go install github.com/tcnksm/ghr@latest
if [ $DRY_RUN ]
then
echo "Dry run, not publishing."
exit 0
fi
~/go/bin/ghr -u ${GITHUB_REPOSITORY%/*} -r ${GITHUB_REPOSITORY#*/} v${VERSION} bin