Add version flag to CLI and set version during build#6
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds a build-time version injection and a CLI flag to display it.
- Introduces a
Versionvariable and a-versionflag inmain.go - Updates GitHub Actions workflow to pass the Git ref as
main.Versionvialdflags
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| main.go | Added Version var and -version flag handling |
| .github/workflows/release-go-github.yml | Configured ldflags to set main.Version on build |
Comments suppressed due to low confidence (2)
.github/workflows/release-go-github.yml:48
- The single quotes around
main.Versionin the ldflags string will be included in the version value. Remove the extra quotes so it reads-X main.Version=${{ github.ref_name }}.
ldflags: "-X 'main.Version=${{ github.ref_name }}'"
main.go:55
- Add a unit or integration test to verify that running the CLI with
-versionoutputs the injectedVersionstring as expected.
showVersion := flag.Bool("version", false, "Print version")
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
========================================
- Coverage 6.81% 6.76% -0.06%
========================================
Files 8 8
Lines 763 769 +6
========================================
Hits 52 52
- Misses 707 713 +6
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.