name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE: ${{ github.repository }}
jobs:
test:
name: Pre-release Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:coverage
- name: Build
run: npm run build:fast
build-mcpb:
name: Build MCPB Package
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install MCPB CLI
run: npm install -g @anthropic-ai/mcpb
- name: Build MCPB package
run: npm run mcpb:build
- name: Upload MCPB artifact
uses: actions/upload-artifact@v4
with:
name: mcpb-package
path: '*.mcpb'
retention-days: 1
publish-docker:
name: Publish Docker Image
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build:fast
- name: Publish to npm
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
# Check if version already exists on npm
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version 2>/dev/null; then
echo "Version ${PACKAGE_VERSION} already exists on npm, skipping publish"
else
echo "Publishing ${PACKAGE_NAME}@${PACKAGE_VERSION} to npm"
npm publish --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-mcpb, publish-docker, publish-npm]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download MCPB artifact
uses: actions/download-artifact@v4
with:
name: mcpb-package
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: '*.mcpb'
generate_release_notes: true
name: ${{ github.ref_name }}
body: |
See [Installation Options](https://github.com/${{ github.repository }}#installation) for setup instructions.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}