Skip to content

Commit 7381ead

Browse files
Initial Commit
0 parents  commit 7381ead

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+13349
-0
lines changed

.github/workflows/ci.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: Test
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
go-version: ['1.21', '1.22']
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: ${{ matrix.go-version }}
27+
28+
- name: Cache Go modules
29+
uses: actions/cache@v3
30+
with:
31+
path: |
32+
~/.cache/go-build
33+
~/go/pkg/mod
34+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
35+
restore-keys: |
36+
${{ runner.os }}-go-${{ matrix.go-version }}-
37+
${{ runner.os }}-go-
38+
39+
- name: Download dependencies
40+
run: go mod download
41+
42+
- name: Verify dependencies
43+
run: go mod verify
44+
45+
- name: Run tests
46+
shell: bash
47+
run: go test -v -race -coverprofile=coverage.out ./...
48+
49+
- name: Upload coverage to Codecov
50+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.21'
51+
uses: codecov/codecov-action@v3
52+
with:
53+
files: ./coverage.out
54+
flags: unittests
55+
name: codecov-umbrella
56+
57+
build:
58+
name: Build
59+
runs-on: ubuntu-latest
60+
needs: test
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Set up Go
67+
uses: actions/setup-go@v5
68+
with:
69+
go-version: '1.21'
70+
71+
- name: Build
72+
run: make build
73+
74+
- name: Verify binary
75+
run: |
76+
./mcp-code-api --version
77+
ls -lh mcp-code-api
78+
79+
lint:
80+
name: Lint
81+
runs-on: ubuntu-latest
82+
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v4
86+
87+
- name: Set up Go
88+
uses: actions/setup-go@v5
89+
with:
90+
go-version: '1.21'
91+
92+
- name: Run golangci-lint
93+
uses: golangci/golangci-lint-action@v3
94+
with:
95+
version: latest
96+
args: --timeout=5m
97+
98+
security:
99+
name: Security Scan
100+
runs-on: ubuntu-latest
101+
permissions:
102+
security-events: write
103+
contents: read
104+
105+
steps:
106+
- name: Checkout code
107+
uses: actions/checkout@v4
108+
109+
- name: Run Gosec Security Scanner
110+
uses: securego/gosec@master
111+
with:
112+
args: '-no-fail -fmt sarif -out results.sarif ./...'
113+
114+
- name: Upload SARIF file
115+
uses: github/codeql-action/upload-sarif@v3
116+
with:
117+
sarif_file: results.sarif

