Skip to content

Commit 3924279

Browse files
committed
Add automation for releasing the project
1 parent d17e684 commit 3924279

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

.ci/scripts/build.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
function git_branch_name() {
4+
echo $(git symbolic-ref --short HEAD)
5+
}
6+
7+
readonly BINARY="swcg"
8+
readonly BRANCH="${TRAVIS_BRANCH:-$(git_branch_name)}"
9+
readonly GO_VERSION="1.12"
10+
readonly GO_WORKSPACE="/usr/local/go/src/github.com/mdelapenya/lpn"
11+
readonly VERSION="$(cat ./VERSION.txt)"
12+
13+
if [[ "$BRANCH" != "master" ]]; then
14+
echo "It's not possible to build from a branch different to master"
15+
exit 1
16+
fi
17+
18+
for GOOS in darwin linux windows; do
19+
goos="${GOOS}"
20+
extension=""
21+
22+
if [[ "$GOOS" == "windows" ]]; then
23+
goos="win"
24+
extension=".exe"
25+
fi
26+
27+
for GOARCH in 386 amd64; do
28+
arch="${GOARCH}"
29+
30+
if [[ "$GOARCH" == "amd64" ]]; then
31+
arch="64"
32+
fi
33+
34+
echo ">>> Building for ${GOOS}/${GOARCH}"
35+
docker run --rm -v "$(pwd)":${GO_WORKSPACE} -w ${GO_WORKSPACE} \
36+
-e GOOS=${GOOS} -e GOARCH=${GOARCH} golang:${GO_VERSION} \
37+
go build -v -o ${GO_WORKSPACE}/.github/releases/download/${VERSION}/${goos}${arch}-${BINARY}${extension}
38+
done
39+
done

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github

VERSION.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

0 commit comments

Comments
 (0)