Merge pull request #6 from feed-mob/codex/improve-postinstall-guidance #4
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: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: npm-publish-main | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 11 | |
| run_install: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Test | |
| run: pnpm test | |
| - name: Build | |
| run: pnpm build | |
| - name: Check package version | |
| id: package | |
| shell: bash | |
| run: | | |
| package_name="$(node -p "require('./package.json').name")" | |
| package_version="$(node -p "require('./package.json').version")" | |
| echo "name=$package_name" >> "$GITHUB_OUTPUT" | |
| echo "version=$package_version" >> "$GITHUB_OUTPUT" | |
| if npm view "$package_name@$package_version" version >/dev/null 2>&1; then | |
| echo "published=true" >> "$GITHUB_OUTPUT" | |
| echo "$package_name@$package_version is already published; skipping npm publish." | |
| else | |
| echo "published=false" >> "$GITHUB_OUTPUT" | |
| echo "$package_name@$package_version is not published yet." | |
| fi | |
| - name: Publish | |
| if: steps.package.outputs.published == 'false' | |
| run: npm publish --access public |