.github/workflows/release.yml

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0, v2.1.3, etc.
7+
workflow_dispatch: # Allow manual trigger
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
name: Build Binaries
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
include:
19+
# Linux builds
20+
- os: ubuntu-latest
21+
goos: linux
22+
goarch: amd64
23+
binary_suffix: ''
24+
- os: ubuntu-latest
25+
goos: linux
26+
goarch: arm64
27+
binary_suffix: ''
28+
29+
# macOS builds
30+
- os: macos-latest
31+
goos: darwin
32+
goarch: amd64
33+
binary_suffix: ''
34+
- os: macos-latest
35+
goos: darwin
36+
goarch: arm64
37+
binary_suffix: ''
38+
39+
# Windows builds
40+
- os: ubuntu-latest
41+
goos: windows
42+
goarch: amd64
43+
binary_suffix: '.exe'
44+
- os: ubuntu-latest
45+
goos: windows
46+
goarch: arm64
47+
binary_suffix: '.exe'
48+
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
53+
- name: Set up Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: '1.21'
57+
58+
- name: Get version from tag
59+
id: get_version
60+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
61+
62+
- name: Build binary
63+
env:
64+
GOOS: ${{ matrix.goos }}
65+
GOARCH: ${{ matrix.goarch }}
66+
CGO_ENABLED: 0
67+
run: |
68+
BINARY_NAME="mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_suffix }}"
69+
go build -v -ldflags="-s -w -X 'main.Version=${{ steps.get_version.outputs.VERSION }}' -X 'main.Commit=${{ github.sha }}' -X 'main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" -o "$BINARY_NAME" .
70+
71+
# Create checksum
72+
if [ "${{ matrix.goos }}" = "windows" ]; then
73+
sha256sum "$BINARY_NAME" > "$BINARY_NAME.sha256"
74+
else
75+
shasum -a 256 "$BINARY_NAME" > "$BINARY_NAME.sha256"
76+
fi
77+
78+
ls -lh "$BINARY_NAME"
79+
80+
- name: Upload artifact
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}
84+
path: |
85+
mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_suffix }}
86+
mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_suffix }}.sha256
87+
retention-days: 7
88+
89+
release:
90+
name: Create Release
91+
needs: build
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
98+
- name: Get version from tag
99+
id: get_version
100+
run: |
101+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
102+
echo "VERSION_NUM=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
103+
104+
- name: Download all artifacts
105+
uses: actions/download-artifact@v4
106+
with:
107+
path: ./artifacts
108+
109+
- name: Prepare release assets
110+
run: |
111+
mkdir -p release
112+
find ./artifacts -type f -exec mv {} ./release/ \;
113+
ls -lh ./release/
114+
115+
# Create a combined checksums file
116+
cd release
117+
cat *.sha256 > SHA256SUMS.txt
118+
cd ..
119+
120+
- name: Generate release notes
121+
id: generate_notes
122+
run: |
123+
cat > release_notes.md << 'EOF'
124+
## MCP Code API ${{ steps.get_version.outputs.VERSION }}
125+
126+
### 📦 Installation
127+
128+
Download the binary for your platform and architecture:
129+
130+
**Linux:**
131+
```bash
132+
# AMD64
133+
curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-linux-amd64 -o mcp-code-api
134+
chmod +x mcp-code-api
135+
sudo mv mcp-code-api /usr/local/bin/
136+
137+
# ARM64
138+
curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-linux-arm64 -o mcp-code-api
139+
chmod +x mcp-code-api
140+
sudo mv mcp-code-api /usr/local/bin/
141+
```
142+
143+
**macOS:**
144+
```bash
145+
# Intel (AMD64)
146+
curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-darwin-amd64 -o mcp-code-api
147+
chmod +x mcp-code-api
148+
sudo mv mcp-code-api /usr/local/bin/
149+
150+
# Apple Silicon (ARM64)
151+
curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-darwin-arm64 -o mcp-code-api
152+
chmod +x mcp-code-api
153+
sudo mv mcp-code-api /usr/local/bin/
154+
```
155+
156+
**Windows:**
157+
```powershell
158+
# AMD64
159+
Invoke-WebRequest -Uri "https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-windows-amd64.exe" -OutFile "mcp-code-api.exe"
160+
161+
# ARM64
162+
Invoke-WebRequest -Uri "https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-windows-arm64.exe" -OutFile "mcp-code-api.exe"
163+
```
164+
165+
### ✅ Verify Installation
166+
167+
```bash
168+
mcp-code-api --version
169+
```
170+
171+
### 🔒 Verify Checksums
172+
173+
Download `SHA256SUMS.txt` and verify:
174+
175+
```bash
176+
# Linux/macOS
177+
sha256sum -c SHA256SUMS.txt
178+
179+
# Or verify individual file
180+
sha256sum mcp-code-api-linux-amd64
181+
cat mcp-code-api-linux-amd64.sha256
182+
```
183+
184+
### 📋 Supported Platforms
185+
186+
- **Linux**: AMD64, ARM64
187+
- **macOS**: AMD64 (Intel), ARM64 (Apple Silicon)
188+
- **Windows**: AMD64, ARM64
189+
190+
### 🚀 Quick Start
191+
192+
```bash
193+
# Run configuration wizard
194+
mcp-code-api config
195+
196+
# Start the server
197+
mcp-code-api server
198+
```
199+
200+
For detailed documentation, see the [README](https://github.com/cecil-the-coder/mcp-code-api#readme).
201+
EOF
202+
203+
- name: Create Release
204+
uses: softprops/action-gh-release@v1
205+
with:
206+
name: Release ${{ steps.get_version.outputs.VERSION }}
207+
body_path: release_notes.md
208+
files: |
209+
release/*
210+
draft: false
211+
prerelease: false
212+
generate_release_notes: true
213+
env:
214+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
215+
216+
- name: Release Summary
217+
run: |
218+
echo "## 🎉 Release ${{ steps.get_version.outputs.VERSION }} Created!" >> $GITHUB_STEP_SUMMARY
219+
echo "" >> $GITHUB_STEP_SUMMARY
220+
echo "### 📦 Binaries Built:" >> $GITHUB_STEP_SUMMARY
221+
echo "" >> $GITHUB_STEP_SUMMARY
222+
ls -lh release/ | grep -v "^total" | awk '{print "- " $9 " (" $5 ")"}' >> $GITHUB_STEP_SUMMARY
223+
echo "" >> $GITHUB_STEP_SUMMARY
224+
echo "### 🔗 Download:" >> $GITHUB_STEP_SUMMARY
225+
echo "https://github.com/cecil-the-coder/mcp-code-api/releases/tag/${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)