Skip to content

refactor: remove LeanSpec configuration and related files #173

refactor: remove LeanSpec configuration and related files

refactor: remove LeanSpec configuration and related files #173

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
force_publish:
description: 'Force publish packages even if versions match'
required: false
default: false
type: boolean
packages:
description: 'Specific packages to check (comma-separated: mcp,core,ai or leave empty for all)'
required: false
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
NODE_VERSION: 22
PNPM_VERSION: 10.15.0
jobs:
# Phase 1: Build and Test
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Generate cache key
id: cache-key
run: |
echo "key=${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-pnpm-
- name: Install dependencies
run: ./.github/scripts/setup-node.sh
- name: Build packages
run: ./.github/scripts/build-packages.sh
- name: Run tests
run: ./.github/scripts/run-tests.sh
- name: Cache build artifacts
uses: actions/cache@v4
with:
path: |
packages/*/build
packages/web/.next-build
key: build-${{ github.sha }}-${{ matrix.node-version }}
- name: Verify build artifacts
run: ./.github/scripts/verify-build.sh
# Phase 2: Docker Build (depends on build-and-test)
docker-build:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in 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=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: runner
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VCS_REF=${{ github.sha }}
- name: Test Docker image
run: |
# Get the first tag for testing
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
./.github/scripts/test-docker.sh "$IMAGE_TAG"
# Phase 4a: NPM Publish Stable (main branch)
npm-publish-stable:
name: Publish to NPM (Stable)
runs-on: ubuntu-latest
needs: build-and-test
if: |
github.ref == 'refs/heads/main' && (
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && contains(github.event.head_commit.message, '[publish]'))
)
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Restore pnpm cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ needs.build-and-test.outputs.cache-key }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: ./.github/scripts/setup-node.sh
- name: Restore build artifacts
uses: actions/cache@v4
with:
path: |
packages/*/build
packages/web/.next-build
key: build-${{ github.sha }}-20
- name: Check versions and determine what to publish
id: check_versions
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
./.github/scripts/check-versions.sh "${{ github.event.inputs.force_publish }}" "${{ github.event.inputs.packages }}"
- name: Publish packages
id: publish
if: steps.check_versions.outputs.has_packages_to_publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
./.github/scripts/publish-packages.sh "${{ steps.check_versions.outputs.packages_to_publish }}"
- name: Create summary
if: always()
run: |
echo "## 📦 NPM Publish Results (Stable)" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check_versions.outputs.has_packages_to_publish }}" == "true" ]; then
echo "### ✅ Successfully Published to latest tag" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.publish.outputs.published_packages }}" >> $GITHUB_STEP_SUMMARY
else
echo "### ℹ️ No Packages to Publish" >> $GITHUB_STEP_SUMMARY
echo "All package versions are up to date with npmjs.org" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
# Phase 4b: NPM Publish Dev (develop branch)
npm-publish-dev:
name: Publish to NPM (Dev)
runs-on: ubuntu-latest
needs: build-and-test
if: |
github.ref == 'refs/heads/develop' && (
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push'
)
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
- name: Restore pnpm cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ needs.build-and-test.outputs.cache-key }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: ./.github/scripts/setup-node.sh
- name: Restore build artifacts
uses: actions/cache@v4
with:
path: |
packages/*/build
packages/web/.next-build
key: build-${{ github.sha }}-20
- name: Bump to dev prerelease versions
id: bump_versions
run: |
./.github/scripts/bump-dev-versions.sh
- name: Publish dev packages
id: publish_dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
./.github/scripts/publish-dev-packages.sh
- name: Create summary
if: always()
run: |
echo "## 📦 NPM Publish Results (Dev)" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.publish_dev.outcome }}" == "success" ]; then
echo "### ✅ Successfully Published to dev tag" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.publish_dev.outputs.published_packages }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Install dev versions with:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "npm install @codervisor/devlog-core@dev" >> $GITHUB_STEP_SUMMARY
echo "npm install @codervisor/devlog-mcp@dev" >> $GITHUB_STEP_SUMMARY
echo "npm install @codervisor/devlog-ai@dev" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
else
echo "### ❌ Dev Publishing Failed" >> $GITHUB_STEP_SUMMARY
echo "Check the logs for details" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
# Final Summary Job
deployment-summary:
name: Deployment Summary
runs-on: ubuntu-latest
needs: [build-and-test, docker-build, npm-publish-stable, npm-publish-dev]
if: always() && github.event_name != 'pull_request'
steps:
- name: Generate comprehensive summary
run: |
echo "## 🚀 CI/CD Pipeline Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "**Timestamp:** $(date -u)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Job Status:" >> $GITHUB_STEP_SUMMARY
echo "- 🧪 **Build & Test:** ${{ needs.build-and-test.result }}" >> $GITHUB_STEP_SUMMARY
echo "- 🐳 **Docker Build:** ${{ needs.docker-build.result }}" >> $GITHUB_STEP_SUMMARY
echo "- 📦 **NPM Publish (Stable):** ${{ needs.npm-publish-stable.result }}" >> $GITHUB_STEP_SUMMARY
echo "- 🚧 **NPM Publish (Dev):** ${{ needs.npm-publish-dev.result }}" >> $GITHUB_STEP_SUMMARY