Cleanup and extend basic build date
Signed-off-by: Mark Anderson <manderson@hashicorp.com>
This commit is contained in:
parent
846298ddf7
commit
84d669702c
|
@ -25,7 +25,7 @@ jobs:
|
||||||
id: get-product-version
|
id: get-product-version
|
||||||
run: |
|
run: |
|
||||||
CONSUL_VERSION=$(build-support/scripts/version.sh -r)
|
CONSUL_VERSION=$(build-support/scripts/version.sh -r)
|
||||||
CONSUL_DATE=$(build-support/scripts/build-date.sh -r)
|
CONSUL_DATE=$(build-support/scripts/build-date.sh)
|
||||||
## TODO: This assumes `make version` outputs 1.1.1+ent-prerel
|
## TODO: This assumes `make version` outputs 1.1.1+ent-prerel
|
||||||
IFS="+" read VERSION _other <<< "$CONSUL_VERSION"
|
IFS="+" read VERSION _other <<< "$CONSUL_VERSION"
|
||||||
IFS="-" read _other PREREL_VERSION <<< "$CONSUL_VERSION"
|
IFS="-" read _other PREREL_VERSION <<< "$CONSUL_VERSION"
|
||||||
|
@ -100,9 +100,11 @@ jobs:
|
||||||
- name: Build UI
|
- name: Build UI
|
||||||
run: |
|
run: |
|
||||||
CONSUL_VERSION=${{ needs.get-product-version.outputs.product-version }}
|
CONSUL_VERSION=${{ needs.get-product-version.outputs.product-version }}
|
||||||
|
CONSUL_DATE=${{ needs.get-product-version.outputs.product-date }}
|
||||||
CONSUL_BINARY_TYPE=${CONSUL_BINARY_TYPE}
|
CONSUL_BINARY_TYPE=${CONSUL_BINARY_TYPE}
|
||||||
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
|
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
|
||||||
echo "consul_version is ${CONSUL_VERSION}"
|
echo "consul_version is ${CONSUL_VERSION}"
|
||||||
|
echo "consul_date is ${CONSUL_DATE}"
|
||||||
echo "consul binary type is ${CONSUL_BINARY_TYPE}"
|
echo "consul binary type is ${CONSUL_BINARY_TYPE}"
|
||||||
echo "consul copyright year is ${CONSUL_COPYRIGHT_YEAR}"
|
echo "consul copyright year is ${CONSUL_COPYRIGHT_YEAR}"
|
||||||
cd ui && make && cd ..
|
cd ui && make && cd ..
|
||||||
|
|
|
@ -26,7 +26,7 @@ GIT_COMMIT_YEAR?=$(shell git show -s --format=%cd --date=format:%Y HEAD)
|
||||||
GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
||||||
GIT_IMPORT=github.com/hashicorp/consul/version
|
GIT_IMPORT=github.com/hashicorp/consul/version
|
||||||
DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ" # it's tricky to do an RFC3339 format in a cross platform way, so we hardcode UTC
|
DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ" # it's tricky to do an RFC3339 format in a cross platform way, so we hardcode UTC
|
||||||
GIT_DATE=$(shell git show -s --format=%cd --date=format:"$(DATE_FORMAT)" HEAD) # we're using this for build date because it's stable across platform builds
|
GIT_DATE=$(shell $(CURDIR)/build-support/scripts/build-date.sh) # we're using this for build date because it's stable across platform builds
|
||||||
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).BuildDate=$(GIT_DATE)
|
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).BuildDate=$(GIT_DATE)
|
||||||
|
|
||||||
ifeq ($(FORCE_REBUILD),1)
|
ifeq ($(FORCE_REBUILD),1)
|
||||||
|
|
|
@ -299,7 +299,7 @@ function git_date {
|
||||||
# it's tricky to do an RFC3339 format in a cross platform way, so we hardcode UTC
|
# it's tricky to do an RFC3339 format in a cross platform way, so we hardcode UTC
|
||||||
local date_format="%Y-%m-%dT%H:%M:%SZ"
|
local date_format="%Y-%m-%dT%H:%M:%SZ"
|
||||||
# we're using this for build date because it's stable across platform builds
|
# we're using this for build date because it's stable across platform builds
|
||||||
local date=$(git show -s --format=%cd --date=format:"$date_format" HEAD)
|
local date="$(git show -s --format=%cd --date=format:"$date_format" HEAD)" || ret=1
|
||||||
|
|
||||||
##local head="$(git status -b --porcelain=v2 | awk '{if ($1 == "#" && $2 =="branch.head") { print $3 }}')" || ret=1
|
##local head="$(git status -b --porcelain=v2 | awk '{if ($1 == "#" && $2 =="branch.head") { print $3 }}')" || ret=1
|
||||||
|
|
||||||
|
|
|
@ -202,6 +202,9 @@ func (c *cmd) run(args []string) int {
|
||||||
segment = "<all>"
|
segment = "<all>"
|
||||||
}
|
}
|
||||||
ui.Info(fmt.Sprintf(" Version: '%s'", c.versionHuman))
|
ui.Info(fmt.Sprintf(" Version: '%s'", c.versionHuman))
|
||||||
|
if strings.Contains(c.versionHuman, "dev") {
|
||||||
|
ui.Info(fmt.Sprintf(" Revision: '%s'", c.revision))
|
||||||
|
}
|
||||||
ui.Info(fmt.Sprintf(" Build Date: %s", c.buildDate))
|
ui.Info(fmt.Sprintf(" Build Date: %s", c.buildDate))
|
||||||
ui.Info(fmt.Sprintf(" Node ID: '%s'", config.NodeID))
|
ui.Info(fmt.Sprintf(" Node ID: '%s'", config.NodeID))
|
||||||
ui.Info(fmt.Sprintf(" Node name: '%s'", config.NodeName))
|
ui.Info(fmt.Sprintf(" Node name: '%s'", config.NodeName))
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -43,6 +44,8 @@ func (_ *prettyFormatter) Format(info *VersionInfo) (string, error) {
|
||||||
buffer.WriteString(fmt.Sprintf("Revision %s\n", info.Revision))
|
buffer.WriteString(fmt.Sprintf("Revision %s\n", info.Revision))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer.WriteString(fmt.Sprintf("Build Date %s\n", info.BuildDate.Format(time.RFC3339)))
|
||||||
|
|
||||||
var supplement string
|
var supplement string
|
||||||
if info.RPC.Default < info.RPC.Max {
|
if info.RPC.Default < info.RPC.Max {
|
||||||
supplement = fmt.Sprintf(" (agent will automatically use protocol >%d when speaking to compatible agents)",
|
supplement = fmt.Sprintf(" (agent will automatically use protocol >%d when speaking to compatible agents)",
|
||||||
|
|
|
@ -36,6 +36,7 @@ func TestFormat(t *testing.T) {
|
||||||
Version: "1.99.3",
|
Version: "1.99.3",
|
||||||
Prerelease: "beta1",
|
Prerelease: "beta1",
|
||||||
Revision: "5e5dbedd47a5f875b60e241c5555a9caab595246",
|
Revision: "5e5dbedd47a5f875b60e241c5555a9caab595246",
|
||||||
|
BuildDate: "2022-06-01T13:18:45Z",
|
||||||
RPC: RPCVersionInfo{
|
RPC: RPCVersionInfo{
|
||||||
Default: 2,
|
Default: 2,
|
||||||
Min: 1,
|
Min: 1,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"Version": "1.99.3",
|
"Version": "1.99.3",
|
||||||
"Revision": "5e5dbedd47a5f875b60e241c5555a9caab595246",
|
"Revision": "5e5dbedd47a5f875b60e241c5555a9caab595246",
|
||||||
"Prerelease": "beta1",
|
"Prerelease": "beta1",
|
||||||
|
"BuildDate": "2022-06-01T13:18:45Z",
|
||||||
"RPC": {
|
"RPC": {
|
||||||
"Default": 2,
|
"Default": 2,
|
||||||
"Min": 1,
|
"Min": 1,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
Consul v1.99.3-beta1
|
Consul v1.99.3-beta1
|
||||||
Revision 5e5dbedd47a5f875b60e241c5555a9caab595246
|
Revision 5e5dbedd47a5f875b60e241c5555a9caab595246
|
||||||
|
Build Date 2022-06-01T13:18:45Z
|
||||||
Protocol 2 spoken by default, understands 1 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
|
Protocol 2 spoken by default, understands 1 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/consul"
|
"github.com/hashicorp/consul/agent/consul"
|
||||||
"github.com/hashicorp/consul/command/flags"
|
"github.com/hashicorp/consul/command/flags"
|
||||||
|
@ -46,6 +47,7 @@ type VersionInfo struct {
|
||||||
Version string
|
Version string
|
||||||
Revision string
|
Revision string
|
||||||
Prerelease string
|
Prerelease string
|
||||||
|
BuildDate time.Time
|
||||||
RPC RPCVersionInfo
|
RPC RPCVersionInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,11 +61,20 @@ func (c *cmd) Run(args []string) int {
|
||||||
c.UI.Error(err.Error())
|
c.UI.Error(err.Error())
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We parse this here because consul version is used in our 'smoke' tests and we want to fail early
|
||||||
|
buildDate, err := time.Parse(time.RFC3339, version.BuildDate)
|
||||||
|
if err != nil {
|
||||||
|
c.UI.Error(err.Error())
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
out, err := formatter.Format(&VersionInfo{
|
out, err := formatter.Format(&VersionInfo{
|
||||||
HumanVersion: version.GetHumanVersion(),
|
HumanVersion: version.GetHumanVersion(),
|
||||||
Version: version.Version,
|
Version: version.Version,
|
||||||
Revision: version.GitCommit,
|
Revision: version.GitCommit,
|
||||||
Prerelease: version.VersionPrerelease,
|
Prerelease: version.VersionPrerelease,
|
||||||
|
BuildDate: buildDate,
|
||||||
RPC: RPCVersionInfo{
|
RPC: RPCVersionInfo{
|
||||||
Default: consul.DefaultRPCProtocol,
|
Default: consul.DefaultRPCProtocol,
|
||||||
Min: int(consul.ProtocolVersionMin),
|
Min: int(consul.ProtocolVersionMin),
|
||||||
|
|
Loading…
Reference in New Issue