Skip to content

Deployment & CI/CD #8

@ada-evorada

Description

@ada-evorada

Issue #10: Deployment & CI/CD

Epic: #1
Phase: 5 - Polish
Estimated Time: 2-3 days
Priority: Medium
Depends On: #2, #3, #9

Goal

Automated build, release, and deployment workflows for the Claude Code Mattermost plugin, including distribution via Mattermost Plugin Marketplace.

Tasks

1. GitHub Actions - Build Workflow

.github/workflows/build.yml:

name: Build Plugin

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: '1.21'
      
      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: '22'
      
      - name: Build plugin
        run: make build
      
      - name: Create bundle
        run: make bundle
      
      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: plugin-bundle
          path: dist/com.appsome.claudecode.tar.gz

2. GitHub Actions - Release Workflow

.github/workflows/release.yml:

name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: '1.21'
      
      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: '22'
      
      - name: Build for all platforms
        run: make build-all
      
      - name: Create bundles
        run: make bundle-all
      
      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          files: |
            dist/com.appsome.claudecode-linux-amd64.tar.gz
            dist/com.appsome.claudecode-darwin-amd64.tar.gz
            dist/com.appsome.claudecode-windows-amd64.tar.gz
          generate_release_notes: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

3. Multi-Platform Builds

Makefile targets:

.PHONY: build-all
build-all:
	@echo "Building for all platforms..."
	GOOS=linux GOARCH=amd64 go build -o server/dist/plugin-linux-amd64 ./server
	GOOS=darwin GOARCH=amd64 go build -o server/dist/plugin-darwin-amd64 ./server
	GOOS=windows GOARCH=amd64 go build -o server/dist/plugin-windows-amd64.exe ./server
	cd webapp && npm run build

.PHONY: bundle-all
bundle-all: build-all
	@echo "Creating platform-specific bundles..."
	mkdir -p dist
	tar -czf dist/com.appsome.claudecode-linux-amd64.tar.gz plugin.json server/dist/plugin-linux-amd64 webapp/dist
	tar -czf dist/com.appsome.claudecode-darwin-amd64.tar.gz plugin.json server/dist/plugin-darwin-amd64 webapp/dist
	tar -czf dist/com.appsome.claudecode-windows-amd64.tar.gz plugin.json server/dist/plugin-windows-amd64.exe webapp/dist

4. Semantic Versioning

Version Management:

  • Use semver (MAJOR.MINOR.PATCH)
  • Automate version bumping
  • Update plugin.json version on release

.github/workflows/version-bump.yml:

name: Version Bump

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'Version type (major, minor, patch)'
        required: true
        default: 'patch'

jobs:
  bump:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Bump version
        run: |
          current=$(jq -r '.version' plugin.json)
          new=$(npx semver $current -i ${{ github.event.inputs.version }})
          jq ".version = \"$new\"" plugin.json > tmp.json
          mv tmp.json plugin.json
      
      - name: Commit and tag
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add plugin.json
          git commit -m "chore: bump version to $(jq -r '.version' plugin.json)"
          git tag -a "v$(jq -r '.version' plugin.json)" -m "Release v$(jq -r '.version' plugin.json)"
          git push origin main --tags

5. Plugin Marketplace Submission

Marketplace Listing (marketplace.yaml):

name: Claude Code
description: Integrate Claude Code AI assistant directly in Mattermost
homepage_url: https://github.com/appsome/claude-code-mattermost-plugin
icon_path: assets/icon.png
release_notes_url: https://github.com/appsome/claude-code-mattermost-plugin/releases
support_url: https://github.com/appsome/claude-code-mattermost-plugin/issues

maintainer_name: Appsome
maintainer_url: https://github.com/appsome

labels:
  - ai
  - development
  - code

Submission Process:

  1. Create plugin marketplace PR
  2. Include plugin.yaml, icon, screenshots
  3. Pass Mattermost review
  4. Get published

6. Bridge Server Deployment

Docker Image:

# bridge-server/Dockerfile
FROM node:22-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --production

COPY dist ./dist

EXPOSE 3002

CMD ["node", "dist/index.js"]

Docker Compose (for production):

# docker-compose.prod.yml
version: '3.8'

services:
  bridge-server:
    build:
      context: ./bridge-server
      dockerfile: Dockerfile
    ports:
      - "3002:3002"
    environment:
      - NODE_ENV=production
      - DATABASE_PATH=/data/sessions.db
      - CLAUDE_CODE_PATH=/usr/local/bin/claude-code
    volumes:
      - bridge-data:/data
    restart: unless-stopped

volumes:
  bridge-data:

7. Installation Documentation

docs/INSTALLATION.md:

# Installation Guide

## Prerequisites
- Mattermost Server 9.0+
- Claude Code CLI installed
- (Optional) Bridge server for multi-user setups

## Method 1: Mattermost Marketplace (Recommended)

1. Log in to Mattermost as System Admin
2. Go to **System Console****Plugins****Marketplace**
3. Search for "Claude Code"
4. Click **Install**
5. Configure settings (see Configuration section)
6. Enable the plugin

## Method 2: Manual Installation

### Download Latest Release
```bash
wget https://github.com/appsome/claude-code-mattermost-plugin/releases/latest/download/com.appsome.claudecode.tar.gz

Upload Plugin

  1. System ConsolePluginsManagement
  2. Click Upload Plugin
  3. Select the .tar.gz file
  4. Click Upload
  5. Enable the plugin

Configure Plugin

  1. System ConsolePluginsClaude Code
  2. Set Bridge Server URL (default: http://localhost:3002)
  3. Set Claude Code CLI Path (default: /usr/local/bin/claude-code)
  4. Click Save

Bridge Server Setup (Optional)

For multi-user deployments:

git clone https://github.com/appsome/claude-code-mattermost-plugin
cd bridge-server
npm install
npm run build
npm start

Or use Docker:

docker-compose -f docker-compose.prod.yml up -d

Verification

  1. Open any Mattermost channel
  2. Type /claude-help
  3. You should see the help message

### 8. Update Mechanism

**Auto-update Support:**
- Plugin updates via Marketplace
- Bridge server update script

```bash
#!/bin/bash
# scripts/update-bridge.sh
cd bridge-server
git pull origin main
npm install
npm run build
pm2 restart claude-code-bridge

9. Health Checks

Bridge Server Health Endpoint:

// bridge-server/src/health.ts
app.get('/health', (req, res) => {
  const health = {
    status: 'ok',
    version: process.env.npm_package_version,
    uptime: process.uptime(),
    sessions: sessionManager.getSessionCount(),
    timestamp: new Date().toISOString(),
  };
  res.json(health);
});

Plugin Health Check:

// server/health.go
func (p *Plugin) GetHealthStatus() *model.PluginStatus {
    // Check bridge server connectivity
    healthy := p.bridgeClient.IsHealthy()
    
    return &model.PluginStatus{
        PluginId: manifest.Id,
        Status:   healthy,
    }
}

10. Monitoring & Logging

Prometheus Metrics (Bridge Server):

import { register, Counter, Histogram } from 'prom-client';

const sessionCounter = new Counter({
  name: 'claude_code_sessions_total',
  help: 'Total number of sessions created',
});

const messageHistogram = new Histogram({
  name: 'claude_code_message_duration_seconds',
  help: 'Message processing time',
});

app.get('/metrics', (req, res) => {
  res.set('Content-Type', register.contentType);
  res.send(register.metrics());
});

Acceptance Criteria

  • Automated builds for all platforms (Linux, macOS, Windows)
  • GitHub releases created on version tags
  • Plugin marketplace listing submitted
  • Installation documentation complete
  • Bridge server Docker image available
  • Health check endpoints implemented
  • Update mechanism documented
  • Monitoring/logging configured
  • CI/CD pipeline fully automated
  • Release process documented

Related Issues

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions