Merge origin/master into 5.0 #278
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 & Release | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - "5.0" | |
| jobs: | |
| npm-publish: | |
| name: npm-publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| npm run build | |
| - id: check | |
| uses: EndBug/version-check@v2 | |
| with: | |
| file-name: package.json | |
| diff-search: true | |
| # master → @latest, stable GitHub release. | |
| # 5.0 → @next, pre-release GitHub release. | |
| - id: release | |
| run: | | |
| if [ "${{ github.ref_name }}" = "master" ]; then | |
| echo "npm_tag=latest" >> "$GITHUB_OUTPUT" | |
| echo "prerelease=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "npm_tag=next" >> "$GITHUB_OUTPUT" | |
| echo "prerelease=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish package on NPM 📦 | |
| if: steps.check.outputs.changed == 'true' | |
| run: npm publish --tag ${{ steps.release.outputs.npm_tag }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # Extract the latest CHANGELOG section (everything after the first | |
| # `## [x.y.z]` header, up to — but not including — the next `## [` | |
| # header) into RELEASE_NOTES.md so the GitHub release body mirrors it. | |
| - name: Extract CHANGELOG entry | |
| if: steps.check.outputs.changed == 'true' | |
| run: | | |
| awk ' | |
| /^## \[/ { | |
| if (found) { exit } | |
| found = 1 | |
| next | |
| } | |
| found { print } | |
| ' CHANGELOG.md > RELEASE_NOTES.md | |
| echo "--- RELEASE_NOTES.md ---" | |
| cat RELEASE_NOTES.md | |
| - name: Release | |
| if: steps.check.outputs.changed == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.check.outputs.version }} | |
| prerelease: ${{ steps.release.outputs.prerelease }} | |
| body_path: RELEASE_NOTES.md | |