release: v1.5.1 (#47) #8
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 Package on Version Change | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| publish-if-version-changed: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if the package version has changed | |
| id: version_check | |
| uses: EndBug/version-check@v2 | |
| with: | |
| # Check the version in the root package.json file | |
| diff-search: true | |
| file-name: package.json | |
| - name: If the version has changed, continue with the following steps | |
| if: steps.version_check.outputs.changed == 'true' | |
| run: echo "The version has changed to ${{ steps.version_check.outputs.version }}. Proceeding to publish." | |
| - name: Setup node | |
| if: steps.version_check.outputs.changed == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.18.1' | |
| cache: 'npm' | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| if: steps.version_check.outputs.changed == 'true' | |
| run: npm ci | |
| - name: Publish to NPM | |
| if: steps.version_check.outputs.changed == 'true' | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |