name: Release
on:
push:
branches:
- release
paths:
- 'packages/mcp-server/package.json'
- 'packages/*/src/**'
- 'packages/*/package.json'
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
should-publish: ${{ steps.check.outputs.should-publish }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if version changed
id: check
run: |
CURRENT_VERSION=$(node -p "require('./packages/mcp-server/package.json').version")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Check if this version already exists as a git tag
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
echo "Version v$CURRENT_VERSION already published"
echo "should-publish=false" >> $GITHUB_OUTPUT
else
echo "New version v$CURRENT_VERSION detected"
echo "should-publish=true" >> $GITHUB_OUTPUT
fi
publish:
needs: check-version
if: needs.check-version.outputs.should-publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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: Lint
run: npm run lint
- name: Type check
run: npm run typecheck
- name: Build
run: npm run build
- name: Run tests
run: npm test
- name: Publish to npm
working-directory: packages/mcp-server
run: |
VERSION=${{ needs.check-version.outputs.version }}
# Determine npm tag based on version
if [[ "$VERSION" == *"alpha"* ]]; then
NPM_TAG="alpha"
elif [[ "$VERSION" == *"beta"* ]]; then
NPM_TAG="beta"
elif [[ "$VERSION" == *"rc"* ]]; then
NPM_TAG="rc"
else
NPM_TAG="latest"
fi
echo "Publishing version $VERSION with tag $NPM_TAG"
npm publish --tag $NPM_TAG --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Git tag
if: success()
run: |
VERSION=${{ needs.check-version.outputs.version }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
- name: Create GitHub Release
if: success()
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.check-version.outputs.version }}
release_name: v${{ needs.check-version.outputs.version }}
body: |
Release v${{ needs.check-version.outputs.version }}
See [CHANGELOG.md](https://github.com/inchankang/zettel-memory/blob/main/CHANGELOG.md) for details.
## Installation
```bash
npm install -g @inchankang/zettel-memory@${{ needs.check-version.outputs.version }}
```
## Usage
```bash
npx @inchankang/zettel-memory --vault ~/my-vault
```
draft: false
prerelease: ${{ contains(needs.check-version.outputs.version, 'alpha') || contains(needs.check-version.outputs.version, 'beta') || contains(needs.check-version.outputs.version, 'rc') }}