Skip to content

Commit

Permalink
Merge pull request #59 from flant/new_build_script
Browse files Browse the repository at this point in the history
CI: new scripts/build-release-binaries.sh scripts
  • Loading branch information
distorhead authored Mar 11, 2019
2 parents 38f825e + cf7041f commit f527ba7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release/build
release-build
27 changes: 0 additions & 27 deletions release/build.sh

This file was deleted.

17 changes: 17 additions & 0 deletions scripts/build-release-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

for f in $(find scripts/lib -type f -name "*.sh"); do
source $f
done

VERSION=$1
if [ -z "$VERSION" ] ; then
echo "Required version argument!" 1>&2
echo 1>&2
echo "Usage: $0 VERSION" 1>&2
exit 1
fi

build_binaries $VERSION
47 changes: 47 additions & 0 deletions scripts/lib/release/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export RELEASE_BUILD_DIR=release-build

go_get() {
for os in linux darwin windows ; do
for arch in amd64 ; do
export GOOS=$os
export GOARCH=$arch
source $GOPATH/src/github.com/flant/kubedog/go-get.sh
done
done
}

go_build() {
VERSION=$1

rm -rf $RELEASE_BUILD_DIR/$VERSION
mkdir -p $RELEASE_BUILD_DIR/$VERSION
chmod -R 0777 $RELEASE_BUILD_DIR/$VERSION

for os in linux darwin windows ; do
for arch in amd64 ; do
outputFile=$RELEASE_BUILD_DIR/$VERSION/kubedog-$os-$arch-$VERSION
if [ "$os" == "windows" ] ; then
outputFile=$outputFile.exe
fi

echo "# Building kubedog $VERSION for $os $arch ..."

GOOS=$os GOARCH=$arch \
go build -ldflags="-s -w -X github.com/flant/kubedog/pkg/kubedog.Version=$VERSION" \
-o $outputFile github.com/flant/kubedog/cmd/kubedog

echo "# Built $outputFile"
done
done

cd $RELEASE_BUILD_DIR/$VERSION/
sha256sum kubedog-* > SHA256SUMS
cd -
}

build_binaries() {
VERSION=$1

( go_get ) || ( exit 1 )
( go_build $VERSION ) || ( exit 1 )
}

0 comments on commit f527ba7

Please sign in to comment.