Workflow file for this run
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 useMultiTabDetection to NPM | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| scope: "@tabbridge" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test --if-present | |
| continue-on-error: false | |
| - name: Build package | |
| run: npm run build --if-present | |
| - name: Check if version already published | |
| id: check-version | |
| run: | | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then | |
| echo "Version $PACKAGE_VERSION already exists on NPM" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version $PACKAGE_VERSION not yet published" | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to NPM | |
| if: steps.check-version.outputs.skip == 'false' | |
| run: npm publish --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create package tarball | |
| if: steps.check-version.outputs.skip == 'false' | |
| run: npm pack | |
| - name: Upload package to release | |
| if: steps.check-version.outputs.skip == 'false' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: "*.tgz" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Skip publishing | |
| if: steps.check-version.outputs.skip == 'true' | |
| run: echo "Skipping publish - version already exists on NPM" |