distribution/version/version.sh
Cory Snider ab27c9d5f1 version: use go list -m
It appears that the value of Package is intended to be what is nowadays
called the module path, not the path to the version package. This also
fixes the issue of the version file being regenerated incorrectly under
shell redirection as the go list command no longer attempts to parse .go
files under the version package.

    $ ./version.sh > version.go
    version.go:1:1: expected 'package', found 'EOF'

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-12-19 13:00:22 -05:00

26 lines
945 B
Bash
Executable file

#!/bin/sh
# This bash script outputs the current, desired content of version.go, using
# git describe. For best effect, pipe this to the target file. Generally, this
# only needs to updated for releases. The actual value of will be replaced
# during build time if the makefile is used.
set -e
cat <<EOF
package version
// Package is the overall, canonical project import path under which the
// package was built.
var Package = "$(go list -m)"
// Version indicates which version of the binary is running. This is set to
// the latest release tag by hand, always suffixed by "+unknown". During
// build, it will be replaced by the actual version. The value here will be
// used if the registry is run after a go get based install.
var Version = "$(git describe --match 'v[0-9]*' --dirty='.m' --always)+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time.
var Revision = ""
EOF