Skip to content

Commit bf1e04f

Browse files
aksOpsclaude
andcommitted
feat: adopt central-ops shared packages and reusable workflows
- Replace inline beta/release workflows with central-ops reusable callers - Adopt pkg/version.Detect() in main.go (removes inline debug.ReadBuildInfo) - Adopt pkg/httputil.CORSMiddleware in internal/mcp/server.go Handler() - Add require + replace directive for github.com/RandomCodeSpace/central-ops Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8e08ad9 commit bf1e04f

5 files changed

Lines changed: 19 additions & 91 deletions

File tree

.github/workflows/beta.yml

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,10 @@ name: Auto Beta
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main]
76

87
jobs:
9-
beta:
10-
runs-on: ubuntu-latest
8+
auto-beta:
9+
uses: RandomCodeSpace/central-ops/.github/workflows/reusable-auto-beta.yml@main
1110
permissions:
1211
contents: write
13-
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
18-
19-
- name: Compute next beta version
20-
id: version
21-
run: |
22-
# Find the latest manually-created base tag (e.g. v0.0.4-beta)
23-
# Pattern: vX.Y.Z-beta with nothing after (no dot-number suffix)
24-
LATEST_BASE=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*-beta' \
25-
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+-beta$' \
26-
| sort -V | tail -1)
27-
28-
if [ -z "$LATEST_BASE" ]; then
29-
echo "No manual beta base tag found, defaulting to v0.0.1-beta"
30-
LATEST_BASE="v0.0.1-beta"
31-
fi
32-
33-
echo "Base version: ${LATEST_BASE}"
34-
35-
# Find the highest auto-increment tag for this base (e.g. v0.0.4-beta.3)
36-
HIGHEST=$(git tag -l "${LATEST_BASE}.[0-9]*" | sort -V | tail -1)
37-
38-
if [ -z "$HIGHEST" ]; then
39-
NEXT="${LATEST_BASE}.1"
40-
else
41-
N="${HIGHEST##*.}"
42-
NEXT="${LATEST_BASE}.$((N + 1))"
43-
fi
44-
45-
echo "Next version: ${NEXT}"
46-
echo "version=${NEXT}" >> "$GITHUB_OUTPUT"
47-
48-
- name: Create tag
49-
run: |
50-
git tag ${{ steps.version.outputs.version }}
51-
git push origin ${{ steps.version.outputs.version }}
52-
53-
- name: Create pre-release
54-
uses: softprops/action-gh-release@v2
55-
with:
56-
tag_name: ${{ steps.version.outputs.version }}
57-
prerelease: true
58-
generate_release_notes: true

.github/workflows/release.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,13 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Base beta version to release (e.g., v0.0.5-beta). Auto-increments (v0.0.5-beta.1, .2, …) will resume from this base on the next push to main.'
7+
description: 'Base beta version to release (e.g., v0.0.5-beta)'
88
required: true
99

1010
jobs:
1111
release:
12-
runs-on: ubuntu-latest
12+
uses: RandomCodeSpace/central-ops/.github/workflows/reusable-release.yml@main
1313
permissions:
1414
contents: write
15-
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
20-
21-
- name: Create Tag
22-
run: |
23-
git tag ${{ inputs.version }}
24-
git push origin ${{ inputs.version }}
25-
env:
26-
INPUT_VERSION: ${{ inputs.version }}
27-
28-
- name: Create Release
29-
uses: softprops/action-gh-release@v2
30-
with:
31-
tag_name: ${{ inputs.version }}
32-
prerelease: false
33-
generate_release_notes: true
15+
with:
16+
version: ${{ inputs.version }}

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ module github.com/RandomCodeSpace/argus
22

33
go 1.25.0
44

5+
require github.com/RandomCodeSpace/central-ops v0.1.0
6+
7+
replace github.com/RandomCodeSpace/central-ops => ../central-ops
8+
59
require (
610
github.com/coder/websocket v1.8.14
711
github.com/glebarez/sqlite v1.11.0

internal/mcp/server.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/RandomCodeSpace/argus/internal/storage"
1414
"github.com/RandomCodeSpace/argus/internal/telemetry"
1515
"github.com/RandomCodeSpace/argus/internal/vectordb"
16+
"github.com/RandomCodeSpace/central-ops/pkg/httputil"
1617
)
1718

1819
const (
@@ -47,22 +48,15 @@ func New(
4748
}
4849
}
4950

50-
// Handler returns an http.Handler for the MCP server.
51+
// Handler returns an http.Handler for the MCP server with CORS applied.
5152
// Works correctly when mounted with http.StripPrefix.
5253
func (s *Server) Handler() http.Handler {
53-
return http.HandlerFunc(s.ServeHTTP)
54+
return httputil.CORSMiddleware("*", http.HandlerFunc(s.ServeHTTP))
5455
}
5556

5657
// ServeHTTP dispatches by HTTP method — no path routing needed.
5758
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
58-
// CORS headers on every response
59-
w.Header().Set("Access-Control-Allow-Origin", "*")
60-
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
61-
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Mcp-Session-Id, Accept")
62-
6359
switch r.Method {
64-
case http.MethodOptions:
65-
w.WriteHeader(http.StatusNoContent)
6660
case http.MethodPost:
6761
s.handleRPC(w, r)
6862
case http.MethodGet:

main.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"net/http"
1212
"os"
1313
"os/signal"
14-
"runtime/debug"
1514
"strings"
1615
"syscall"
1716
"time"
1817

18+
"github.com/RandomCodeSpace/central-ops/pkg/version"
19+
1920
"github.com/RandomCodeSpace/argus/internal/ai"
2021
"github.com/RandomCodeSpace/argus/internal/api"
2122
"github.com/RandomCodeSpace/argus/internal/archive"
@@ -40,16 +41,9 @@ import (
4041
)
4142

4243

43-
// Version defaults to "local" for development builds.
44-
// When installed via `go install module@vX.Y.Z`, the module version is read
45-
// automatically from build info — no ldflags required.
46-
var Version = func() string {
47-
if info, ok := debug.ReadBuildInfo(); ok &&
48-
info.Main.Version != "" && info.Main.Version != "(devel)" {
49-
return info.Main.Version
50-
}
51-
return "local"
52-
}()
44+
// Version is detected from build info at startup.
45+
// Returns the real tag when installed via `go install`, "local" otherwise.
46+
var Version = version.Detect()
5347

5448
func main() {
5549
versionFlag := flag.Bool("version", false, "print version and exit")

0 commit comments

Comments
 (0)