Include build information and add version command (#194)
Includes relevant fields listed on
https://goreleaser.com/customization/templates/ into build artifacts.
The version command outputs the version by default:
```
$ bricks version
0.0.21-devel
```
Or all build information if `--json` is specified:
```
$ bricks version --json
{
"ProjectName": "bricks",
"Version": "0.0.21-devel",
"Branch": "version-info",
"Tag": "v0.0.20",
"ShortCommit": "193b56b",
"FullCommit": "193b56b0929128c0836d35e913c46fd66fa2a93c",
"CommitTime": "2023-02-02T22:04:42+01:00",
"Summary": "v0.0.20-5-g193b56b",
"Major": 0,
"Minor": 0,
"Patch": 20,
"Prerelease": "",
"IsSnapshot": true,
"BuildTime": "2023-02-02T22:07:36+01:00"
}
```
2023-02-03 14:38:53 +00:00
|
|
|
package build
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
var buildProjectName string = "cli"
|
Include build information and add version command (#194)
Includes relevant fields listed on
https://goreleaser.com/customization/templates/ into build artifacts.
The version command outputs the version by default:
```
$ bricks version
0.0.21-devel
```
Or all build information if `--json` is specified:
```
$ bricks version --json
{
"ProjectName": "bricks",
"Version": "0.0.21-devel",
"Branch": "version-info",
"Tag": "v0.0.20",
"ShortCommit": "193b56b",
"FullCommit": "193b56b0929128c0836d35e913c46fd66fa2a93c",
"CommitTime": "2023-02-02T22:04:42+01:00",
"Summary": "v0.0.20-5-g193b56b",
"Major": 0,
"Minor": 0,
"Patch": 20,
"Prerelease": "",
"IsSnapshot": true,
"BuildTime": "2023-02-02T22:07:36+01:00"
}
```
2023-02-03 14:38:53 +00:00
|
|
|
var buildVersion string = ""
|
|
|
|
|
|
|
|
var buildBranch string = "undefined"
|
|
|
|
var buildTag string = "undefined"
|
|
|
|
var buildShortCommit string = "00000000"
|
|
|
|
var buildFullCommit string = "0000000000000000000000000000000000000000"
|
|
|
|
var buildCommitTimestamp string = "0"
|
|
|
|
var buildSummary string = "v0.0.0"
|
|
|
|
|
|
|
|
var buildMajor string = "0"
|
|
|
|
var buildMinor string = "0"
|
|
|
|
var buildPatch string = "0"
|
|
|
|
var buildPrerelease string = ""
|
|
|
|
var buildIsSnapshot string = "false"
|
|
|
|
var buildTimestamp string = "0"
|
2024-04-02 12:55:21 +00:00
|
|
|
|
|
|
|
// This function is used to set the build version for testing purposes.
|
|
|
|
func SetBuildVersion(version string) {
|
|
|
|
buildVersion = version
|
|
|
|
info.Version = version
|
|
|
|
}
|