diff --git a/Makefile b/Makefile index 47ae2ff7b..52fc854a8 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ GOIMPORTS_BIN := $(GO_BIN)/gosimports COMMIT := $(shell git describe --abbrev=40 --dirty --tags) COMMIT_HASH := $(shell git rev-parse HEAD) +DIRTY := $(shell git diff-index --quiet HEAD -- || echo -dirty) PUBLIC_URL := # GO_VERSION is the Go version used for the release build, docker files, and @@ -69,6 +70,8 @@ make_ldflags = $(2) -X $(LND_PKG)/build.Commit=lightning-terminal-$(COMMIT) \ -X $(LND_PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g') \ -X $(PKG).appFilesPrefix=$(PUBLIC_URL) \ -X $(PKG).Commit=$(COMMIT) \ + -X $(PKG).CommitHash=$(COMMIT_HASH) \ + -X $(PKG).Dirty=$(DIRTY) \ -X $(LOOP_PKG).Commit=$(LOOP_COMMIT) \ -X $(POOL_PKG).Commit=$(POOL_COMMIT) \ -X $(TAP_PKG).Commit=$(TAP_COMMIT) diff --git a/app/src/types/generated/proxy_pb.d.ts b/app/src/types/generated/proxy_pb.d.ts index fd882ae9a..f038e4c94 100644 --- a/app/src/types/generated/proxy_pb.d.ts +++ b/app/src/types/generated/proxy_pb.d.ts @@ -99,6 +99,9 @@ export class GetInfoResponse extends jspb.Message { getVersion(): string; setVersion(value: string): void; + getCommitHash(): string; + setCommitHash(value: string): void; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): GetInfoResponse.AsObject; static toObject(includeInstance: boolean, msg: GetInfoResponse): GetInfoResponse.AsObject; @@ -112,6 +115,7 @@ export class GetInfoResponse extends jspb.Message { export namespace GetInfoResponse { export type AsObject = { version: string, + commitHash: string, } } diff --git a/app/src/types/generated/proxy_pb.js b/app/src/types/generated/proxy_pb.js index ae5f2af3a..a8c590290 100644 --- a/app/src/types/generated/proxy_pb.js +++ b/app/src/types/generated/proxy_pb.js @@ -781,7 +781,8 @@ proto.litrpc.GetInfoResponse.prototype.toObject = function(opt_includeInstance) */ proto.litrpc.GetInfoResponse.toObject = function(includeInstance, msg) { var f, obj = { - version: jspb.Message.getFieldWithDefault(msg, 1, "") + version: jspb.Message.getFieldWithDefault(msg, 1, ""), + commitHash: jspb.Message.getFieldWithDefault(msg, 2, "") }; if (includeInstance) { @@ -822,6 +823,10 @@ proto.litrpc.GetInfoResponse.deserializeBinaryFromReader = function(msg, reader) var value = /** @type {string} */ (reader.readString()); msg.setVersion(value); break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setCommitHash(value); + break; default: reader.skipField(); break; @@ -858,6 +863,13 @@ proto.litrpc.GetInfoResponse.serializeBinaryToWriter = function(message, writer) f ); } + f = message.getCommitHash(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } }; @@ -879,4 +891,22 @@ proto.litrpc.GetInfoResponse.prototype.setVersion = function(value) { }; +/** + * optional string commit_hash = 2; + * @return {string} + */ +proto.litrpc.GetInfoResponse.prototype.getCommitHash = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.litrpc.GetInfoResponse} returns this + */ +proto.litrpc.GetInfoResponse.prototype.setCommitHash = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + goog.object.extend(exports, proto.litrpc); diff --git a/cmd/litcli/main.go b/cmd/litcli/main.go index 9bcce4472..7571d4cb9 100644 --- a/cmd/litcli/main.go +++ b/cmd/litcli/main.go @@ -73,7 +73,7 @@ var ( func main() { app := cli.NewApp() - app.Version = terminal.Version() + app.Version = terminal.RichVersion() app.Name = "litcli" app.Usage = "control plane for your Lightning Terminal (lit) daemon" app.Flags = []cli.Flag{ diff --git a/config.go b/config.go index 9418ca869..ae3a5a15a 100644 --- a/config.go +++ b/config.go @@ -367,7 +367,7 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) { appName := filepath.Base(os.Args[0]) appName = strings.TrimSuffix(appName, filepath.Ext(appName)) if preCfg.ShowVersion { - fmt.Println(appName, "version", Version()) + fmt.Println(appName, "version", RichVersion()) os.Exit(0) } if preCfg.Lnd.ShowVersion { diff --git a/docs/release-notes/release-notes-0.14.2.md b/docs/release-notes/release-notes-0.14.2.md index 6e91c8932..3684a3e25 100644 --- a/docs/release-notes/release-notes-0.14.2.md +++ b/docs/release-notes/release-notes-0.14.2.md @@ -51,6 +51,21 @@ `supermacaroon:write` permission to disable access to the `bakesupermacaroon` endpoint. +* [A `commit_hash` field has been added to the `GetInfo` + response](https://github.com/lightninglabs/lightning-terminal/pull/1034). + The `commit_hash` field will contain the full commit hash of the commit that + LiT release binary build was based on. If the build had uncommitted changes, + the `commit_hash` field will contain the most recent commit hash, suffixed by + "-dirty". + The contents of the `version` field in the `GetInfo` response has also been + updated to only include the semantic version number of the LiT release, + following the semantic versioning 2.0.0 spec (http://semver.org/). + +* [A `commit_hash` field has been added to the `--version` + output](https://github.com/lightninglabs/lightning-terminal/pull/1034). + The `commit_hash` field will contain the full commit hash of the commit that + LiT release binary build was based on. + ## Integrated Binary Updates ### LND diff --git a/litrpc/proxy.pb.go b/litrpc/proxy.pb.go index 56aa65894..23c22eb7d 100644 --- a/litrpc/proxy.pb.go +++ b/litrpc/proxy.pb.go @@ -245,8 +245,14 @@ type GetInfoResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The version of the LiTd software that the node is running. + // The application version of the LiTd software running on the node, + // following the Semantic Versioning 2.0.0 specification + // (http://semver.org/). Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // The Git commit hash the LiTd binary build was based on. If the build had + // uncommited changes, this field will contain the most recent commit hash, + // suffixed by "-dirty". + CommitHash string `protobuf:"bytes,2,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"` } func (x *GetInfoResponse) Reset() { @@ -288,6 +294,13 @@ func (x *GetInfoResponse) GetVersion() string { return "" } +func (x *GetInfoResponse) GetCommitHash() string { + if x != nil { + return x.CommitHash + } + return "" +} + var File_proxy_proto protoreflect.FileDescriptor var file_proxy_proto_rawDesc = []byte{ @@ -306,28 +319,30 @@ var file_proxy_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x53, 0x74, 0x6f, 0x70, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x2b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x74, 0x22, 0x4c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0xe2, - 0x01, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x3a, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6c, 0x69, - 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x53, 0x74, 0x6f, 0x70, 0x44, 0x61, 0x65, 0x6d, - 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x6f, 0x70, - 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, - 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x44, 0x61, 0x65, 0x6d, 0x6f, - 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x42, 0x61, 0x6b, - 0x65, 0x53, 0x75, 0x70, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x12, 0x20, - 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, 0x65, - 0x72, 0x4d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x21, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x61, 0x6b, 0x65, 0x53, 0x75, - 0x70, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, - 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, - 0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, + 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x48, 0x61, 0x73, 0x68, 0x32, + 0xe2, 0x01, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x3a, 0x0a, 0x07, 0x47, 0x65, 0x74, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x53, 0x74, 0x6f, 0x70, 0x44, 0x61, 0x65, + 0x6d, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x6f, + 0x70, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, + 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x44, 0x61, 0x65, 0x6d, + 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x42, 0x61, + 0x6b, 0x65, 0x53, 0x75, 0x70, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x12, + 0x20, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x61, 0x6b, 0x65, 0x53, 0x75, 0x70, + 0x65, 0x72, 0x4d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x21, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x42, 0x61, 0x6b, 0x65, 0x53, + 0x75, 0x70, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, + 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/litrpc/proxy.proto b/litrpc/proxy.proto index 4a5892fb5..f58cb1d0e 100644 --- a/litrpc/proxy.proto +++ b/litrpc/proxy.proto @@ -52,6 +52,13 @@ message GetInfoRequest { } message GetInfoResponse { - // The version of the LiTd software that the node is running. + // The application version of the LiTd software running on the node, + // following the Semantic Versioning 2.0.0 specification + // (http://semver.org/). string version = 1; + + // The Git commit hash the LiTd binary build was based on. If the build had + // uncommited changes, this field will contain the most recent commit hash, + // suffixed by "-dirty". + string commit_hash = 2; } \ No newline at end of file diff --git a/litrpc/proxy.swagger.json b/litrpc/proxy.swagger.json index f41678fc4..1c2bbb782 100644 --- a/litrpc/proxy.swagger.json +++ b/litrpc/proxy.swagger.json @@ -135,7 +135,11 @@ "properties": { "version": { "type": "string", - "description": "The version of the LiTd software that the node is running." + "description": "The application version of the LiTd software running on the node,\nfollowing the Semantic Versioning 2.0.0 specification\n(http://semver.org/)." + }, + "commit_hash": { + "type": "string", + "description": "The Git commit hash the LiTd binary build was based on. If the build had\nuncommited changes, this field will contain the most recent commit hash,\nsuffixed by \"-dirty\"." } } }, diff --git a/proto/proxy.proto b/proto/proxy.proto index 4a5892fb5..f58cb1d0e 100644 --- a/proto/proxy.proto +++ b/proto/proxy.proto @@ -52,6 +52,13 @@ message GetInfoRequest { } message GetInfoResponse { - // The version of the LiTd software that the node is running. + // The application version of the LiTd software running on the node, + // following the Semantic Versioning 2.0.0 specification + // (http://semver.org/). string version = 1; + + // The Git commit hash the LiTd binary build was based on. If the build had + // uncommited changes, this field will contain the most recent commit hash, + // suffixed by "-dirty". + string commit_hash = 2; } \ No newline at end of file diff --git a/rpc_proxy.go b/rpc_proxy.go index f9011eb70..885afa643 100644 --- a/rpc_proxy.go +++ b/rpc_proxy.go @@ -240,7 +240,8 @@ func (p *rpcProxy) GetInfo(_ context.Context, _ *litrpc.GetInfoRequest) ( *litrpc.GetInfoResponse, error) { return &litrpc.GetInfoResponse{ - Version: Version(), + Version: Version(), + CommitHash: CommitHash + Dirty, }, nil } diff --git a/terminal.go b/terminal.go index c48c5fcfc..408a03fed 100644 --- a/terminal.go +++ b/terminal.go @@ -298,7 +298,7 @@ func (g *LightningTerminal) Run(ctx context.Context) error { g.defaultImplCfg = g.cfg.Lnd.ImplementationConfig(shutdownInterceptor) // Show version at startup. - log.Infof("LiT version: %s", Version()) + log.Infof("LiT version: %s", RichVersion()) // This concurrent error queue can be used by every component that can // raise runtime errors. Using a queue will prevent us from blocking on @@ -2010,7 +2010,7 @@ func (g *LightningTerminal) showStartupInfo(ctx context.Context) error { " Web interface %s \n" + "----------------------------------------------------------\n" fmt.Printf(str, info.mode, info.status, info.alias, info.version, - Version(), webInterfaceString) + RichVersion(), webInterfaceString) return nil } diff --git a/version.go b/version.go index 2ec0feb09..082a1fc12 100644 --- a/version.go +++ b/version.go @@ -11,10 +11,21 @@ import ( "strings" ) -// Commit stores the current commit hash of this build, this should be set -// using the -ldflags during compilation. +// Commit stores the current git tag of this build, when the build is based on +// a tagged commit. If the build is based on an untagged commit or is a dirty +// build, the Commit field stores the most recent tag suffixed by the commit +// hash, and/or "-dirty". This should be set using the -ldflags during +// compilation. var Commit string +// CommitHash stores the current git commit hash of this build. This should be +// set using the -ldflags during compilation. +var CommitHash string + +// Dirty stores a "-dirty" string, if the build had uncommitted changes when +// being built. This should be set using the -ldflags during compilation. +var Dirty string + // semanticAlphabet const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-." @@ -33,6 +44,22 @@ const ( // Version returns the application version as a properly formed string per the // semantic versioning 2.0.0 spec (http://semver.org/). func Version() string { + return semanticVersion() +} + +// RichVersion returns the application version as a properly formed string +// per the semantic versioning 2.0.0 spec (http://semver.org/), the git tag and +// commit hash it was built on. +func RichVersion() string { + // Append git tag and commit hash of current build to version. + return fmt.Sprintf( + "%s commit=%s commit_hash=%s", semanticVersion(), Commit, + CommitHash, + ) +} + +// semanticVersion returns the SemVer part of the version. +func semanticVersion() string { // Start with the major, minor, and patch versions. version := fmt.Sprintf("%d.%d.%d", appMajor, appMinor, appPatch) @@ -45,9 +72,6 @@ func Version() string { version = fmt.Sprintf("%s-%s", version, preRelease) } - // Append commit hash of current build to version. - version = fmt.Sprintf("%s commit=%s", version, Commit) - return version }