remove resources and modified write and essential tags #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to NPM | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.19.0' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Check if version changed | |
| id: version-check | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| PUBLISHED_VERSION=$(npm view @cognitionai/metabase-mcp-server version 2>/dev/null || echo "0.0.0") | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "published=$PUBLISHED_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$PUBLISHED_VERSION" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Version changed: $PUBLISHED_VERSION -> $CURRENT_VERSION" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged: $CURRENT_VERSION" | |
| fi | |
| - name: Publish to NPM | |
| if: steps.version-check.outputs.changed == 'true' | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.COGNITION_NPM_TOKEN }} | |
| - name: Create Git tag | |
| if: steps.version-check.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git tag "v${{ steps.version-check.outputs.current }}" | |
| git push origin "v${{ steps.version-check.outputs.current }}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Skip publishing | |
| if: steps.version-check.outputs.changed == 'false' | |
| run: echo "Skipping publish - version ${{ steps.version-check.outputs.current }} already published" |