Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add version subcommand to display build metadata#119

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SamMorrowDrums merged 5 commits intogithub:mainfromjoe-ton:feat/version-subcommand
Apr 15, 2025

Conversation

joe-ton
Copy link
Contributor

Feature:version Subcommand for GitHub MCP Server CLI

This PR adds a newversion subcommand to the GitHub MCP Server CLI, providing build metadata for better visibility and traceability in development and CI environments.

What’s Included

  • Addsserver version command using Cobra
  • Outputs:
    • Semantic version
    • Git commit hash
    • UTC build date
### Build Metadata Injectiongo build -ldflags"\  -X main.version=v0.1.0\  -X main.commit=$(git rev-parse --short HEAD)\  -X main.date=$(date -u +%Y-%m-%d)" \  -o server ./cmd/github-mcp-server### Example Output$ ./server versionGitHub MCP ServerVersion: v0.1.0Commit: abc1234Build Date: 2025-04-04

Perhaps work on Makefiles / automation (build + make) for later.

@joe-ton
Copy link
ContributorAuthor

✅ Rebased withmain and resolved conflicts.
✅ PR passes local testing.
Let me know if anything else is needed!

@juruen
Copy link
Collaborator

@joe-ton

There's already a-v flag to display version info:

 % ./github-mcp-server -vserver version v0.1.0 (270bbf7) 2025-04-05

isn't that enough?

SamMorrowDrums reacted with thumbs up emoji

@SamMorrowDrums
Copy link
Collaborator

I believe we can add aSetVersionTemplate param to the root cobra command or similar to improve the output, as I agree that the output could be nicer, and I like the format suggested in this PR.

But as@juruen mentioned, the--version flag, and ldflags are already being set in the docker builds and binary builds specified in the.goreleaser file in the repo root.

@joe-ton
Copy link
ContributorAuthor

@juruen@SamMorrowDrums

Good point -- I noticed the -v flag after opening the PR. My intent here was improving the clarity and completeness of the build metadata for easier traceability in CI/CD environments. If we're aligned on keeping the simpler flag, I'm happy to refactor the existing -v output using SetVersionTemplate as Sam suggested. Would this work for you both?

SamMorrowDrums reacted with heart emoji

@SamMorrowDrums
Copy link
Collaborator

Yes, definitely.

@joe-tonjoe-ton closed thisApr 5, 2025
@joe-tonjoe-tonforce-pushed thefeat/version-subcommand branch fromdeacd75 to6b02799CompareApril 5, 2025 21:54
@joe-tonjoe-ton reopened thisApr 5, 2025
@joe-ton
Copy link
ContributorAuthor

@SamMorrowDrums@juruen

Implemented version output improvement usingSetVersionTemplate. Ready for review and workflow approval. Let me know if any additional tweaks are needed!

@joe-ton
Copy link
ContributorAuthor

For easy reproduction and verification, you can use the following:

In project root:

Build:

go build -ldflags "\  -X main.version=v0.1.0 \  -X main.commit=$(git rev-parse --short HEAD) \  -X main.date=$(date -u +%Y-%m-%d)" \  -o server ./cmd/github-mcp-server

Test:

./server --version

@SamMorrowDrums
Copy link
Collaborator

@joe-ton I fixed spaces instead of tabs, and because the template command uses a template library, I made use of it - although it doesn't make much difference. The output is the same.

GitHub MCP ServerVersion: v0.1.0Commit: ff3036dBuild Date: 2025-04-15

SamMorrowDrums
SamMorrowDrums previously approved these changesApr 15, 2025
@SamMorrowDrums
Copy link
Collaborator

@joe-ton the tabs not spaces thing for go is important, and you should havego-fmt run on save in your code editor. The Go tools are great, and will save you a bunch of time!

@SamMorrowDrumsSamMorrowDrums merged commitb72a591 intogithub:mainApr 15, 2025
9 checks passed
@joe-ton
Copy link
ContributorAuthor

@SamMorrowDrums Thanks for accepting the PR. Yes, I need to dogo-fmt on my NeoVim config lol Appreciate it!!

SamMorrowDrums reacted with heart emoji

@joe-tonjoe-ton deleted the feat/version-subcommand branchApril 15, 2025 19:14
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@SamMorrowDrumsSamMorrowDrumsSamMorrowDrums approved these changes

@juruenjuruenAwaiting requested review from juruen

@williammartinwilliammartinAwaiting requested review from williammartin

@tobytobyAwaiting requested review from toby

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@joe-ton@juruen@SamMorrowDrums

[8]ページ先頭

©2009-2025 Movatter.jp