Create Release PR #30
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: | |
| inputs: | |
| cordova_version: | |
| description: 'New Cordova 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 | |
| #For making a release pr from cordova github actions. | |
| workflow_dispatch: | |
| inputs: | |
| cordova_version: | |
| description: 'New Cordova 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 | |
| jobs: | |
| prep: | |
| uses: OneSignal/sdk-actions/.github/workflows/prep-release.yml@main | |
| with: | |
| version: ${{ inputs.cordova_version }} | |
| # Cordova specific steps | |
| update-version: | |
| needs: prep | |
| runs-on: macos-latest | |
| outputs: | |
| cordova_from: ${{ steps.current_versions.outputs.cordova_from }} | |
| android_from: ${{ steps.current_versions.outputs.android_from }} | |
| ios_from: ${{ steps.current_versions.outputs.ios_from }} | |
| steps: | |
| - name: Debug | |
| run: | | |
| echo "release_branch: ${{ needs.prep.outputs.release_branch }}" | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ needs.prep.outputs.release_branch }} | |
| - 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 | |
| id: current_versions | |
| run: | | |
| # Current cordova version | |
| CURRENT_VERSION=$(jq -r .version package.json) | |
| # Extract current Android SDK version | |
| ANDROID_VERSION=$(sed -n 's/.*com\.onesignal:OneSignal:\([0-9.]*\).*/\1/p' plugin.xml | head -1) | |
| # Extract current iOS SDK version | |
| IOS_VERSION=$(sed -n 's/.*OneSignalXCFramework.*spec="\([0-9.]*\)".*/\1/p' plugin.xml | head -1) | |
| echo "cordova_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT | |
| echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT | |
| - name: Setup Capacitor | |
| run: | | |
| bun link | |
| cd example/IonicCapOneSignal | |
| bun install --frozen-lockfile | |
| bun run build | |
| - 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 sed -n '/\"id\"/p' <<< "$RELEASE" | grep -q .; then | |
| # Update plugin.xml with new version | |
| # mac os sed syntax | |
| sed -i '' 's|<framework src="com\.onesignal:OneSignal:[^"]*" />|<framework src="com.onesignal:OneSignal:'"$VERSION"'" />|' plugin.xml | |
| echo "✓ Updated plugin.xml with Android SDK ${VERSION}" | |
| cd example/IonicCapOneSignal | |
| bunx cap sync android | |
| git add . | |
| else | |
| echo "✗ Android SDK version ${VERSION} not found" | |
| exit 1 | |
| fi | |
| - 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 sed -n '/\"id\"/p' <<< "$RELEASE" | grep -q .; then | |
| # Update plugin.xml with new version | |
| # mac os sed syntax | |
| sed -i '' "s|<pod name=\"OneSignalXCFramework\" spec=\"[^\"]*\" />|<pod name=\"OneSignalXCFramework\" spec=\"${VERSION}\" />|" plugin.xml | |
| echo "✓ Updated plugin.xml with iOS SDK ${VERSION}" | |
| # Need to regenerate the Podfile.lock | |
| cd example/IonicCapOneSignal/ios/App | |
| rm -f Podfile.lock | |
| cd ../.. | |
| bunx cap sync ios | |
| git add . | |
| else | |
| echo "✗ iOS SDK version ${VERSION} not found" | |
| exit 1 | |
| fi | |
| - name: Update sdk version | |
| run: | | |
| NEW_VERSION="${{ inputs.cordova_version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Convert version format for OneSignal wrapper (e.g., 5.2.15 -> 050215) | |
| # For pre-releases, extract base version first (e.g., 5.2.15-alpha.1 -> 5.2.15) | |
| BASE_VERSION=$(echo "$NEW_VERSION" | sed 's/-[a-z].*//') | |
| WRAPPER_VERSION=$(echo "$BASE_VERSION" | awk -F'.' '{printf "%02d%02d%02d", $1, $2, $3}') | |
| # Update package.json version | |
| npm pkg set version="$NEW_VERSION" | |
| # Update plugin.xml cordova plugin version (target <plugin> element specifically) | |
| sed -i '' '/<plugin/,/>/ { s/version="[^"]*"/version="'"$NEW_VERSION"'"/; }' plugin.xml | |
| # Update OneSignalPush.java wrapper version | |
| sed -i '' "s/OneSignalWrapper\.setSdkVersion(\"[^\"]*\")/OneSignalWrapper.setSdkVersion(\"$WRAPPER_VERSION\")/g" src/android/com/onesignal/cordova/OneSignalPush.java | |
| # Update OneSignalPush.m wrapper version | |
| sed -i '' "s/OneSignalWrapper\.sdkVersion = @\"[^\"]*\"/OneSignalWrapper.sdkVersion = @\"$WRAPPER_VERSION\"/g" src/ios/OneSignalPush.m | |
| git add package.json plugin.xml src/android/com/onesignal/cordova/OneSignalPush.java src/ios/OneSignalPush.m | |
| git commit -m "Release $NEW_VERSION" | |
| git push | |
| create-pr: | |
| needs: [prep, update-version] | |
| uses: OneSignal/sdk-actions/.github/workflows/create-release.yml@main | |
| with: | |
| release_branch: ${{ needs.prep.outputs.release_branch }} | |
| version_from: ${{ needs.update-version.outputs.cordova_from }} | |
| version_to: ${{ inputs.cordova_version }} | |
| 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 }} |