Merge pull request #4 from preshin/fix/number-leading-zeros-and-requi… #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: Publish to npm | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| # Only publish when the version in package.json changed | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Check if version changed | |
| id: version | |
| run: | | |
| LOCAL=$(node -p "require('./package.json').version") | |
| PUBLISHED=$(npm view react-formio-engine version 2>/dev/null || echo "0.0.0") | |
| echo "local=$LOCAL" >> $GITHUB_OUTPUT | |
| echo "published=$PUBLISHED" >> $GITHUB_OUTPUT | |
| if [ "$LOCAL" != "$PUBLISHED" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm | |
| if: steps.version.outputs.changed == 'true' | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Tag release | |
| if: steps.version.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git tag "v${{ steps.version.outputs.local }}" | |
| git push origin "v${{ steps.version.outputs.local }}" |