Skip to content

Publish to NPM

Publish to NPM #2

Workflow file for this run

name: Publish to NPM
on:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Extract version from tag
id: get_version
run: |
# Extract version from GitHub release tag (e.g., "v1.2.3" -> "1.2.3")
RELEASE_TAG="${{ github.event.release.tag_name }}"
VERSION=${RELEASE_TAG#v} # Remove 'v' prefix if present
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Release tag: $RELEASE_TAG"
echo "Extracted version: $VERSION"
- name: Update package.json version
run: |
npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Publish to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Verify publication
run: |
sleep 10
npm view tradingview-mcp-server@${{ steps.get_version.outputs.version }} version