name: Release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify tag is on main branch
run: |
# Get the commit SHA the tag points to
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }})
echo "Tag commit: $TAG_COMMIT"
# Check if this commit is on main branch
if git branch -r --contains $TAG_COMMIT | grep -q 'origin/main'; then
echo "Tag is on main branch - proceeding with release"
else
echo "::error::Release tags must be created from the main branch!"
echo "::error::This tag points to a commit that is not on main."
echo "::error::Please merge your changes to main first, then create the tag."
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Run linting
run: npm run lint
- name: Build project
run: npm run build
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Update MCPB manifest version
run: |
TAG_VERSION="${{ steps.version.outputs.VERSION }}"
# Update version in manifest.json using node
node -e "
const fs = require('fs');
const manifest = JSON.parse(fs.readFileSync('mcpb/manifest.json', 'utf8'));
manifest.version = '$TAG_VERSION';
fs.writeFileSync('mcpb/manifest.json', JSON.stringify(manifest, null, 2) + '\n');
console.log('Updated manifest.json version to: $TAG_VERSION');
"
- name: Build MCPB package
run: npm run build:mcpb
- name: Rename MCPB with version
run: |
TAG_VERSION="${{ steps.version.outputs.VERSION }}"
mv mcpb/todoist-mcp.mcpb mcpb/todoist-mcp-v${TAG_VERSION}.mcpb
echo "MCPB_FILE=mcpb/todoist-mcp-v${TAG_VERSION}.mcpb" >> $GITHUB_OUTPUT
id: mcpb
- name: Update package.json version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION="${{ steps.version.outputs.VERSION }}"
if [ "$CURRENT_VERSION" != "$TAG_VERSION" ]; then
npm version $TAG_VERSION --no-git-tag-version
else
echo "Version already matches tag version: $TAG_VERSION"
fi
- name: Publish to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.version.outputs.VERSION }}
body: |
## Changes in v${{ steps.version.outputs.VERSION }}
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for full details.
## Installation
### NPM (CLI)
```bash
npm install -g @greirson/mcp-todoist@${{ steps.version.outputs.VERSION }}
```
### Claude Desktop (MCPB)
Download `todoist-mcp-v${{ steps.version.outputs.VERSION }}.mcpb` below and double-click to install, or drag and drop onto Claude Desktop.
files: |
${{ steps.mcpb.outputs.MCPB_FILE }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}