Skip to content

feat: implement version command#419

Merged
shizhMSFT merged 2 commits intonotaryproject:mainfrom
JeyJeyGao:junjiegao/cmd_version
Oct 31, 2022
Merged

feat: implement version command#419
shizhMSFT merged 2 commits intonotaryproject:mainfrom
JeyJeyGao:junjiegao/cmd_version

Conversation

@JeyJeyGao
Copy link
Copy Markdown
Contributor

@JeyJeyGao JeyJeyGao commented Oct 26, 2022

  • Added version command
  • Removed --version flag
  • Update Makefile to set GitCommit value by ldflags
  • Update the BuildMetadata definition and allow user to override the value by environment variable

Please build it bymake build command to include git commit information

Example

$ ./bin/notation version
Notation: Notary v2, A tool to sign, store, and verify artifacts.

Version:     v0.11.0-alpha.4
Go version:  go1.19
Git commit:  f747031135a6010d92c737ea611276b18f4188d7

If it does not build by make build command, the output will be

$ ./bin/notation version
Notation: Notary v2, A tool to sign, store, and verify artifacts.

Version:     v0.11.0-alpha.4
Go version:  go1.19

Signed-off-by: Junjie Gao junjiegao@microsoft.com

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 26, 2022

Codecov Report

Merging #419 (74edd19) into main (f747031) will decrease coverage by 0.51%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #419      +/-   ##
==========================================
- Coverage   34.60%   34.09%   -0.52%     
==========================================
  Files          23       24       +1     
  Lines        1254     1273      +19     
==========================================
  Hits          434      434              
- Misses        809      828      +19     
  Partials       11       11              
Impacted Files Coverage Δ
cmd/notation/main.go 0.00% <0.00%> (ø)
cmd/notation/version.go 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yizha1 yizha1 added this to the beta-1 milestone Oct 26, 2022
@yizha1 yizha1 added the cli Issue or PR released to Notation CLI label Oct 26, 2022
@JeyJeyGao JeyJeyGao changed the title feat: implement version command feat: implement version command (Draft) Oct 26, 2022
@JeyJeyGao JeyJeyGao force-pushed the junjiegao/cmd_version branch 3 times, most recently from 133861c to 74edd19 Compare October 26, 2022 08:49
@JeyJeyGao JeyJeyGao changed the title feat: implement version command (Draft) feat: implement version command Oct 26, 2022
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
@JeyJeyGao JeyJeyGao force-pushed the junjiegao/cmd_version branch from 74edd19 to ba52b41 Compare October 26, 2022 09:12
@yizha1 yizha1 requested a review from a team October 27, 2022 05:18
@yizha1 yizha1 linked an issue Oct 27, 2022 that may be closed by this pull request
@yizha1 yizha1 removed this from the beta-1 milestone Oct 27, 2022
Copy link
Copy Markdown
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the spec, we should always print out all three of Version, Go Version, and Git Commit.

If the commit is not tagged, we should use unreleased as the build metadata.

if BUILD_METADATA is not defined in ENVIRONMENT variable, use
`unreleased` as the value

Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
@JeyJeyGao
Copy link
Copy Markdown
Contributor Author

According to the spec, we should always print out all three of Version, Go Version, and Git Commit.

If the commit is not tagged, we should use unreleased as the build metadata.

  1. if GitCommit is not set by compiler, its output line will be skipped, which is consistent with oras version behavior and confirmed by Yi @yizha1
  2. updated: build metadata will be unreleased if user didn't define the BUILD_METADATA environment variable and didn't set the tag.

@shizhMSFT

Copy link
Copy Markdown
Contributor

@patrickzheng200 patrickzheng200 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shizhMSFT shizhMSFT merged commit a219ad5 into notaryproject:main Oct 31, 2022
7h3-3mp7y-m4n pushed a commit to 7h3-3mp7y-m4n/notation that referenced this pull request Mar 29, 2025
- Added version command
- Removed --version flag
- Update Makefile to set GitCommit value by ldflags
- Update the BuildMetadata definition and allow user to override the
value by environment variable

Please build it by`make build` command to include git commit information

Example

```
$ ./bin/notation version
Notation: Notary v2, A tool to sign, store, and verify artifacts.

Version:     v0.11.0-alpha.4
Go version:  go1.19
Git commit:  f747031
```

If it does `not` build by `make build` command, the output will be

```
$ ./bin/notation version
Notation: Notary v2, A tool to sign, store, and verify artifacts.

Version:     v0.11.0-alpha.4
Go version:  go1.19
```
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
FeynmanZhou pushed a commit to FeynmanZhou/notation that referenced this pull request May 15, 2025
- Added version command
- Removed --version flag
- Update Makefile to set GitCommit value by ldflags
- Update the BuildMetadata definition and allow user to override the
value by environment variable

Please build it by`make build` command to include git commit information

Example

```
$ ./bin/notation version
Notation: Notary v2, A tool to sign, store, and verify artifacts.

Version:     v0.11.0-alpha.4
Go version:  go1.19
Git commit:  f747031
```

If it does `not` build by `make build` command, the output will be

```
$ ./bin/notation version
Notation: Notary v2, A tool to sign, store, and verify artifacts.

Version:     v0.11.0-alpha.4
Go version:  go1.19
```
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Issue or PR released to Notation CLI

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add version command for notation CLI

7 participants