Migrate to Prettier 3 with JavaScript module format #7
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 | |
| jobs: | |
| publish-npm: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get package version | |
| id: package-version | |
| uses: martinbeentjes/[email protected] | |
| - name: Setup node environment | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' # Always use latest LTS version | |
| registry-url: https://registry.npmjs.org | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Publish to NPM | |
| run: npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
| - name: Collect release notes | |
| id: collect-release-notes | |
| run: | | |
| echo "::group::Prepare release notes" | |
| RELEASE_NOTES=$(awk -v ver=${{ steps.package-version.outputs.current-version }} '/^## \[/ { if ($2 == "["ver"]") { p=1 } else { p=0 } } p { print }' CHANGELOG.md | tail -n +3) | |
| echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
| echo "$RELEASE_NOTES" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "::endgroup::" | |
| - name: Create Release Tag | |
| id: create-release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.package-version.outputs.current-version }} | |
| body: ${{ env.RELEASE_NOTES }} | |
| token: ${{ secrets.GITHUB_TOKEN }} |