Deploy (manual) #94
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: | |
| # Pre-release validation jobs | |
| validate-android: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| env: | |
| GRADLE_OPTS: '-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError"' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Generate nitrogen code | |
| run: node .yarn/releases/yarn-3.6.1.cjs nitrogen | |
| - name: Install JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Accept Android SDK licenses | |
| run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses || true | |
| - name: Build Android library | |
| working-directory: example/android | |
| run: ./gradlew :react-native-iap:assembleDebug --stacktrace | |
| validate-ios: | |
| runs-on: macos-15 | |
| timeout-minutes: 60 | |
| env: | |
| XCODE_VERSION: 16.4 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Generate nitrogen code | |
| run: node .yarn/releases/yarn-3.6.1.cjs nitrogen | |
| - name: Set up Xcode | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: ${{ env.XCODE_VERSION }} | |
| - name: Cache Ruby gems | |
| uses: actions/cache@v4 | |
| with: | |
| path: example/vendor/bundle | |
| key: ${{ runner.os }}-ruby-${{ hashFiles('example/Gemfile.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-ruby- | |
| - name: Cache CocoaPods | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cocoapods/repos/trunk | |
| example/ios/Pods | |
| ~/Library/Caches/CocoaPods | |
| example/ios/build | |
| key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock', 'example/ios/Podfile') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pods- | |
| - name: Install Ruby dependencies | |
| working-directory: example | |
| run: bundle install | |
| - name: Install CocoaPods dependencies | |
| working-directory: example/ios | |
| run: | | |
| echo "Installing pods..." | |
| bundle exec pod install | |
| - name: Build iOS library | |
| working-directory: example/ios | |
| run: | | |
| set -o pipefail | |
| xcodebuild build \ | |
| -workspace example.xcworkspace \ | |
| -scheme example \ | |
| -destination 'generic/platform=iOS Simulator' \ | |
| -configuration Debug \ | |
| CODE_SIGNING_ALLOWED=NO \ | |
| COMPILER_INDEX_STORE_ENABLE=NO | |
| deploy: | |
| needs: [validate-android, validate-ios] | |
| 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: Disable Corepack | |
| run: corepack disable | |
| - name: Install dependencies (vendored Yarn) | |
| run: node .yarn/releases/yarn-3.6.1.cjs install --immutable | |
| - name: Lint | |
| run: | | |
| node .yarn/releases/yarn-3.6.1.cjs 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: node .yarn/releases/yarn-3.6.1.cjs 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 |