mirror of https://github.com/knative/client.git
fix(build.sh): Reintroduced build-flags.sh (#122)
so that it can be shared between build.sh and release.sh Fixes #120
This commit is contained in:
parent
bbfc9fbaa3
commit
e0f4f51e67
|
@ -0,0 +1,14 @@
|
|||
function build_flags() {
|
||||
local now="$(date -u '+%Y-%m-%d %H:%M:%S')"
|
||||
local rev="$(git rev-parse --short HEAD)"
|
||||
local pkg="github.com/knative/client/pkg/kn/commands"
|
||||
local version="${TAG:-}"
|
||||
# Use vYYYYMMDD-local-<hash> for the version string, if not passed.
|
||||
if [[ -z "${version}" ]]; then
|
||||
# Get the commit, excluding any tags but keeping the "dirty" flag
|
||||
local commit="$(git describe --always --dirty --match '^$')"
|
||||
[[ -n "${commit}" ]] || abort "error getting the current commit"
|
||||
version="v$(date +%Y%m%d)-local-${commit}"
|
||||
fi
|
||||
echo "-X '${pkg}.BuildDate=${now}' -X ${pkg}.Version=${version} -X ${pkg}.GitRevision=${rev}"
|
||||
}
|
|
@ -19,16 +19,15 @@ set -eu
|
|||
|
||||
dir=$(dirname "${BASH_SOURCE[0]}")
|
||||
base=$(cd "$dir/.." && pwd)
|
||||
source ${base}/hack/util/flags.sh
|
||||
source ${base}/hack/build-flags.sh
|
||||
|
||||
export GO111MODULE=on
|
||||
|
||||
echo "📋 Formatting"
|
||||
go fmt ${base}/cmd/... ${base}/pkg/...
|
||||
echo "🚧 Building"
|
||||
go build -mod=vendor -ldflags "$(ld_flags ${base}/hack)" -o ${base}/kn ${base}/cmd/...
|
||||
go build -mod=vendor -ldflags "$(build_flags)" -o ${base}/kn ${base}/cmd/...
|
||||
echo "🌞 Success"
|
||||
|
||||
${base}/hack/generate-docs.sh
|
||||
|
||||
${base}/kn version
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
# limitations under the License.
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/release.sh
|
||||
source $(dirname $0)/build-flags.sh
|
||||
|
||||
function build_release() {
|
||||
local ld_flags="$(build_flags)"
|
||||
local pkg="github.com/knative/client/pkg/kn/commands"
|
||||
local version="${TAG}"
|
||||
# Use vYYYYMMDD-<hash>-local for the version string, if not passed.
|
||||
[[ -z "${version}" ]] && version="v${BUILD_TAG}-local"
|
||||
local ld_flags="-X '${pkg}.BuildDate=${BUILD_TIMESTAMP}' -X ${pkg}.Version=${version} -X ${pkg}.GitRevision=${BUILD_COMMIT_HASH}"
|
||||
|
||||
export GO111MODULE=on
|
||||
export CGO_ENABLED=0
|
||||
|
|
Loading…
Reference in New Issue