Skip to content

Publish NPM Package #59

Publish NPM Package

Publish NPM Package #59

Workflow file for this run

name: Publish NPM Package
on:
workflow_dispatch:
inputs:
channel:
required: true
type: choice
description: NPM tag to publish the package to
options:
- oldversion
- alpha
- beta
- latest
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./mcp-server
steps:
- uses: actions/checkout@v4
with:
# PR context: build from PR head; workflow_dispatch: build from triggered ref (e.g. release/x.y.z)
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Validate release branch for latest channel
if: github.event.inputs.channel == 'latest'
run: |
if [[ ! "${{ github.ref }}" =~ ^refs/(heads|tags)/release/ ]]; then
echo "Error: Publishing to 'latest' channel requires a release/* branch or tag"
echo "Current ref: ${{ github.ref }}"
exit 1
fi
- uses: actions/setup-node@v4
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
- name: Extract package version
id: extract_version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
- name: Update npm to support Trusted Publishing
run: npm install -g npm@latest
- run: npm ci
- name: Publish to NPM
run: |
git config user.name "Currents NPM Bot"
git config user.email "npm@currents.dev"
npm run publish:mcp -- -- --tag ${{ github.event.inputs.channel }}
- name: Mark Linear release as complete
id: release
if: success() && github.event.inputs.channel == 'latest'
uses: linear/linear-release-action@v0
with:
access_key: ${{ secrets.LINEAR_ACCESS_KEY }}
command: complete
version: ${{ steps.extract_version.outputs.package_version }}
- name: Post to Slack
if: success() && github.event.inputs.channel == 'latest' && steps.release.outputs.release-url
uses: slackapi/slack-github-action@v2
with:
webhook: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": "🚀 Release: @currents/mcp@${{ steps.extract_version.outputs.package_version }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*🚀Release: @currents/mcp@${{ steps.extract_version.outputs.package_version }}* has been marked as complete in Linear.\n\n<${{ steps.release.outputs.release-url }}|View Release Notes>"
}
}
]
}