Skip to content

Commit 86cf777

Browse files
committed
use shared action for creating release PR
1 parent 47a2bd8 commit 86cf777

File tree

1 file changed

+178
-38
lines changed

1 file changed

+178
-38
lines changed
Lines changed: 178 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,65 @@
11
name: Create Unity Release PR
22

33
on:
4-
workflow_dispatch:
4+
# For making a release pr from android / ios sdk actions
5+
workflow_call:
56
inputs:
6-
bump_command:
7-
description: "Version bump type (major, minor, patch, specify)"
7+
unity_version:
8+
description: 'New Unity Version (e.g., 5.2.15 or 5.2.15-beta.1)'
89
required: true
9-
type: choice
10-
options:
11-
- major
12-
- minor
13-
- patch
14-
- specify
15-
postfix:
16-
description: "Optional postfix (e.g. preview, beta, or specific version when using 'specify')"
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.'
1717
required: false
1818
type: string
1919

20-
permissions:
21-
contents: write
22-
pull-requests: write
20+
# For making a release pr from github actions
21+
workflow_dispatch:
22+
inputs:
23+
unity_version:
24+
description: 'New Unity 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
2335

2436
jobs:
25-
compose-unity-release:
26-
name: Compose Unity Release
27-
runs-on: macos-latest
37+
prep:
38+
uses: OneSignal/sdk-actions/.github/workflows/prep-release.yml@main
39+
with:
40+
version: ${{ inputs.unity_version }}
2841

29-
env:
30-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
BUMP_COMMAND: ${{ github.event.inputs.bump_command }}
32-
POSTFIX: ${{ github.event.inputs.postfix }}
42+
# Unity specific steps
43+
update-version:
44+
needs: prep
45+
runs-on: macos-latest
46+
outputs:
47+
unity_from: ${{ steps.current_versions.outputs.unity_from }}
48+
ios_from: ${{ steps.current_versions.outputs.ios_from }}
49+
android_from: ${{ steps.current_versions.outputs.android_from }}
3350

3451
steps:
35-
- name: Checkout Repository
36-
uses: actions/checkout@v4
52+
- name: Checkout
53+
uses: actions/checkout@v5
3754
with:
38-
fetch-depth: 0
39-
fetch-tags: true
55+
ref: ${{ needs.prep.outputs.release_branch }}
4056

4157
- name: Prepare Environment
4258
run: |
4359
brew install gh jq || true
4460
gh auth status || gh auth login --with-token <<< "$GH_TOKEN"
4561
62+
# to save time, use cached Unity installation if available
4663
- name: Cache Unity
4764
uses: actions/cache@v4
4865
with:
@@ -51,32 +68,155 @@ jobs:
5168
restore-keys: |
5269
UnityEditor-${{ runner.os }}
5370
71+
# setup Unity using the version file
5472
- name: Setup Unity
5573
uses: buildalon/[email protected]
5674
with:
5775
version-file: 'OneSignalExample/ProjectSettings/ProjectVersion.txt'
5876

77+
# need to activate the Unity license to run Unity in batchmode; required for exportPackage
5978
- uses: buildalon/activate-unity-license@v2
6079
with:
6180
license: 'Personal'
6281
username: '${{ secrets.UNITY_USERNAME }}'
6382
password: '${{ secrets.UNITY_PASSWORD }}'
6483

65-
- name: 🏗️ Run composeRelease.sh
84+
- name: Get current native SDK versions
85+
id: current_versions
86+
run: |
87+
# Current cordova version
88+
CURRENT_VERSION=$(cat OneSignalExample/Assets/OneSignal/VERSION)
89+
90+
# Extract current Android SDK version
91+
ANDROID_VERSION=$(grep "api 'com.onesignal:OneSignal:" android/build.gradle | sed -E "s/.*OneSignal:([0-9.]+).*/\1/")
92+
93+
# Extract current iOS SDK version
94+
IOS_VERSION=$(grep "OneSignalXCFramework" react-native-onesignal.podspec | sed -E "s/.*'([0-9.]+)'.*/\1/")
95+
96+
echo "rn_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT
97+
echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT
98+
echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT
99+
100+
- name: Update Android SDK version
101+
if: inputs.android_version != ''
66102
run: |
67-
chmod +x ./composeRelease.sh
68-
if [[ -n "$POSTFIX" ]]; then
69-
./composeRelease.sh "$BUMP_COMMAND" "$POSTFIX" || echo "composeRelease.sh failed, continuing to patch manually"
70-
else
71-
./composeRelease.sh "$BUMP_COMMAND" || echo "composeRelease.sh failed, continuing to patch manually"
103+
VERSION="${{ inputs.android_version }}"
104+
105+
# Validate version exists on GitHub
106+
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
107+
"https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
108+
109+
if [ -z "$RELEASE" ]; then
110+
echo "✗ Android SDK version ${VERSION} not found"
111+
exit 1
72112
fi
73113
74-
- name: 🔍 Confirm PR Exists
114+
sed -i '' "s/spec='com.onesignal:OneSignal:[^']*'/spec='com.onesignal:OneSignal:$VERSION'/" com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml
115+
sed -i '' "s/spec='com.onesignal:OneSignal:[^']*'/spec='com.onesignal:OneSignal:$VERSION'/" OneSignalExample/Assets/Plugins/Android/mainTemplate.gradle
116+
sed -i '' "s/'com.onesignal:OneSignal:[^']*'/'com.onesignal:OneSignal:$VERSION'/" OneSignalExample/ProjectSettings/AndroidResolverDependencies.xml
117+
118+
echo "✓ Updated android/build.gradle with Android SDK ${VERSION}"
119+
git add .
120+
git commit -m "Bump Android SDK $NEW_VERSION"
121+
git push
122+
123+
- name: Update iOS SDK version
124+
if: inputs.android_version != ''
75125
run: |
76-
PR_URL=$(gh pr list --head "release/$VERSION" --json url --jq '.[0].url')
77-
if [[ -n "$PR_URL" ]]; then
78-
echo "✅ Release PR found: $PR_URL"
79-
else
80-
echo "⚠️ No PR found. composeRelease.sh should have created one."
81-
echo "If missing, create manually from release/$VERSION → main."
126+
VERSION="${{ inputs.android_version }}"
127+
128+
# Validate version exists on GitHub
129+
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
130+
"https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
131+
132+
if [ -z "$RELEASE" ]; then
133+
echo "✗ iOS SDK version ${VERSION} not found"
134+
exit 1
82135
fi
136+
137+
sed -i '' "s/version=\"[^']*'version=\"$VERSION'/" com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.xml
138+
139+
echo "✓ Updated react-native-onesignal.podspec with iOS SDK ${VERSION}"
140+
git add .
141+
git commit -m "Bump iOS SDK $NEW_VERSION"
142+
git push
143+
144+
- name: Update Unity SDK version
145+
run: |
146+
echo "Updating Unity SDK version to ${{ inputs.unity_version }}"
147+
148+
# Version string formats
149+
PADDED_VERSION=$(printf "%06d" $(echo "${{ inputs.unity_version }}" | sed 's/[^0-9]//g'))
150+
151+
# VERSION file
152+
echo "${{ inputs.unity_version }}" > OneSignalExample/Assets/OneSignal/VERSION
153+
154+
# package.json files
155+
for file in com.onesignal.unity.core/package.json com.onesignal.unity.android/package.json com.onesignal.unity.ios/package.json; do
156+
sed -i "s/\"version\": \".*\"/\"version\": \"${{ inputs.unity_version }}\"/" "$file"
157+
sed -i "s/\"com.onesignal.unity.core\": \".*\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/" "$file"
158+
done
159+
160+
sed -i "s/public const string Version = \".*\"/public const string Version = \"${{ inputs.unity_version }}\"/" \
161+
com.onesignal.unity.core/Runtime/OneSignal.cs
162+
sed -i "s/public const string VersionHeader = \".*\"/public const string VersionHeader = \"${PADDED_VERSION}\"/" \
163+
com.onesignal.unity.core/Runtime/OneSignalPlatform.cs
164+
165+
# asmdef files
166+
for asm in \
167+
OneSignalExample/Assets/OneSignal/Example/OneSignal.UnityPackage.Example.asmdef \
168+
OneSignalExample/Assets/OneSignal/Editor/OneSignal.UnityPackage.Editor.asmdef \
169+
OneSignalExample/Assets/OneSignal/Attribution/OneSignal.UnityPackage.Attribution.asmdef; do
170+
sed -i "s/\"expression\": \".*\"/\"expression\": \"${{ inputs.unity_version }}\"/" "$asm"
171+
done
172+
173+
# packages-lock.json
174+
sed -i "s/\"com.onesignal.unity.core\": \"[0-9.]\+\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/g" \
175+
OneSignalExample/Packages/packages-lock.json
176+
177+
# ProjectSettings.asset
178+
sed -i "s/bundleVersion: .*/bundleVersion: ${ { inputs.unity_version } }/" \
179+
OneSignalExample/ProjectSettings/ProjectSettings.asset
180+
181+
# iOS plugin version (UIApplication+OneSignalUnity.mm)
182+
sed -i "s/setSdkVersion:@\"[0-9]*\"/setSdkVersion:@\"${PADDED_VERSION}\"/" \
183+
com.onesignal.unity.ios/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm
184+
185+
- name: Run UpdateProjectVersion
186+
uses: buildalon/unity-action@v3
187+
with:
188+
project-path: OneSignalExample
189+
arguments: -quit -batchmode -nographics -buildTarget Android -executeMethod OneSignalSDK.OneSignalPackagePublisher.UpdateProjectVersion
190+
191+
192+
- name: Run ExportUnityPackage
193+
uses: buildalon/unity-action@v3
194+
with:
195+
project-path: OneSignalExample
196+
arguments: -quit -batchmode -nographics -buildTarget Android -executeMethod OneSignalSDK.OneSignalPackagePublisher.ExportUnityPackage
197+
198+
- name: Commit Release
199+
run: |
200+
git add .
201+
git commit -m "Release ${{ inputs.unity_version }}"
202+
git push
203+
204+
- name: Draft Release
205+
run: |
206+
package_path="OneSignalExample/OneSignal-v${{ inputs.unity_version }}.unitypackage"
207+
gh release create "${{ inputs.unity_version }}" "${package_path}"\
208+
--draft\
209+
--title "${{ inputs.unity_version }} Release"\
210+
--notes "TODO"
211+
212+
create-pr:
213+
needs: [prep, update-version]
214+
uses: OneSignal/sdk-actions/.github/workflows/create-release.yml@main
215+
with:
216+
release_branch: ${{ needs.prep.outputs.release_branch }}
217+
version_from: ${{ needs.update-version.outputs.rn_from }}
218+
version_to: ${{ inputs.rn_version }}
219+
android_from: ${{ needs.update-version.outputs.android_from }}
220+
android_to: ${{ inputs.android_version }}
221+
ios_from: ${{ needs.update-version.outputs.ios_from }}
222+
ios_to: ${{ inputs.ios_version }}

0 commit comments

Comments
 (0)