Deploy (manual) #44
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: Deploy (manual) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version or semver (e.g., 3.2.0 | patch | minor | major)' | |
| required: true | |
| type: string | |
| tag: | |
| description: 'npm dist-tag to publish under' | |
| required: true | |
| default: latest | |
| type: choice | |
| options: | |
| - latest | |
| - next | |
| create_release: | |
| description: 'Also create a GitHub Release from the tag' | |
| required: false | |
| default: false | |
| type: boolean | |
| git_user_name: | |
| description: 'Git author name for release commit' | |
| required: false | |
| default: 'react-native-iap bot' | |
| type: string | |
| git_user_email: | |
| description: 'Git author email for release commit' | |
| required: false | |
| default: 'github-actions[bot]@users.noreply.github.com' | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| registry-url: 'https://registry.npmjs.org' | |
| always-auth: true | |
| - name: Enable Corepack (Yarn 3) | |
| run: corepack enable | |
| - name: Use Yarn 3 cache dir | |
| id: yarn_cache | |
| run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" | |
| - name: Restore Yarn cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.yarn_cache.outputs.dir }} | |
| key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| yarn-${{ runner.os }}- | |
| - name: Install dependencies | |
| run: yarn install --immutable | |
| - name: Lint | |
| run: | | |
| yarn lint:tsc | |
| npx eslint --ext .ts,.tsx,.js,.jsx src plugin/src | |
| - name: Configure Git user | |
| run: | | |
| git config user.name "${{ github.event.inputs.git_user_name }}" | |
| git config user.email "${{ github.event.inputs.git_user_email }}" | |
| - name: Bump version and tag | |
| id: bump | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| run: | | |
| # Yarn 3 uses corepack-managed npm; ensure git tagging commit is created | |
| npm version "$INPUT_VERSION" --tag-version-prefix="" -m "chore(release): %s" | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Prepare package (build + codegen) | |
| run: yarn prepare | |
| - name: Push commit and tags | |
| run: | | |
| git push --follow-tags | |
| - name: Configure npm auth | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | |
| - name: Verify npm auth | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm whoami | |
| - name: Publish to npm | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| if [ "${{ github.event.inputs.tag }}" = "latest" ]; then | |
| npm publish | |
| else | |
| npm publish --tag ${{ github.event.inputs.tag }} | |
| fi | |
| - name: Create GitHub Release | |
| if: ${{ github.event.inputs.create_release == 'true' }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.bump.outputs.version }} | |
| name: ${{ steps.bump.outputs.version }} | |
| draft: false | |
| prerelease: ${{ github.event.inputs.tag != 'latest' }} | |
| generate_release_notes: true |