Reformat package.json before publishing #7
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 | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| jobs: | |
| publish: | |
| if: github.event.pull_request.merged == true && (contains(github.event.pull_request.labels.*.name, 'patch') || contains(github.event.pull_request.labels.*.name, 'minor') || contains(github.event.pull_request.labels.*.name, 'major')) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24.x | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build:release | |
| - name: Determine version bump | |
| id: version | |
| run: | | |
| if ${{ contains(github.event.pull_request.labels.*.name, 'major') }}; then | |
| echo "bump=major" >> $GITHUB_OUTPUT | |
| elif ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}; then | |
| echo "bump=minor" >> $GITHUB_OUTPUT | |
| else | |
| echo "bump=patch" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Bump version | |
| run: npm version ${{ steps.version.outputs.bump }} --no-git-tag-version | |
| - name: Fix formatting | |
| run: npm run lint:fix | |
| - name: Commit and push | |
| run: | | |
| git add . | |
| git commit -m "chore: release v$(node -p "require('./package.json').version")" | |
| git tag "v$(node -p "require('./package.json').version")" | |
| git push | |
| git push --tags | |
| - name: Publish to npm | |
| run: npm publish --provenance --access public |