# 🚀 GitHub Release Guide

Complete guide for creating and managing GitHub releases for the Developer Onboarding MCP Server.

## 📋 Prerequisites

Before creating a release, ensure you have:

- [ ] GitHub repository with proper access permissions
- [ ] GitHub secrets configured (see [Secrets Setup](#secrets-setup))
- [ ] All features tested and documented
- [ ] Clean git working directory
- [ ] On main/master branch

## 🔑 Secrets Setup

Configure these secrets in GitHub repository settings:

```bash
# Settings → Secrets and variables → Actions → New repository secret

DOCKER_USERNAME=your-dockerhub-username
DOCKER_PASSWORD=your-dockerhub-token
NPM_TOKEN=your-npm-publish-token
```

### Getting NPM Token
1. Login to npmjs.com
2. Go to Access Tokens → Generate New Token
3. Choose "Automation" type
4. Copy token to GitHub secrets

### Getting Docker Hub Token
1. Login to hub.docker.com
2. Account Settings → Security → New Access Token
3. Choose appropriate permissions
4. Copy token to GitHub secrets

## 🚀 Creating a Release

### Method 1: Automated Release (Recommended)

```bash
# For patch release (1.0.0 → 1.0.1)
npm run release:patch

# For minor release (1.0.0 → 1.1.0)
npm run release:minor

# For major release (1.0.0 → 2.0.0)
npm run release:major
```

This will:
- ✅ Run tests and build
- ✅ Bump version
- ✅ Update CHANGELOG.md
- ✅ Create git tag
- ✅ Push to GitHub
- ✅ Trigger GitHub Actions workflow

### Method 2: Manual Release

```bash
# 1. Bump version manually
npm version patch  # or minor/major

# 2. Update CHANGELOG.md manually
# 3. Commit changes
git add .
git commit -m "chore: prepare release v1.0.1"

# 4. Create and push tag
git tag v1.0.1
git push origin main
git push origin v1.0.1
```

### Method 3: GitHub Actions Manual Trigger

1. Go to GitHub Actions → Release workflow
2. Click "Run workflow"
3. Enter version (e.g., v1.0.1)
4. Click "Run workflow"

## 🔄 Release Workflow

The GitHub Actions workflow will:

### 1. **🧪 Test Phase**
- Run all tests
- Check code linting
- Validate build process

### 2. **🏗️ Build Phase**
- Compile TypeScript
- Generate distribution files
- Create build artifacts

### 3. **📦 Package Creation**
- Create platform-specific packages:
  - `onboarding-mcp-v1.0.0-linux-x64.tar.gz`
  - `onboarding-mcp-v1.0.0-macos-x64.tar.gz`
  - `onboarding-mcp-v1.0.0-win-x64.zip`

### 4. **🐳 Docker Build**
- Build multi-architecture Docker image
- Push to Docker Hub with version tag
- Tag as `latest` if main branch

### 5. **🎉 GitHub Release**
- Create GitHub release with:
  - Generated changelog
  - Platform packages
  - Installation scripts
  - Documentation links

### 6. **📦 NPM Publish**
- Publish package to npm registry
- Available for global installation

## 📦 Release Assets

Each release includes:

### Distribution Packages
- **Linux**: `onboarding-mcp-v1.0.0-linux-x64.tar.gz`
- **macOS**: `onboarding-mcp-v1.0.0-macos-x64.tar.gz`
- **Windows**: `onboarding-mcp-v1.0.0-win-x64.zip`

### Installation Scripts
- **install.sh** - Unix/Linux/macOS installer
- **install.ps1** - Windows PowerShell installer

### Docker Image
- **Docker Hub**: `your-username/onboarding-mcp:v1.0.0`
- **Multi-arch**: linux/amd64, linux/arm64

### NPM Package
- **Registry**: `npm install -g developer-onboarding-mcp`

## 🎯 Release Types

### Patch Release (1.0.0 → 1.0.1)
- Bug fixes
- Security updates
- Documentation updates
- No breaking changes

### Minor Release (1.0.0 → 1.1.0)
- New features
- Improvements
- Backward compatible
- New tools or capabilities

### Major Release (1.0.0 → 2.0.0)
- Breaking changes
- API changes
- Major rewrites
- Requires migration guide

## 📝 Release Notes Template

```markdown
## 🚀 What's New in v1.0.0

### ✨ New Features
- 🎯 Role-based onboarding system
- 🧠 AI-powered explanations
- 📝 Interactive quizzes

### 🐛 Bug Fixes
- Fixed authentication issues
- Improved error handling

### 🔧 Improvements
- Better performance
- Enhanced documentation

### 📦 Installation
\`\`\`bash
# NPM Global Install
npm install -g developer-onboarding-mcp

# One-line install
curl -fsSL https://github.com/username/onboarding-mcp/releases/download/v1.0.0/install.sh | bash

# Docker
docker pull username/onboarding-mcp:v1.0.0
\`\`\`

### 🛠️ Available Tools
- identify-user-role
- learning-modules
- analyze-project
- track-progress
```

## 🚨 Troubleshooting

### Build Failures
```bash
# Check GitHub Actions logs
# Common issues:
- TypeScript compilation errors
- Missing dependencies
- Test failures
```

### Docker Push Failures
```bash
# Check Docker Hub credentials
# Verify DOCKER_USERNAME and DOCKER_PASSWORD secrets
```

### NPM Publish Failures
```bash
# Check NPM token permissions
# Verify package.json version is unique
# Check NPM_TOKEN secret
```

### Release Creation Failures
```bash
# Verify GitHub token permissions
# Check if tag already exists
# Ensure release assets exist
```

## 📊 Post-Release Checklist

- [ ] Verify GitHub release is created
- [ ] Check NPM package is available
- [ ] Confirm Docker image on Docker Hub
- [ ] Test installation methods
- [ ] Update documentation
- [ ] Announce release
- [ ] Monitor for issues

## 🔗 Useful Links

- [GitHub Releases Documentation](https://docs.github.com/en/repositories/releasing-projects-on-github)
- [Semantic Versioning](https://semver.org/)
- [Keep a Changelog](https://keepachangelog.com/)
- [GitHub Actions](https://docs.github.com/en/actions)
