opentofu/cmd/tofu/version.go

15 lines
289 B
Go
Raw Normal View History

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
2014-05-24 14:04:43 -05:00
package main
import (
"github.com/opentofu/opentofu/version"
)
var Version = version.Version
core: Use environment variables to set VersionPrerelease at compile time Instead of using a hardcoded version prerelease string, which makes release automation difficult, set the version prerelease string from an environment variable via the go linker tool during compile time. The environment variable `TF_RELEASE` should only be set via the `make bin` target, and thus leaves the version prerelease string unset. Otherwise, when running a local compile of terraform via the `make dev` makefile target, the version prerelease string is set to `"dev"`, as usual. This also requires some changes to both the circonus and postgresql providers, as they directly used the `VersionPrerelease` constant. We now simply call the `VersionString()` function, which returns the proper interpolated version string with the prerelease string populated correctly. `TF_RELEASE` is unset: ```sh $ make dev ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/05/22 10:38:19 Generated command/internal_plugin_list.go ==> Removing old directory... ==> Building... Number of parallel builds: 3 --> linux/amd64: github.com/hashicorp/terraform ==> Results: total 209M -rwxr-xr-x 1 jake jake 209M May 22 10:39 terraform $ terraform version Terraform v0.9.6-dev (fd472e4a86500606b03c314f70d11f2bc4bc84e5+CHANGES) ``` `TF_RELEASE` is set (mimicking the `make bin` target): ```sh $ TF_RELEASE=1 make dev ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/05/22 10:40:39 Generated command/internal_plugin_list.go ==> Removing old directory... ==> Building... Number of parallel builds: 3 --> linux/amd64: github.com/hashicorp/terraform ==> Results: total 121M -rwxr-xr-x 1 jake jake 121M May 22 10:42 terraform $ terraform version Terraform v0.9.6 ```
2017-05-22 09:49:15 -05:00
var VersionPrerelease = version.Prerelease