Skip to content

Commit 55a44bc

Browse files
committed
ci: add create-release-pr workflow (#1849)
1 parent 165db42 commit 55a44bc

File tree

4 files changed

+160
-18
lines changed

4 files changed

+160
-18
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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+
rn_version:
8+
description: 'New React Native Version (e.g., 5.2.15 or 5.2.15-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+
rn_version:
24+
description: 'New React Native 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.rn_version }}
41+
42+
# React Native specific steps
43+
update-version:
44+
needs: prep
45+
runs-on: macos-latest
46+
outputs:
47+
rn_from: ${{ steps.current_versions.outputs.rn_from }}
48+
ios_from: ${{ steps.current_versions.outputs.ios_from }}
49+
android_from: ${{ steps.current_versions.outputs.android_from }}
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v5
54+
with:
55+
ref: ${{ needs.prep.outputs.release_branch }}
56+
57+
- name: Setup Bun
58+
uses: oven-sh/setup-bun@v2
59+
with:
60+
bun-version: latest
61+
62+
- name: Install
63+
run: bun install --frozen-lockfile
64+
65+
- name: Get current native SDK versions
66+
id: current_versions
67+
run: |
68+
# Current cordova version
69+
CURRENT_VERSION=$(jq -r .version package.json)
70+
71+
# Extract current Android SDK version
72+
ANDROID_VERSION=$(grep "api 'com.onesignal:OneSignal:" android/build.gradle | sed -E "s/.*OneSignal:([0-9.]+).*/\1/")
73+
74+
# Extract current iOS SDK version
75+
IOS_VERSION=$(grep "OneSignalXCFramework" react-native-onesignal.podspec | sed -E "s/.*'([0-9.]+)'.*/\1/")
76+
77+
echo "rn_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT
78+
echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT
79+
echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT
80+
81+
- name: Update Android SDK version
82+
if: inputs.android_version != ''
83+
run: |
84+
VERSION="${{ inputs.android_version }}"
85+
86+
# Validate version exists on GitHub
87+
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
88+
"https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
89+
90+
91+
if [ -z "$RELEASE" ]; then
92+
echo "✗ Android SDK version ${VERSION} not found"
93+
exit 1
94+
fi
95+
96+
# Update Android SDK version in build.gradle
97+
sed -i '' "s/api 'com.onesignal:OneSignal:[^']*'/api 'com.onesignal:OneSignal:$VERSION'/" android/build.gradle
98+
echo "✓ Updated android/build.gradle with Android SDK ${VERSION}"
99+
git add .
100+
101+
- name: Update iOS SDK version
102+
if: inputs.ios_version != ''
103+
run: |
104+
VERSION="${{ inputs.ios_version }}"
105+
106+
# Validate version exists on GitHub
107+
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
108+
"https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
109+
110+
if [ -z "$RELEASE" ]; then
111+
echo "✗ iOS SDK version ${VERSION} not found"
112+
exit 1
113+
fi
114+
115+
sed -i '' "s/s\.dependency 'OneSignalXCFramework', '[^']*'/s.dependency 'OneSignalXCFramework', '$VERSION'/" react-native-onesignal.podspec
116+
echo "✓ Updated react-native-onesignal.podspec with iOS SDK ${VERSION}"
117+
118+
# Update example
119+
bun link
120+
cd examples/RNOneSignalTS
121+
bun install
122+
cd ios
123+
pod update OneSignalXCFramework
124+
git add .
125+
126+
- name: Update sdk version
127+
run: |
128+
NEW_VERSION="${{ inputs.rn_version }}"
129+
git config user.name "github-actions[bot]"
130+
git config user.email "github-actions[bot]@users.noreply.github.com"
131+
132+
# Update package.json version & lockfile
133+
bun pm pkg set version="$NEW_VERSION"
134+
bun install
135+
136+
git add .
137+
git commit -m "Release $NEW_VERSION"
138+
git push
139+
140+
create-pr:
141+
needs: [prep, update-version]
142+
uses: OneSignal/sdk-actions/.github/workflows/create-release.yml@main
143+
with:
144+
release_branch: ${{ needs.prep.outputs.release_branch }}
145+
version_from: ${{ needs.update-version.outputs.rn_from }}
146+
version_to: ${{ inputs.rn_version }}
147+
android_from: ${{ needs.update-version.outputs.android_from }}
148+
android_to: ${{ inputs.android_version }}
149+
ios_from: ${{ needs.update-version.outputs.ios_from }}
150+
ios_to: ${{ inputs.ios_version }}

.github/workflows/npm_deploy.yml

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

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @OneSignal/eng-sdk-platform

0 commit comments

Comments
 (0)