feat: add concurrency control to getEntityInfo #9
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 | |
| jobs: | |
| publish: | |
| name: Build and Publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build package | |
| run: yarn build | |
| - name: Check version and publish | |
| id: publish | |
| run: | | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| # Handle potential failure if package is new | |
| PUBLISHED_VERSION=$(npm view $PACKAGE_NAME version 2>/dev/null || echo "0.0.0") | |
| # Use node to compare semver versions | |
| IS_NEWER=$(node -p "require('semver').gt('$CURRENT_VERSION', '$PUBLISHED_VERSION')") | |
| if [ "$IS_NEWER" = "true" ]; then | |
| echo "New version detected: $CURRENT_VERSION (Registry: $PUBLISHED_VERSION)" | |
| echo "Publishing to NPM..." | |
| npm publish --access public --provenance | |
| else | |
| echo "Version $CURRENT_VERSION is not newer than registry ($PUBLISHED_VERSION). Skipping." | |
| fi |