Create Release PR #11
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: Create Release PR | |
| on: | |
| # For making a release pr from android / ios sdk actions | |
| workflow_call: | |
| secrets: | |
| GH_PUSH_TOKEN: | |
| required: false | |
| description: 'GitHub token for pushing changes' | |
| inputs: | |
| rn_version: | |
| description: 'New React Native Version (e.g., 5.2.15 or 5.2.15-beta.1)' | |
| required: true | |
| type: string | |
| android_version: | |
| description: 'New Android SDK Version (e.g., 2.3.0). Leave blank to skip.' | |
| required: false | |
| type: string | |
| ios_version: | |
| description: 'New iOS SDK Version (e.g., 1.5.0). Leave blank to skip.' | |
| required: false | |
| type: string | |
| target_branch: | |
| description: 'Target branch to create the release PR on. Defaults to main.' | |
| required: false | |
| type: string | |
| default: main | |
| # For making a release pr from the github actions | |
| workflow_dispatch: | |
| inputs: | |
| rn_version: | |
| description: 'New React Native Version (e.g., 5.2.15 or 5.2.15-beta.1)' | |
| required: true | |
| type: string | |
| android_version: | |
| description: 'New Android SDK Version (e.g., 2.3.0). Leave blank to skip.' | |
| required: false | |
| type: string | |
| ios_version: | |
| description: 'New iOS SDK Version (e.g., 1.5.0). Leave blank to skip.' | |
| required: false | |
| type: string | |
| target_branch: | |
| description: 'Target branch to create the release PR on. Defaults to main.' | |
| required: false | |
| type: string | |
| default: main | |
| jobs: | |
| prep: | |
| uses: OneSignal/sdk-shared/.github/workflows/prep-release.yml@main | |
| secrets: | |
| # Need this cross-repo token (sdk-shared & this repo) to perform changes | |
| GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} | |
| with: | |
| target_repo: OneSignal/react-native-onesignal | |
| version: ${{ inputs.rn_version }} | |
| # React Native specific steps | |
| update_version: | |
| needs: prep | |
| runs-on: macos-latest | |
| outputs: | |
| rn_from: ${{ steps.current_versions.outputs.rn_from }} | |
| ios_from: ${{ steps.current_versions.outputs.ios_from }} | |
| android_from: ${{ steps.current_versions.outputs.android_from }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| # Need repository otherwise caller would set github.repository to the caller itself (e.g. sdk-shared) | |
| repository: OneSignal/react-native-onesignal | |
| ref: ${{ needs.prep.outputs.release_branch }} | |
| token: ${{ secrets.GH_PUSH_TOKEN || github.token }} | |
| - name: Setup Git User | |
| uses: OneSignal/sdk-shared/.github/actions/setup-git-user@main | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install | |
| run: bun install --frozen-lockfile | |
| - name: Get current native SDK versions from target branch | |
| id: current_versions | |
| run: | | |
| git fetch origin ${{ inputs.target_branch }} | |
| # Get versions from target branch (not the release branch) | |
| CURRENT_VERSION=$(git show origin/${{ inputs.target_branch }}:package.json | jq -r .version) | |
| ANDROID_VERSION=$(git show origin/${{ inputs.target_branch }}:android/build.gradle | grep "com.onesignal:OneSignal:" | sed -E "s/.*OneSignal:([0-9.]+).*/\1/") | |
| IOS_VERSION=$(git show origin/${{ inputs.target_branch }}:react-native-onesignal.podspec | grep "OneSignalXCFramework" | sed -E "s/.*'([0-9.]+)'.*/\1/") | |
| echo "rn_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT | |
| echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT | |
| - name: Update Android SDK version | |
| if: inputs.android_version != '' | |
| run: | | |
| VERSION="${{ inputs.android_version }}" | |
| # Validate version exists on GitHub | |
| RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
| "https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}") | |
| if [ -z "$RELEASE" ]; then | |
| echo "✗ Android SDK version ${VERSION} not found" | |
| exit 1 | |
| fi | |
| # Update Android SDK version in build.gradle (handles both api '...' and api('...') syntax) | |
| sed -i '' -E "s/(com\.onesignal:OneSignal:)[0-9.]+/\1$VERSION/" android/build.gradle | |
| echo "✓ Updated android/build.gradle with Android SDK ${VERSION}" | |
| # Only commit if there are changes | |
| git add -A | |
| git diff --staged --quiet && exit 0 | |
| git commit -m "Update Android SDK to ${VERSION}" && git push | |
| - name: Update iOS SDK version | |
| if: inputs.ios_version != '' | |
| run: | | |
| VERSION="${{ inputs.ios_version }}" | |
| # Validate version exists on GitHub | |
| RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
| "https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}") | |
| if [ -z "$RELEASE" ]; then | |
| echo "✗ iOS SDK version ${VERSION} not found" | |
| exit 1 | |
| fi | |
| sed -i '' "s/s\.dependency 'OneSignalXCFramework', '[^']*'/s.dependency 'OneSignalXCFramework', '$VERSION'/" react-native-onesignal.podspec | |
| echo "✓ Updated react-native-onesignal.podspec with iOS SDK ${VERSION}" | |
| # Only commit if there are changes | |
| git add -A | |
| git diff --staged --quiet && exit 0 | |
| git commit -m "Update iOS SDK to ${VERSION}" && git push | |
| - name: Update sdk version | |
| run: | | |
| NEW_VERSION="${{ inputs.rn_version }}" | |
| # Update package.json version | |
| bun pm pkg set version="$NEW_VERSION" | |
| # Only commit if there are changes | |
| git add -A | |
| git diff --staged --quiet && exit 0 | |
| git commit -m "Release $NEW_VERSION" && git push | |
| create-pr: | |
| needs: [prep, update_version] | |
| uses: OneSignal/sdk-shared/.github/workflows/create-release.yml@main | |
| secrets: | |
| # Need this cross-repo token (sdk-shared & this repo) to perform changes | |
| GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} | |
| with: | |
| # Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-shared) | |
| target_repo: OneSignal/react-native-onesignal | |
| release_branch: ${{ needs.prep.outputs.release_branch }} | |
| target_branch: ${{ inputs.target_branch }} | |
| android_from: ${{ needs.update_version.outputs.android_from }} | |
| android_to: ${{ inputs.android_version }} | |
| ios_from: ${{ needs.update_version.outputs.ios_from }} | |
| ios_to: ${{ inputs.ios_version }} |