|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +This directory contains CI/CD workflows for the `@daichi-kudo/mcp-memory-sqlite` package. |
| 4 | + |
| 5 | +## 📁 Files |
| 6 | + |
| 7 | +- **`workflows/ci.yml`** - Continuous Integration workflow |
| 8 | +- **`workflows/release.yml`** - Release and npm publishing workflow |
| 9 | +- **`SETUP.md`** - Detailed setup instructions |
| 10 | +- **`PIPELINE_DIAGRAM.md`** - Visual pipeline diagrams |
| 11 | + |
| 12 | +## 🚀 Quick Start |
| 13 | + |
| 14 | +### Windows Users |
| 15 | + |
| 16 | +```cmd |
| 17 | +SETUP_COMMANDS.bat |
| 18 | +``` |
| 19 | + |
| 20 | +### Linux/macOS Users |
| 21 | + |
| 22 | +```bash |
| 23 | +bash SETUP_COMMANDS.sh |
| 24 | +``` |
| 25 | + |
| 26 | +This will: |
| 27 | +1. Install required development dependencies |
| 28 | +2. Update package.json with CI-friendly scripts |
| 29 | +3. Verify everything works locally |
| 30 | + |
| 31 | +## 📋 Manual Setup |
| 32 | + |
| 33 | +If you prefer to set up manually, follow these steps: |
| 34 | + |
| 35 | +### 1. Install Dependencies |
| 36 | + |
| 37 | +```bash |
| 38 | +npm install -D \ |
| 39 | + @typescript-eslint/eslint-plugin \ |
| 40 | + @typescript-eslint/parser \ |
| 41 | + eslint \ |
| 42 | + rimraf |
| 43 | +``` |
| 44 | + |
| 45 | +### 2. Update package.json |
| 46 | + |
| 47 | +Add these scripts to `package.json`: |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "scripts": { |
| 52 | + "typecheck": "tsc --noEmit", |
| 53 | + "lint": "eslint src --ext .ts && tsc --noEmit", |
| 54 | + "test": "echo \"No tests yet\" && exit 0", |
| 55 | + "test:ci": "npm run typecheck && npm run lint && npm run test", |
| 56 | + "clean": "rimraf dist", |
| 57 | + "prepublishOnly": "npm run clean && npm run build" |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +### 3. Configure npm Token |
| 63 | + |
| 64 | +1. Generate token at https://www.npmjs.com/settings/[username]/tokens |
| 65 | +2. Choose "Automation" type |
| 66 | +3. Copy the token |
| 67 | +4. Add to GitHub repository: |
| 68 | + - Settings → Secrets and variables → Actions |
| 69 | + - New repository secret: `NPM_TOKEN` |
| 70 | + |
| 71 | +### 4. Verify Locally |
| 72 | + |
| 73 | +```bash |
| 74 | +npm run typecheck # Should pass ✓ |
| 75 | +npm run lint # Should pass ✓ |
| 76 | +npm run build # Should create dist/ ✓ |
| 77 | +npm test # Should pass ✓ |
| 78 | +``` |
| 79 | + |
| 80 | +### 5. Commit and Push |
| 81 | + |
| 82 | +```bash |
| 83 | +git add . |
| 84 | +git commit -m "ci: add GitHub Actions workflows" |
| 85 | +git push origin master |
| 86 | +``` |
| 87 | + |
| 88 | +## 🔄 Workflows |
| 89 | + |
| 90 | +### CI Workflow (ci.yml) |
| 91 | + |
| 92 | +**Triggers:** |
| 93 | +- Push to `main` or `develop` |
| 94 | +- Pull requests to `main` or `develop` |
| 95 | + |
| 96 | +**Jobs:** |
| 97 | +1. Lint and type check |
| 98 | +2. Build package |
| 99 | +3. Test on multiple platforms (Ubuntu, Windows, macOS) with Node 20 & 22 |
| 100 | +4. Verify build artifacts are committed |
| 101 | + |
| 102 | +**Duration:** ~2-3 minutes |
| 103 | + |
| 104 | +### Release Workflow (release.yml) |
| 105 | + |
| 106 | +**Triggers:** |
| 107 | +- GitHub release published |
| 108 | +- Tags matching `v*` pattern |
| 109 | + |
| 110 | +**Steps:** |
| 111 | +1. Run full CI checks |
| 112 | +2. Build package |
| 113 | +3. Publish to npm with provenance |
| 114 | +4. Create release summary |
| 115 | + |
| 116 | +**Duration:** ~3-5 minutes |
| 117 | + |
| 118 | +## 📦 Publishing Releases |
| 119 | + |
| 120 | +### Create a Tag |
| 121 | + |
| 122 | +```bash |
| 123 | +git tag v1.0.0 |
| 124 | +git push origin v1.0.0 |
| 125 | +``` |
| 126 | + |
| 127 | +### Create GitHub Release (Recommended) |
| 128 | + |
| 129 | +1. Go to repository → Releases → Draft a new release |
| 130 | +2. Choose tag: v1.0.0 |
| 131 | +3. Add release notes: |
| 132 | + |
| 133 | +```markdown |
| 134 | +## What's New |
| 135 | +- Initial release |
| 136 | +- SQLite-based MCP memory server |
| 137 | +- WAL mode for concurrency |
| 138 | + |
| 139 | +## Installation |
| 140 | +npm install @daichi-kudo/mcp-memory-sqlite |
| 141 | +``` |
| 142 | + |
| 143 | +4. Click "Publish release" |
| 144 | + |
| 145 | +The workflow will automatically publish to npm! 🎉 |
| 146 | + |
| 147 | +## 🔍 Monitoring |
| 148 | + |
| 149 | +### View Workflow Runs |
| 150 | + |
| 151 | +1. Go to repository → Actions tab |
| 152 | +2. Click on a workflow run to see details |
| 153 | +3. Each job shows real-time logs |
| 154 | + |
| 155 | +### Check npm Package |
| 156 | + |
| 157 | +After release, verify at: |
| 158 | +- https://www.npmjs.com/package/@daichi-kudo/mcp-memory-sqlite |
| 159 | + |
| 160 | +## 🛠️ Troubleshooting |
| 161 | + |
| 162 | +### CI Fails: Type Errors |
| 163 | + |
| 164 | +```bash |
| 165 | +npm run typecheck # See errors locally |
| 166 | +# Fix errors |
| 167 | +npm run typecheck # Verify fixed |
| 168 | +``` |
| 169 | + |
| 170 | +### CI Fails: Lint Errors |
| 171 | + |
| 172 | +```bash |
| 173 | +npm run lint # See lint errors |
| 174 | +npm run lint -- --fix # Auto-fix |
| 175 | +``` |
| 176 | + |
| 177 | +### CI Fails: Build Check |
| 178 | + |
| 179 | +The build-check job fails if committed `dist/` doesn't match the build output. |
| 180 | + |
| 181 | +**Fix:** |
| 182 | +```bash |
| 183 | +npm run clean |
| 184 | +npm run build |
| 185 | +git add dist/ |
| 186 | +git commit -m "chore: update build artifacts" |
| 187 | +git push |
| 188 | +``` |
| 189 | + |
| 190 | +### Release Fails: npm Publish |
| 191 | + |
| 192 | +**Common causes:** |
| 193 | +1. NPM_TOKEN not set or invalid |
| 194 | +2. Package version already published |
| 195 | +3. Package name not available |
| 196 | +4. No publish permissions for `@daichi-kudo` scope |
| 197 | + |
| 198 | +**Solutions:** |
| 199 | +1. Verify NPM_TOKEN in GitHub secrets |
| 200 | +2. Bump version in package.json |
| 201 | +3. Check package availability on npm |
| 202 | +4. Verify npm scope access |
| 203 | + |
| 204 | +### better-sqlite3 Build Fails |
| 205 | + |
| 206 | +The native module should rebuild automatically. If it fails: |
| 207 | + |
| 208 | +1. Check Node.js version compatibility |
| 209 | +2. Verify platform has build tools (CI runners have them) |
| 210 | +3. Check better-sqlite3 documentation for platform support |
| 211 | + |
| 212 | +## 📊 Matrix Testing |
| 213 | + |
| 214 | +The CI workflow tests on 6 combinations: |
| 215 | + |
| 216 | +| OS | Node 20 | Node 22 | |
| 217 | +|----|---------|---------| |
| 218 | +| Ubuntu | ✅ | ✅ | |
| 219 | +| Windows | ✅ | ✅ | |
| 220 | +| macOS | ✅ | ✅ | |
| 221 | + |
| 222 | +This ensures the package works across all supported platforms. |
| 223 | + |
| 224 | +## 🔐 Security |
| 225 | + |
| 226 | +### npm Provenance |
| 227 | + |
| 228 | +The release workflow uses npm provenance, which: |
| 229 | +- Cryptographically links the package to the source code |
| 230 | +- Proves the package was built by GitHub Actions |
| 231 | +- Prevents tampering between build and publish |
| 232 | +- Improves supply chain security |
| 233 | + |
| 234 | +### Secret Management |
| 235 | + |
| 236 | +- NPM_TOKEN is stored as a GitHub secret |
| 237 | +- Never exposed in logs |
| 238 | +- Can be rotated without code changes |
| 239 | +- Scoped to publish permissions only |
| 240 | + |
| 241 | +## 📚 Additional Resources |
| 242 | + |
| 243 | +- [Detailed Setup Guide](SETUP.md) |
| 244 | +- [Pipeline Diagrams](PIPELINE_DIAGRAM.md) |
| 245 | +- [CI Setup Summary](../CI_SETUP_SUMMARY.md) |
| 246 | +- [Package.json Improvements](../PACKAGE_JSON_IMPROVEMENTS.md) |
| 247 | + |
| 248 | +## 🆘 Support |
| 249 | + |
| 250 | +If you encounter issues: |
| 251 | + |
| 252 | +1. Check the [Troubleshooting](#troubleshooting) section |
| 253 | +2. Review workflow logs in the Actions tab |
| 254 | +3. Consult the detailed guides in this directory |
| 255 | +4. Open an issue on GitHub |
| 256 | + |
| 257 | +--- |
| 258 | + |
| 259 | +**Happy CI/CD! 🚀** |
0 commit comments