name: Build and Publish Docker Image
on:
push:
branches: [main, develop]
tags: ['v*']
pull_request:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
name: Test and Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Type check
run: npm run typecheck
- name: Run tests
run: npm test
- name: Build
run: npm run build
docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: test
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker image
run: |
echo "Testing MCP server functionality..."
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | \
docker run --rm -i \
-e FLOAT_API_KEY="test_key" \
-e LOG_LEVEL="error" \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | \
jq -e '.result.tools | length > 0'
echo "✅ Docker image test passed"
release:
name: Create Release
runs-on: ubuntu-latest
needs: docker
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Install DXT CLI
run: npm install -g @anthropic-ai/dxt
- name: Create DXT package
run: dxt pack . float-mcp-${{ github.ref_name }}.dxt
- name: Extract version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract release notes
id: release_notes
run: |
version="${{ steps.version.outputs.VERSION }}"
awk -v version="$version" '
BEGIN { found=0; content="" }
/^## \[.*\] - / {
if (found) exit
if (match($0, /\[([^\]]+)\]/, arr) && arr[1] == version) found=1
next
}
/^## \[.*\] - / && found { exit }
found && !/^#/ {
if (content == "" && $0 == "") next
content = content $0 "\n"
}
END {
gsub(/\n+$/, "", content)
print content
}' CHANGELOG.md > release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: 'Release ${{ github.ref_name }}'
body_path: release-notes.md
files: |
float-mcp-${{ github.ref_name }}.dxt
draft: false
prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}