Skip to content

Commit 520e60b

Browse files
committed
feat: Implement automated releases with GoReleaser and GitHub Actions, and refine logging and HTTP authentication.
1 parent 6267a92 commit 520e60b

File tree

4 files changed

+96
-3
lines changed

4 files changed

+96
-3
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.23'
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v5
27+
with:
28+
# either 'goreleaser' (default) or 'goreleaser-pro'
29+
distribution: goreleaser
30+
version: latest
31+
args: release --clean
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# .goreleaser.yaml
2+
project_name: gomcp-pilot
3+
4+
builds:
5+
- id: gomcp
6+
main: ./cmd/gomcp
7+
binary: gomcp
8+
env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- darwin
13+
- windows
14+
goarch:
15+
- amd64
16+
- arm64
17+
ignore:
18+
- goos: windows
19+
goarch: arm64
20+
21+
archives:
22+
- format: tar.gz
23+
# this name template makes the OS and Arch compatible with the results of uname.
24+
name_template: >-
25+
{{ .ProjectName }}_
26+
{{- title .Os }}_
27+
{{- if eq .Arch "amd64" }}x86_64
28+
{{- else if eq .Arch "386" }}i386
29+
{{- else }}{{ .Arch }}{{ end }}
30+
{{- if .Arm }}v{{ .Arm }}{{ end }}
31+
# use zip for windows
32+
format_overrides:
33+
- goos: windows
34+
format: zip
35+
36+
checksum:
37+
name_template: 'checksums.txt'
38+
39+
snapshot:
40+
name_template: "{{ incpatch .Version }}-next"
41+
42+
changelog:
43+
sort: asc
44+
filters:
45+
exclude:
46+
- '^docs:'
47+
- '^test:'

internal/app/app.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ func (w *logWriter) Write(p []byte) (n int, err error) {
167167

168168
// RunMCP starts upstreams and serves an MCP server over stdio.
169169
func RunMCP(ctx context.Context, cfg *config.Config) error {
170-
logger := log.New(os.Stdout, "[gomcp] ", log.LstdFlags|log.Lmicroseconds)
170+
// Initialize global zap logger first because process manager likely uses it
171+
if err := logger.InitLogger(); err != nil {
172+
return err
173+
}
174+
175+
stdLog := log.New(os.Stderr, "[gomcp-stdio] ", log.LstdFlags|log.Lmicroseconds)
171176

172177
manager := process.NewManager()
173178
if err := manager.StartAll(ctx, cfg); err != nil {
@@ -179,7 +184,7 @@ func RunMCP(ctx context.Context, cfg *config.Config) error {
179184
if err != nil {
180185
return err
181186
}
182-
logger.Println("stdio MCP server ready (connect with MCP-compatible client)")
187+
stdLog.Println("stdio MCP server ready (connect with MCP-compatible client)")
183188
return mcpbridge.ServeStdio(ctx, srv)
184189
}
185190

internal/server/http.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,15 @@ func (s *Server) authMiddleware(next http.Handler) http.Handler {
170170
}
171171
expected := "Bearer " + s.cfg.AuthToken
172172
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
173-
if r.Header.Get("Authorization") != expected {
173+
auth := r.Header.Get("Authorization")
174+
if auth == "" {
175+
token := r.URL.Query().Get("access_token")
176+
if token != "" {
177+
auth = "Bearer " + token
178+
}
179+
}
180+
181+
if auth != expected {
174182
http.Error(w, "unauthorized", http.StatusUnauthorized)
175183
return
176184
}

0 commit comments

Comments
 (0)