forked from github/multus-cni
This changes introduce goreleaser, which does cross-compile and package, as well as add version into go code. This change also changes .travis.yml to allow to other users' forked repo.
32 lines
814 B
Bash
Executable File
32 lines
814 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
ORG_PATH="github.com/intel"
|
|
REPO_PATH="${ORG_PATH}/multus-cni"
|
|
|
|
# Add version/commit/date into binary
|
|
# In case of TravisCI, need to check error code of 'git describe'.
|
|
set +e
|
|
git describe --tags --abbrev=0 > /dev/null 2>&1
|
|
if [ "$?" != "0" ]; then
|
|
VERSION="master"
|
|
else
|
|
VERSION=$(git describe --tags --abbrev=0)
|
|
fi
|
|
set -e
|
|
DATE=$(date --iso-8601=seconds)
|
|
COMMIT=$(git rev-parse --verify HEAD)
|
|
LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}"
|
|
|
|
if [ ! -h gopath/src/${REPO_PATH} ]; then
|
|
mkdir -p gopath/src/${ORG_PATH}
|
|
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
|
|
fi
|
|
|
|
export GO15VENDOREXPERIMENT=1
|
|
export GOBIN=${PWD}/bin
|
|
export GOPATH=${PWD}/gopath
|
|
|
|
echo "Building plugins"
|
|
go install -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/multus
|