Skip to content

chore: go releaser #71

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

Merged
merged 2 commits into from
Apr 3, 2025
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: GoReleaser Release
on:
push:
tags:
- "v*"
permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Download dependencies
run: go mod download

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552
with:
distribution: goreleaser
# GoReleaser version
version: "~> v2"
# Arguments to pass to GoReleaser
args: release --clean
workdir: .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
cmd/github-mcp-server/github-mcp-server
# Added by goreleaser init:
dist/
47 changes: 47 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: 2
project_name: github-mcp-server
before:
hooks:
- go mod tidy
- go generate ./...
- script/licenses
- cp -r ./third-party/ ./dist
- cp third-party-licenses.md ./dist/third-party-licenses.md

builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
goos:
- linux
- windows
- darwin
main: ./cmd/github-mcp-server

archives:
- formats: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
formats: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
draft: true
prerelease: auto
name_template: "GitHub MCP Server {{.Version}}"
13 changes: 9 additions & 4 deletions cmd/github-mcp-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ import (
"github.com/spf13/viper"
)

var version = "version"
var commit = "commit"
var date = "date"

var (
rootCmd = &cobra.Command{
Use: "server",
Short: "GitHub MCP Server",
Long: `A GitHub MCP server that handles various tools and resources.`,
Use: "server",
Short: "GitHub MCP Server",
Long: `A GitHub MCP server that handles various tools and resources.`,
Version: fmt.Sprintf("%s (%s) %s", version, commit, date),
}

stdioCmd = &cobra.Command{
Expand Down Expand Up @@ -101,7 +106,7 @@ func runStdioServer(readOnly bool, logger *log.Logger, logCommands bool, exportT
logger.Fatal("GITHUB_PERSONAL_ACCESS_TOKEN not set")
}
ghClient := gogithub.NewClient(nil).WithAuthToken(token)
ghClient.UserAgent = "github-mcp-server/1.0"
ghClient.UserAgent = fmt.Sprintf("github-mcp-server/%s", version)

// Check GH_HOST env var first, then fall back to viper config
host := os.Getenv("GH_HOST")
Expand Down