11name : Create Unity Release PR
22
33on :
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
2436jobs :
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
58+ env :
59+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4260 run : |
4361 brew install gh jq || true
4462 gh auth status || gh auth login --with-token <<< "$GH_TOKEN"
4563
64+ # to save time, use cached Unity installation if available
4665 - name : Cache Unity
4766 uses : actions/cache@v4
4867 with :
@@ -51,32 +70,155 @@ jobs:
5170 restore-keys : |
5271 UnityEditor-${{ runner.os }}
5372
73+ # setup Unity using the version file
5474 - name : Setup Unity
55755676 with :
5777 version-file : ' OneSignalExample/ProjectSettings/ProjectVersion.txt'
5878
79+ # need to activate the Unity license to run Unity in batchmode; required for exportPackage
5980 - uses : buildalon/activate-unity-license@v2
6081 with :
6182 license : ' Personal'
6283 username : ' ${{ secrets.UNITY_USERNAME }}'
6384 password : ' ${{ secrets.UNITY_PASSWORD }}'
6485
65- - name : 🏗️ Run composeRelease.sh
86+ - name : Get current native SDK versions
87+ id : current_versions
88+ run : |
89+ # Current Unity version
90+ CURRENT_VERSION=$(cat OneSignalExample/Assets/OneSignal/VERSION | tr -d '\n\r' | xargs)
91+
92+ # Extract current Android SDK version
93+ ANDROID_VERSION=$(grep -oE 'spec="com.onesignal:OneSignal:[0-9.]+"' com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml | grep -oE '[0-9.]+' | head -1)
94+
95+ # Extract current iOS SDK version
96+ IOS_VERSION=$(grep -oE 'version="[0-9.]+"' com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.xml | grep -oE '[0-9.]+' | head -1)
97+
98+ echo "unity_from=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
99+ echo "android_from=${ANDROID_VERSION}" >> $GITHUB_OUTPUT
100+ echo "ios_from=${IOS_VERSION}" >> $GITHUB_OUTPUT
101+
102+ - name : Update Android SDK version
103+ if : inputs.android_version != ''
66104 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"
105+ VERSION="${{ inputs.android_version }}"
106+
107+ # Validate version exists on GitHub
108+ RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
109+ "https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
110+
111+ if [ -z "$RELEASE" ]; then
112+ echo "✗ Android SDK version ${VERSION} not found"
113+ exit 1
72114 fi
73115
74- - name : 🔍 Confirm PR Exists
116+ sed -i '' "s/spec=\"com.onesignal:OneSignal:[0-9.]\+\"/spec=\"com.onesignal:OneSignal:$VERSION\"/" com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml
117+ sed -i '' "s/'com.onesignal:OneSignal:[0-9.]\+'/'com.onesignal:OneSignal:$VERSION'/" OneSignalExample/Assets/Plugins/Android/mainTemplate.gradle
118+ sed -i '' "s/<package>com.onesignal:OneSignal:[0-9.]\+<\/package>/<package>com.onesignal:OneSignal:$VERSION<\/package>/" OneSignalExample/ProjectSettings/AndroidResolverDependencies.xml
119+
120+ echo "✓ Updated Android SDK to ${VERSION}"
121+ git add .
122+ git commit -m "Bump Android SDK $VERSION"
123+ git push
124+
125+ - name : Update iOS SDK version
126+ if : inputs.ios_version != ''
75127 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."
128+ VERSION="${{ inputs.ios_version }}"
129+
130+ # Validate version exists on GitHub
131+ RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
132+ "https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
133+
134+ if [ -z "$RELEASE" ]; then
135+ echo "✗ iOS SDK version ${VERSION} not found"
136+ exit 1
82137 fi
138+
139+ sed -i '' "s/version=\"[0-9.]\+\"/version=\"$VERSION\"/" com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.xml
140+
141+ echo "✓ Updated iOS SDK to ${VERSION}"
142+ git add .
143+ git commit -m "Bump iOS SDK $VERSION"
144+ git push
145+
146+ - name : Update Unity SDK version
147+ run : |
148+ echo "Updating Unity SDK version to ${{ inputs.unity_version }}"
149+
150+ # Version string formats
151+ PADDED_VERSION=$(printf "%06d" $(echo "${{ inputs.unity_version }}" | sed 's/[^0-9]//g'))
152+
153+ # VERSION file
154+ echo "${{ inputs.unity_version }}" > OneSignalExample/Assets/OneSignal/VERSION
155+
156+ # package.json files
157+ for file in com.onesignal.unity.core/package.json com.onesignal.unity.android/package.json com.onesignal.unity.ios/package.json; do
158+ sed -i "s/\"version\": \".*\"/\"version\": \"${{ inputs.unity_version }}\"/" "$file"
159+ sed -i "s/\"com.onesignal.unity.core\": \".*\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/" "$file"
160+ done
161+
162+ sed -i "s/public const string Version = \".*\"/public const string Version = \"${{ inputs.unity_version }}\"/" \
163+ com.onesignal.unity.core/Runtime/OneSignal.cs
164+ sed -i "s/public const string VersionHeader = \".*\"/public const string VersionHeader = \"${PADDED_VERSION}\"/" \
165+ com.onesignal.unity.core/Runtime/OneSignalPlatform.cs
166+
167+ # asmdef files
168+ for asm in \
169+ OneSignalExample/Assets/OneSignal/Example/OneSignal.UnityPackage.Example.asmdef \
170+ OneSignalExample/Assets/OneSignal/Editor/OneSignal.UnityPackage.Editor.asmdef \
171+ OneSignalExample/Assets/OneSignal/Attribution/OneSignal.UnityPackage.Attribution.asmdef; do
172+ sed -i "s/\"expression\": \".*\"/\"expression\": \"${{ inputs.unity_version }}\"/" "$asm"
173+ done
174+
175+ # packages-lock.json
176+ sed -i "s/\"com.onesignal.unity.core\": \"[0-9.]\+\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/g" \
177+ OneSignalExample/Packages/packages-lock.json
178+
179+ # ProjectSettings.asset
180+ sed -i "s/bundleVersion: .*/bundleVersion: ${ { inputs.unity_version } }/" \
181+ OneSignalExample/ProjectSettings/ProjectSettings.asset
182+
183+ # iOS plugin version (UIApplication+OneSignalUnity.mm)
184+ sed -i "s/setSdkVersion:@\"[0-9]*\"/setSdkVersion:@\"${PADDED_VERSION}\"/" \
185+ com.onesignal.unity.ios/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm
186+
187+ - name : Run UpdateProjectVersion
188+ uses : buildalon/unity-action@v3
189+ with :
190+ project-path : OneSignalExample
191+ arguments : -quit -batchmode -nographics -buildTarget Android -executeMethod OneSignalSDK.OneSignalPackagePublisher.UpdateProjectVersion
192+
193+
194+ - name : Run ExportUnityPackage
195+ uses : buildalon/unity-action@v3
196+ with :
197+ project-path : OneSignalExample
198+ arguments : -quit -batchmode -nographics -buildTarget Android -executeMethod OneSignalSDK.OneSignalPackagePublisher.ExportUnityPackage
199+
200+ - name : Commit Release
201+ run : |
202+ git add .
203+ git commit -m "Release ${{ inputs.unity_version }}"
204+ git push
205+
206+ - name : Draft Release
207+ run : |
208+ package_path="OneSignalExample/OneSignal-v${{ inputs.unity_version }}.unitypackage"
209+ gh release create "${{ inputs.unity_version }}" "${package_path}"\
210+ --draft\
211+ --title "${{ inputs.unity_version }} Release"\
212+ --notes "TODO"
213+
214+ create-pr :
215+ needs : [prep, update-version]
216+ uses : OneSignal/sdk-actions/.github/workflows/create-release.yml@main
217+ with :
218+ release_branch : ${{ needs.prep.outputs.release_branch }}
219+ version_from : ${{ needs.update-version.outputs.unity_from }}
220+ version_to : ${{ inputs.unity_version }}
221+ android_from : ${{ needs.update-version.outputs.android_from }}
222+ android_to : ${{ inputs.android_version }}
223+ ios_from : ${{ needs.update-version.outputs.ios_from }}
224+ ios_to : ${{ inputs.ios_version }}
0 commit comments