chore(release): publish to npm from release-please workflow (#13) #3
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: Release Please | |
| on: | |
| push: | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| release-please: | |
| name: Release PR + Publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| config-file: release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| - uses: actions/checkout@v4 | |
| if: ${{ steps.release.outputs.release_created }} | |
| - uses: pnpm/action-setup@v2 | |
| if: ${{ steps.release.outputs.release_created }} | |
| with: | |
| version: 10 | |
| - uses: actions/setup-node@v4 | |
| if: ${{ steps.release.outputs.release_created }} | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'pnpm' | |
| - name: Install | |
| if: ${{ steps.release.outputs.release_created }} | |
| run: pnpm install --frozen-lockfile | |
| - name: Check if version already published | |
| if: ${{ steps.release.outputs.release_created }} | |
| run: | | |
| VERSION="$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json','utf8')).version)")" | |
| if npm view "codebase-context@${VERSION}" version >/dev/null 2>&1; then | |
| echo "Version ${VERSION} already exists on npm; skipping publish." | |
| echo "SKIP_PUBLISH=true" >> "$GITHUB_ENV" | |
| else | |
| echo "Version ${VERSION} not found on npm; will publish." | |
| fi | |
| - name: Quality gates | |
| if: ${{ steps.release.outputs.release_created && env.SKIP_PUBLISH != 'true' }} | |
| run: | | |
| pnpm lint | |
| pnpm format:check | |
| pnpm type-check | |
| pnpm test | |
| pnpm build | |
| - name: Publish | |
| if: ${{ steps.release.outputs.release_created && env.SKIP_PUBLISH != 'true' }} | |
| run: pnpm publish --access public --no-git-checks | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |