release 2.4.0 #6
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: | |
| push: | |
| branches: [master, main] | |
| paths: | |
| - package.json | |
| jobs: | |
| version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| changed: ${{ steps.check.outputs.changed }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 2 # last 2 commits | |
| - name: check version change | |
| id: check | |
| run: | | |
| PREV_VERSION=$(git show HEAD^:package.json | jq -r .version) | |
| CURR_VERSION=$(jq -r .version package.json) | |
| echo "Previous: $PREV_VERSION" | |
| echo "Current: $CURR_VERSION" | |
| if [ "$PREV_VERSION" != "$CURR_VERSION" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| echo "version=$CURR_VERSION" >> $GITHUB_OUTPUT | |
| build: | |
| needs: version | |
| if: needs.version.outputs.changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| - uses: actions/checkout@v6 | |
| - run: npm ci | |
| - run: npm test | |
| release: | |
| needs: [build, version] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # needed to create tags and releases | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # fetch all tags | |
| - id: tag-check | |
| run: | | |
| TAG="v${{ needs.version.outputs.version }}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Git tag and push | |
| if: steps.tag-check.outputs.exists == 'false' | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git tag v${{ needs.version.outputs.version }} | |
| git push origin v${{ needs.version.outputs.version }} | |
| - name: Create GitHub Release | |
| if: steps.tag-check.outputs.exists == 'false' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.version.outputs.version }} | |
| name: ${{ needs.version.outputs.version }} | |
| generate_release_notes: false | |
| publish: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| registry-url: https://registry.npmjs.org/ | |
| - run: npm ci | |
| - run: npm publish --provenance |