name: Publish to NPM (manual) # Fallback for manual publishing. The primary publish path is release.yml. # Use this for publishing beta/next tags or re-publishing a failed release. on: workflow_dispatch: inputs: tag: description: 'NPM dist-tag (latest, beta, next)' required: true default: 'latest' type: choice options: - latest - beta - next jobs: publish: name: Publish to NPM (${{ github.event.inputs.tag }}) runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '20.x' registry-url: 'https://registry.npmjs.org' cache: 'npm' - name: Install dependencies run: npm ci - name: Type check run: npm run type-check - name: Build run: npm run build - name: Unit & integration tests run: npm test - name: Verify build artifacts run: | test -f dist/index.js test -f dist/server.js test -d dist/frontend - name: Get version id: version run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT" - name: Check if version exists on NPM id: check run: | if npm view excalidraw-mcp-sentinel@${{ steps.version.outputs.version }} version 2>/dev/null; then echo "exists=true" >> "$GITHUB_OUTPUT" else echo "exists=false" >> "$GITHUB_OUTPUT" fi - name: Publish to NPM if: steps.check.outputs.exists == 'false' run: npm publish --tag ${{ github.event.inputs.tag }} --provenance --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Skip (version exists) if: steps.check.outputs.exists == 'true' run: | echo "⚠️ Version ${{ steps.version.outputs.version }} already on NPM" echo "Bump the version in package.json first" exit 1