name: Publish to JSR
on:
release:
types: [created]
workflow_dispatch:
inputs:
dry-run:
description: 'Perform a dry run (do not actually publish)'
required: false
type: boolean
default: false
permissions:
contents: read
id-token: write
jobs:
publish-jsr:
name: Publish to JSR Registry
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
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
run_install: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm run test:coverage
env:
CLOCKIFY_API_KEY: test-key-12345678
- name: Build package
run: pnpm run build
- name: Setup Deno for JSR
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Verify JSR configuration
run: |
if [ -f "jsr.json" ]; then
echo "β
JSR configuration found"
cat jsr.json
else
echo "β jsr.json not found - creating default"
exit 1
fi
- name: Publish to JSR (dry run)
if: github.event.inputs.dry-run == 'true'
run: pnpm dlx jsr publish --dry-run
- name: Publish to JSR
if: github.event.inputs.dry-run != 'true'
run: pnpm dlx jsr publish
- name: Get package info
if: github.event.inputs.dry-run != 'true'
id: package-info
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
JSR_SCOPE=$(node -p "require('./jsr.json').name.split('/')[0]")
JSR_NAME=$(node -p "require('./jsr.json').name.split('/')[1]")
{
echo "npm-name=${PACKAGE_NAME}"
echo "version=${PACKAGE_VERSION}"
echo "jsr-scope=${JSR_SCOPE}"
echo "jsr-name=${JSR_NAME}"
} >> "$GITHUB_OUTPUT"
- name: Update GitHub release with JSR info
if: github.event_name == 'release' && github.event.inputs.dry-run != 'true'
uses: actions/github-script@v7
with:
script: |
const { data: release } = await github.rest.repos.getRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: context.payload.release.id
});
const jsrScope = '${{ steps.package-info.outputs.jsr-scope }}';
const jsrName = '${{ steps.package-info.outputs.jsr-name }}';
const version = '${{ steps.package-info.outputs.version }}';
const updatedBody = release.body + `
## π¦ JSR Publication
**JSR Package**: \`${jsrScope}/${jsrName}@${version}\`
### Installation via JSR
\`\`\`bash
# Using Deno
deno add ${jsrScope}/${jsrName}
# Using Node.js with JSR
npx jsr add ${jsrScope}/${jsrName}
\`\`\`
### Documentation
View on JSR: https://jsr.io/${jsrScope}/${jsrName}
`;
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: context.payload.release.id,
body: updatedBody
});
notify-success:
name: Notify JSR Success
runs-on: ubuntu-latest
needs: publish-jsr
if: success() && github.event.inputs.dry-run != 'true'
steps:
- name: Notify JSR deployment success
run: |
echo "β
Successfully published Clockify Master MCP to JSR!"
echo "π¦ Available on both NPM and JSR registries"
echo "π JSR provides better TypeScript support and documentation"