Skip to content

Add tag & commit_hash field to GetInfo response #1034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ 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).GitCommitHash=$(COMMIT_HASH) \
-X $(LOOP_PKG).Commit=$(LOOP_COMMIT) \
-X $(POOL_PKG).Commit=$(POOL_COMMIT) \
-X $(TAP_PKG).Commit=$(TAP_COMMIT)
Expand Down
8 changes: 8 additions & 0 deletions app/src/types/generated/proxy_pb.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 61 additions & 1 deletion app/src/types/generated/proxy_pb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/litcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions docs/release-notes/release-notes-0.14.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@
`supermacaroon:write` permission to disable access to the
`bakesupermacaroon` endpoint.

* [A `tag` and a `commit_hash` field has been added to the `GetInfo`
response](https://github.com/lightninglabs/lightning-terminal/pull/1034).
The `tag` field will be set to the Git tag that the LiT release binary build
was based on. If the build was not based on a clean tagged commit, this field
will contain the most recent tag suffixed by the commit hash, and/or a
"-dirty" suffix.
The `commit_hash` field will contain the full commit hash of the commit that
LiT release binary build was based on.
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/).

## Integrated Binary Updates

### LND
Expand Down
69 changes: 47 additions & 22 deletions litrpc/proxy.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion litrpc/proxy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ 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 tag that the LiTd binary build was based on. If the build was
// not based on a clean tagged commit, this field will contain the most
// recent tag suffixed by the commit hash, and/or a "-dirty" suffix.
string tag = 2;

// The Git commit hash the LiTd binary build was based on.
string commit_hash = 3;
}
10 changes: 9 additions & 1 deletion litrpc/proxy.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@
"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/)."
},
"tag": {
"type": "string",
"description": "The Git tag that the LiTd binary build was based on. If the build was\nnot based on a clean tagged commit, this field will contain the most\nrecent tag suffixed by the commit hash, and/or a \"-dirty\" suffix."
},
"commit_hash": {
"type": "string",
"description": "The Git commit hash the LiTd binary build was based on."
}
}
},
Expand Down
12 changes: 11 additions & 1 deletion proto/proxy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ 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 tag that the LiTd binary build was based on. If the build was
// not based on a clean tagged commit, this field will contain the most
// recent tag suffixed by the commit hash, and/or a "-dirty" suffix.
string tag = 2;

// The Git commit hash the LiTd binary build was based on.
string commit_hash = 3;
}
4 changes: 3 additions & 1 deletion rpc_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ func (p *rpcProxy) GetInfo(_ context.Context, _ *litrpc.GetInfoRequest) (
*litrpc.GetInfoResponse, error) {

return &litrpc.GetInfoResponse{
Version: Version(),
Version: Version(),
Tag: CommitTag(),
CommitHash: CommitHash(),
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
39 changes: 34 additions & 5 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ 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

// GitCommitHash stores the current git commit hash of this build. This should
// be set using the -ldflags during compilation.
var GitCommitHash string

// semanticAlphabet
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-."

Expand All @@ -33,6 +40,31 @@ 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 tag=%s commit=%s", semanticVersion(), Commit, GitCommitHash,
)
}

// CommitHash returns the git commit hash of the current build.
func CommitHash() string {
return GitCommitHash
}

// CommitTag returns the git tag of the current build.
func CommitTag() string {
return Commit
}

// 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)

Expand All @@ -45,9 +77,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
}

Expand Down
Loading