diff --git a/script/.build b/script/.build new file mode 100644 index 00000000..bd647b6b --- /dev/null +++ b/script/.build @@ -0,0 +1,5 @@ +#!/bin/bash + +GITCOMMIT=$(git rev-parse --short HEAD) + +BUILD_FLAGS=(-tags experimental -ldflags="-w -X github.com/skippbox/kompose/version.GITCOMMIT=${GITCOMMIT}") diff --git a/script/binary b/script/binary index 017b8915..ee1c21a3 100755 --- a/script/binary +++ b/script/binary @@ -1,14 +1,17 @@ #!/bin/bash set -e +source "$(dirname "$BASH_SOURCE")/.build" + +OUT_FILE="./kompose" + # Get rid of existing binary -rm -f kompose +rm -f $OUT_FILE # Build binary go build \ - -tags experimental \ - -o kompose \ - -ldflags="-w -X github.com/skippbox/kompose/version.GITCOMMIT=${GITCOMMIT}" \ + "${BUILD_FLAGS[@]}" \ + -o $OUT_FILE \ ./cli/main if [ $? -eq 0 ]; then diff --git a/script/binary-cross b/script/binary-cross index 9fabf1af..ee3d11ae 100644 --- a/script/binary-cross +++ b/script/binary-cross @@ -1,6 +1,8 @@ #!/bin/bash set -e +source "$(dirname "$BASH_SOURCE")/.build" + if [ -z "$1" ]; then OS_PLATFORM_ARG=(-os="darwin linux windows") else @@ -21,6 +23,5 @@ rm -f kompose* # Build binaries gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \ -output="bundles/kompose_{{.OS}}-{{.Arch}}/kompose" \ - -tags experimental \ - -ldflags="-w -X github.com/skippbox/kompose/version.GITCOMMIT=${GITCOMMIT}" \ + "${BUILD_FLAGS[@]}" \ ./cli/main diff --git a/script/test-unit b/script/test-unit index 8189ce30..3b4269ef 100755 --- a/script/test-unit +++ b/script/test-unit @@ -1,6 +1,8 @@ #!/bin/bash set -e +source "$(dirname "$BASH_SOURCE")/.build" + find_dirs() { ( find . -not \( \ @@ -11,7 +13,7 @@ find_dirs() { ) } -TEST_FLAGS="-tags experimental -cover -coverprofile=cover.out" +TEST_FLAGS=("${BUILD_FLAGS[@]}" -cover -coverprofile=cover.out) if [ -z "$TEST_DIRS" ]; then TEST_DIRS=$(find_dirs '*_test.go') @@ -19,7 +21,6 @@ fi TESTS_FAILED=() -set +e for dir in $TEST_DIRS; do - go test ${TEST_FLAGS} "./${dir}" + go test "${TEST_FLAGS[@]}" "./${dir}" done