Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change display versions #1601

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions hack/build-flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function build_flags() {
rev="$(git rev-parse --short HEAD)"
local pkg="knative.dev/client/pkg/kn/commands/version"
local version="${TAG:-}"
local major_minor="$(echo "${version}" | cut -f1-2 -d. -n)"
# 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
Expand All @@ -27,13 +28,21 @@ function build_flags() {
[[ -n "${commit}" ]] || abort "error getting the current commit"
version="v$(date +%Y%m%d)-local-${commit}"
fi
# Extract Eventing and Serving versions from go.mod
local version_serving version_eventing
version_serving=$(grep "knative.dev/serving " "${base}/go.mod" \
# For Eventing and Serving versionings,
# major and minor versions are the same as client version
# patch version is from each technical version
technical_version_serving=$(grep "knative.dev/serving " "${base}/go.mod" \
| sed -s 's/.* \(v.[\.0-9]*\).*/\1/')
version_eventing=$(grep "knative.dev/eventing " "${base}/go.mod" \
technical_version_eventing=$(grep "knative.dev/eventing " "${base}/go.mod" \
| sed -s 's/.* \(v.[\.0-9]*\).*/\1/')

local version_serving version_eventing
if [[ -n "${major_minor}" ]]; then
version_serving=${major_minor}.$(echo ${technical_version_serving} |cut -f3 -d.)
version_eventing=${major_minor}.$(echo ${technical_version_eventing} |cut -f3 -d.)
else
version_serving="${technical_version_serving}"
version_eventing="${technical_version_eventing}"
fi
echo "-X '${pkg}.BuildDate=${now}' \
-X ${pkg}.Version=${version} \
-X ${pkg}.GitRevision=${rev} \
Expand Down