Merge branch 'refs/heads/v1.3.0' #15
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: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24.x" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Ensure npm supports trusted publishing | |
| run: npm i -g npm@11.5.1 | |
| - name: Install dependencies | |
| run: npm ci | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_READ_TOKEN }} | |
| - name: Build | |
| run: npm run build | |
| - name: Check Version | |
| id: check-version | |
| run: | | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| NPM_VERSION=$(npm view react-native-lab version 2>/dev/null || echo "0.0.0") | |
| echo "Package Version: $PACKAGE_VERSION" | |
| echo "NPM Version: $NPM_VERSION" | |
| if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then | |
| echo "New version detected. Proceeding with publish." | |
| echo "IS_NEW_VERSION=true" >> $GITHUB_ENV | |
| else | |
| echo "Version $PACKAGE_VERSION already exists on NPM. Skipping publish." | |
| echo "IS_NEW_VERSION=false" >> $GITHUB_ENV | |
| fi | |
| - name: Publish to NPM (OIDC) | |
| if: env.IS_NEW_VERSION == 'true' | |
| run: npm publish --access public |