Skip to content

Commit 9e4caa5

Browse files
authored
ci: add create-release-pr workflow (#1070)
1 parent 8521d71 commit 9e4caa5

File tree

5 files changed

+159
-250
lines changed

5 files changed

+159
-250
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Create Release PR
2+
3+
on:
4+
# For making a release pr from android / ios sdk actions
5+
workflow_call:
6+
inputs:
7+
flutter_version:
8+
description: "New Flutter SDK Version (e.g., 5.3.4 or 5.3.4-beta.1)"
9+
required: true
10+
type: string
11+
android_version:
12+
description: "New Android SDK Version (e.g., 2.3.0). Leave blank to skip."
13+
required: false
14+
type: string
15+
ios_version:
16+
description: "New iOS SDK Version (e.g., 1.5.0). Leave blank to skip."
17+
required: false
18+
type: string
19+
20+
# For making a release pr from cordova github actions
21+
workflow_dispatch:
22+
inputs:
23+
flutter_version:
24+
description: "New Flutter SDK Version (e.g., 5.2.15 or 5.2.15-beta.1)"
25+
required: true
26+
type: string
27+
android_version:
28+
description: "New Android SDK Version (e.g., 2.3.0). Leave blank to skip."
29+
required: false
30+
type: string
31+
ios_version:
32+
description: "New iOS SDK Version (e.g., 1.5.0). Leave blank to skip."
33+
required: false
34+
type: string
35+
36+
jobs:
37+
prep:
38+
uses: OneSignal/sdk-actions/.github/workflows/prep-release.yml@main
39+
with:
40+
version: ${{ inputs.flutter_version }}
41+
42+
update-version:
43+
needs: prep
44+
runs-on: macos-latest
45+
outputs:
46+
flutter_from: ${{ steps.current_versions.outputs.cordova_from }}
47+
android_from: ${{ steps.current_versions.outputs.android_from }}
48+
ios_from: ${{ steps.current_versions.outputs.ios_from }}
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v5
53+
with:
54+
ref: ${{ needs.prep.outputs.release_branch }}
55+
56+
- name: Get current native SDK versions
57+
id: current_versions
58+
run: |
59+
# Current flutter version
60+
CURRENT_VERSION=$(grep "^version:" pubspec.yaml | sed 's/version: //' | tr -d ' ')
61+
62+
# Extract current Android SDK version
63+
ANDROID_VERSION=$(sed -n "s/.*com\.onesignal:OneSignal:\([^']*\)'.*/\1/p" android/build.gradle)
64+
65+
# Extract current iOS SDK version
66+
IOS_VERSION=$(sed -n "s/.*OneSignalXCFramework', '\([^']*\)'.*/\1/p" ios/onesignal_flutter.podspec)
67+
68+
echo "flutter_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT
69+
echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT
70+
echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT
71+
72+
- name: Update Android SDK version
73+
if: inputs.android_version != ''
74+
run: |
75+
VERSION="${{ inputs.android_version }}"
76+
77+
# Validate version exists on GitHub
78+
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
79+
"https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
80+
81+
82+
if [ -z "$RELEASE" ]; then
83+
echo "✗ Android SDK version ${VERSION} not found"
84+
exit 1
85+
fi
86+
87+
# Update build.gradle with new version
88+
# macOS sed syntax
89+
sed -i '' "s|implementation 'com\.onesignal:OneSignal:[^']*'|implementation 'com.onesignal:OneSignal:${VERSION}'|" android/build.gradle
90+
echo "✓ Updated android/build.gradle with Android SDK ${VERSION}"
91+
92+
git add .
93+
94+
- name: Update iOS SDK version
95+
if: inputs.ios_version != ''
96+
run: |
97+
VERSION="${{ inputs.ios_version }}"
98+
99+
# Validate version exists on GitHub
100+
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
101+
"https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
102+
103+
if [ -z "$RELEASE" ]; then
104+
echo "✗ iOS SDK version ${VERSION} not found"
105+
exit 1
106+
fi
107+
108+
# Update onesignal_flutter.podspec with new version
109+
# macOS sed syntax
110+
sed -i '' "s|s.dependency 'OneSignalXCFramework', '[^']*'|s.dependency 'OneSignalXCFramework', '${VERSION}'|" ios/onesignal_flutter.podspec
111+
echo "✓ Updated ios/onesignal_flutter.podspec with iOS SDK ${VERSION}"
112+
113+
# Update ios example
114+
cd example/ios
115+
pod update OneSignalXCFramework
116+
117+
git add .
118+
119+
- name: Update sdk version
120+
run: |
121+
NEW_VERSION="${{ inputs.flutter_version }}"
122+
git config user.name "github-actions[bot]"
123+
git config user.email "github-actions[bot]@users.noreply.github.com"
124+
125+
# Convert version format for OneSignal wrapper (e.g., 5.2.15 -> 050215)
126+
# For pre-releases, extract base version first (e.g., 5.2.15-alpha.1 -> 5.2.15)
127+
BASE_VERSION=$(echo "$NEW_VERSION" | sed 's/-[a-z].*//')
128+
WRAPPER_VERSION=$(echo "$BASE_VERSION" | awk -F'.' '{printf "%02d%02d%02d", $1, $2, $3}')
129+
130+
# Update pubspec.yaml version
131+
sed -i '' "s/^version:.*/version: $NEW_VERSION/" pubspec.yaml
132+
echo "✓ Updated pubspec.yaml version to ${NEW_VERSION}"
133+
134+
# Update OneSignalPlugin.java wrapper version
135+
sed -i '' "s/OneSignalWrapper\.setSdkVersion(\"[^\"]*\")/OneSignalWrapper.setSdkVersion(\"$WRAPPER_VERSION\")/g" android/src/main/java/com/onesignal/flutter/OneSignalPlugin.java
136+
137+
# Update OneSignalPlugin.m wrapper version
138+
sed -i '' "s/OneSignalWrapper\.sdkVersion = @\"[^\"]*\"/OneSignalWrapper.sdkVersion = @\"$WRAPPER_VERSION\"/g" ios/Classes/OneSignalPlugin.m
139+
140+
git add .
141+
git commit -m "Release $NEW_VERSION"
142+
git push
143+
144+
create-pr:
145+
needs: [prep, update-version]
146+
uses: OneSignal/sdk-actions/.github/workflows/create-release.yml@main
147+
with:
148+
release_branch: ${{ needs.prep.outputs.release_branch }}
149+
version_from: ${{ needs.update-version.outputs.flutter_from }}
150+
version_to: ${{ inputs.flutter_version }}
151+
android_from: ${{ needs.update-version.outputs.android_from }}
152+
android_to: ${{ inputs.android_version }}
153+
ios_from: ${{ needs.update-version.outputs.ios_from }}
154+
ios_to: ${{ inputs.ios_version }}

.pubignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
example/
2+
build/
3+
test/
4+
**/local.properties
5+
test.json
-52.4 KB
Binary file not shown.

example/android/gradlew

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)