From 53f4d0c2f0b6aeb33dd377674759bec6a989812b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harry=20M=C3=ADchal?= Date: Tue, 7 Apr 2020 20:01:41 +0200 Subject: [PATCH] Add versioning infrastructure in Go https://github.com/containers/toolbox/pull/318 --- meson.build | 2 +- src/meson.build | 1 + src/pkg/version/version.go | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/pkg/version/version.go diff --git a/meson.build b/meson.build index ac5b1f4..fbefc86 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'toolbox', - version: '0.0.18', + version: '0.0.90', license: 'ASL 2.0', meson_version: '>= 0.40.0', ) diff --git a/src/meson.build b/src/meson.build index 46b729f..b97eb06 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,6 +4,7 @@ go_build_wrapper_program = find_program('go-build-wrapper') sources = files( 'toolbox.go', 'cmd/root.go', + 'pkg/version/version.go', ) if go.found() diff --git a/src/pkg/version/version.go b/src/pkg/version/version.go new file mode 100644 index 0000000..13c4449 --- /dev/null +++ b/src/pkg/version/version.go @@ -0,0 +1,38 @@ +/* + * Copyright © 2019 – 2020 Red Hat Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package version + +import "fmt" + +// Version is the version of Toolbox +type Version struct { + Major int + Minor int + Micro int +} + +// CurrentVersion holds the information about current build version +var CurrentVersion = Version{ + Major: 0, + Minor: 0, + Micro: 90, +} + +// GetVersion returns string with the version of Toolbox +func GetVersion() string { + return fmt.Sprintf("%d.%d.%d", CurrentVersion.Major, CurrentVersion.Minor, CurrentVersion.Micro) +}