Deploy (manual) #54
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: 'Choose version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| 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: true | |
| type: boolean | |
| permissions: | |
| contents: write | |
| id-token: write # Required for OIDC trusted publishing | |
| 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' | |
| - 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 "react-native-iap bot" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - 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: Ensure npm CLI v11.5.1 or later (required for OIDC) | |
| run: npm install -g npm@latest | |
| - name: Publish to npm with OIDC trusted publishing | |
| run: | | |
| if [ "${{ github.event.inputs.tag }}" = "latest" ]; then | |
| npm publish --access public --provenance | |
| else | |
| npm publish --tag ${{ github.event.inputs.tag }} --access public --provenance | |
| 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 |