Merge pull request #9 from react-native-community/chore/release-0.1.6 #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] | |
| paths: | |
| - 'package.json' | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version_changed: ${{ steps.check.outputs.changed }} | |
| new_version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check if version changed | |
| id: check | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| PREVIOUS_VERSION=$(git show HEAD~1:package.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version") | |
| echo "current=$CURRENT_VERSION" | |
| echo "previous=$PREVIOUS_VERSION" | |
| if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Version changed: $PREVIOUS_VERSION -> $CURRENT_VERSION" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged: $CURRENT_VERSION" | |
| fi | |
| publish: | |
| needs: check-version | |
| if: needs.check-version.outputs.version_changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| package-manager-cache: false | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: npm run build | |
| - name: Publish to npm | |
| run: npm publish | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.new_version }} | |
| name: v${{ needs.check-version.outputs.new_version }} | |
| generate_release_notes: true |