chore: update readme #23
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: build and publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| bp: | |
| name: build and publish to npm | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check if version changed | |
| id: version-check | |
| run: | | |
| if git diff HEAD^ HEAD -- package.json | grep -q '"version"'; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node.js | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Setup pnpm | |
| if: steps.version-check.outputs.changed == 'true' | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: install | |
| if: steps.version-check.outputs.changed == 'true' | |
| run: pnpm install --frozen-lockfile | |
| - name: build and publish | |
| if: steps.version-check.outputs.changed == 'true' | |
| working-directory: ./ | |
| run: | | |
| pnpm build | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |