deploy-mcpb.yml•5.47 kB
name: Deploy MCPB to apex-frontend
on:
push:
branches:
- main
paths:
- 'src/**'
- 'package.json'
- '.github/workflows/deploy-mcpb.yml'
workflow_dispatch:
inputs:
debug:
description: 'Enable debug logging'
required: false
default: 'false'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout apex-mcp repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build MCPB
run: npm run mcpb:build
- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Get MCPB file info
id: fileinfo
run: |
FILESIZE=$(stat -c%s apex-mcp.mcpb 2>/dev/null || stat -f%z apex-mcp.mcpb)
echo "filesize=$FILESIZE" >> $GITHUB_OUTPUT
echo "File size: $FILESIZE bytes"
- name: Checkout apex-frontend
uses: actions/checkout@v4
with:
repository: xonack/apex-frontend
token: ${{ secrets.FRONTEND_REPO_TOKEN }}
path: apex-frontend
ref: master
- name: Prepare downloads directory
working-directory: apex-frontend
run: |
mkdir -p public/downloads/versions
- name: Copy MCPB files
working-directory: apex-frontend
run: |
# Copy as latest version
cp ../apex-mcp.mcpb public/downloads/apex-mcp.mcpb
# Copy to versioned file
cp ../apex-mcp.mcpb public/downloads/versions/v${{ steps.version.outputs.version }}-apex-mcp.mcpb
echo "Files copied successfully"
- name: Update versions.json
working-directory: apex-frontend
run: |
# Create or update versions.json
if [ -f "public/downloads/versions.json" ]; then
# Read existing versions
EXISTING=$(cat public/downloads/versions.json)
else
# Initialize with empty array
EXISTING='{"versions":[]}'
fi
# Add new version entry
NEW_VERSION=$(cat <<EOF
{
"version": "${{ steps.version.outputs.version }}",
"filename": "v${{ steps.version.outputs.version }}-apex-mcp.mcpb",
"size": ${{ steps.fileinfo.outputs.filesize }},
"date": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"sha": "${{ github.sha }}"
}
EOF
)
# Update JSON with new version
echo "$EXISTING" | jq --argjson newVersion "$NEW_VERSION" '.versions = ([$newVersion] + .versions[0:9])' > public/downloads/versions.json
echo "Updated versions.json"
- name: List versions directory
if: ${{ inputs.debug == 'true' || github.event.inputs.debug == 'true' }}
working-directory: apex-frontend
run: |
echo "Contents of public/downloads/versions:"
ls -la public/downloads/versions/
echo "Contents of versions.json:"
cat public/downloads/versions.json | jq .
- name: Commit and push changes
working-directory: apex-frontend
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add public/downloads/
# Check if there are changes to commit
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Deploy apex-mcp v${{ steps.version.outputs.version }} MCPB
- Version: ${{ steps.version.outputs.version }}
- File size: ${{ steps.fileinfo.outputs.filesize }} bytes
- Source SHA: ${{ github.sha }}
- Deployed from: apex-mcp-stdio"
git push origin master
- name: Cleanup old versions
working-directory: apex-frontend
run: |
# Keep only the 10 most recent versions
cd public/downloads/versions
# Get all version files, sort by version number, keep only files to delete
ls -1 v*-apex-mcp.mcpb 2>/dev/null | sort -V -r | tail -n +11 | while read file; do
echo "Removing old version: $file"
rm "$file"
done || true
- name: Summary
run: |
echo "### MCPB Deployment Complete ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **File Size**: ${{ steps.fileinfo.outputs.filesize }} bytes" >> $GITHUB_STEP_SUMMARY
echo "- **Target Repo**: xonack/apex-frontend" >> $GITHUB_STEP_SUMMARY
echo "- **Download URL**: https://[your-domain]/downloads/apex-mcp.mcpb" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The MCPB file has been deployed and will be available after Vercel deployment completes." >> $GITHUB_STEP_SUMMARY