Increase deps and package version (#33) #12
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 on npm | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - package.json | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| id-token: write | |
| jobs: | |
| build_and_publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linter | |
| run: npm run lint | |
| - name: Run tests | |
| run: npm test | |
| - name: Build | |
| run: npm run build | |
| - id: publish | |
| name: Publish to NPM | |
| uses: JS-DevTools/npm-publish@v3 | |
| with: | |
| token: ${{ secrets.NPM_TOKEN }} | |
| dry-run: false | |
| provenance: true | |
| access: public | |
| - name: Post-publish | |
| if: steps.publish.outputs.type != 'none' | |
| run: | | |
| echo "Published ${{ steps.publish.outputs.type }} version: ${{ steps.publish.outputs.version }}" | |
| - name: Publish skipped | |
| if: steps.publish.outputs.type == 'none' | |
| run: | | |
| echo "Version in package.json has not changed. Skipping." | |
| exit 0 | |
| - name: Configure changelog | |
| if: steps.publish.outputs.type != 'none' | |
| run: | | |
| echo '{"categories": [], "template": "## Commits:\n\n${{ '${{UNCATEGORIZED}}' }}", "pr_template": ${{ '"- ${{MERGE_SHA}} ${{TITLE}}"' }} }' > changelog_config.json | |
| echo "last_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV | |
| echo "curr_commit=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
| - name: Generate changelog | |
| if: steps.publish.outputs.type != 'none' | |
| id: github_release | |
| uses: mikepenz/release-changelog-builder-action@v2.9.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| fromTag: "${{ env.last_tag }}" | |
| toTag: ${{ github.ref }} | |
| commitMode: true | |
| configuration: changelog_config.json | |
| - name: Create release | |
| if: steps.publish.outputs.type != 'none' | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.publish.outputs.version }} | |
| release_name: v${{ steps.publish.outputs.version }} | |
| commitish: ${{ github.ref }} | |
| body: ${{ steps.github_release.outputs.changelog }} | |
| draft: false | |
| prerelease: false |