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,159 @@ 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]+\.[0-9]+\.[0-9]+"' com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml | sed -E 's/.*OneSignal:([0-9]+\.[0-9]+\.[0-9]+)".*/\1/' | 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+ echo " unity_from: ${CURRENT_VERSION}"
103+ echo " android_from: ${ANDROID_VERSION}"
104+ echo " ios_from: ${IOS_VERSION}"
105+
106+ - name : Update Android SDK version
107+ if : inputs.android_version != ''
66108 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"
109+ VERSION="${{ inputs.android_version }}"
110+
111+ # Validate version exists on GitHub
112+ RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
113+ "https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
114+
115+ if [ -z "$RELEASE" ]; then
116+ echo "✗ Android SDK version ${VERSION} not found"
117+ exit 1
72118 fi
73119
74- - name : 🔍 Confirm PR Exists
120+ sed -i '' -E "s/spec=\"com\.onesignal:OneSignal:[0-9][0-9.]*\"/spec=\"com.onesignal:OneSignal:$VERSION\"/" com.onesignal.unity.android/Editor/OneSignalAndroidDependencies.xml
121+ sed -i '' -E "s/'com\.onesignal:OneSignal:[0-9][0-9.]*'/'com.onesignal:OneSignal:$VERSION'/" OneSignalExample/Assets/Plugins/Android/mainTemplate.gradle
122+ sed -i '' -E "s/<package>com\.onesignal:OneSignal:[0-9][0-9.]*<\/package>/<package>com.onesignal:OneSignal:$VERSION<\/package>/" OneSignalExample/ProjectSettings/AndroidResolverDependencies.xml
123+
124+ echo "✓ Updated Android SDK to ${VERSION}"
125+ git add .
126+ git commit -m "Bump Android SDK $VERSION"
127+ git push
128+
129+ - name : Update iOS SDK version
130+ if : inputs.ios_version != ''
75131 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."
132+ VERSION="${{ inputs.ios_version }}"
133+
134+ # Validate version exists on GitHub
135+ RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
136+ "https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
137+
138+ if [ -z "$RELEASE" ]; then
139+ echo "✗ iOS SDK version ${VERSION} not found"
140+ exit 1
82141 fi
142+
143+ sed -i '' -E "s/version=\"[0-9][0-9.]*\"/version=\"$VERSION\"/" com.onesignal.unity.ios/Editor/OneSignaliOSDependencies.xml
144+
145+ echo "✓ Updated iOS SDK to ${VERSION}"
146+ git add .
147+ git commit -m "Bump iOS SDK $VERSION"
148+ git push
149+
150+ - name : Update Unity SDK version
151+ run : |
152+ echo "Updating Unity SDK version to ${{ inputs.unity_version }}"
153+
154+ # Version string formats
155+ PADDED_VERSION=$(printf "%06d" $(echo "${{ inputs.unity_version }}" | sed 's/[^0-9]//g'))
156+
157+ # VERSION file
158+ echo "${{ inputs.unity_version }}" > OneSignalExample/Assets/OneSignal/VERSION
159+
160+ # package.json files
161+ for file in com.onesignal.unity.core/package.json com.onesignal.unity.android/package.json com.onesignal.unity.ios/package.json; do
162+ sed -i '' "s/\"version\": \".*\"/\"version\": \"${{ inputs.unity_version }}\"/" "$file"
163+ sed -i '' "s/\"com.onesignal.unity.core\": \".*\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/" "$file"
164+ done
165+
166+ sed -i '' "s/public const string Version = \".*\"/public const string Version = \"${{ inputs.unity_version }}\"/" \
167+ com.onesignal.unity.core/Runtime/OneSignal.cs
168+ sed -i '' "s/public const string VersionHeader = \".*\"/public const string VersionHeader = \"${PADDED_VERSION}\"/" \
169+ com.onesignal.unity.core/Runtime/OneSignalPlatform.cs
170+
171+ # asmdef files
172+ for asm in \
173+ OneSignalExample/Assets/OneSignal/Example/OneSignal.UnityPackage.Example.asmdef \
174+ OneSignalExample/Assets/OneSignal/Editor/OneSignal.UnityPackage.Editor.asmdef \
175+ OneSignalExample/Assets/OneSignal/Attribution/OneSignal.UnityPackage.Attribution.asmdef; do
176+ sed -i '' "s/\"expression\": \".*\"/\"expression\": \"${{ inputs.unity_version }}\"/" "$asm"
177+ done
178+
179+ # packages-lock.json
180+ sed -i '' "s/\"com.onesignal.unity.core\": \"[0-9.]\+\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/g" \
181+ OneSignalExample/Packages/packages-lock.json
182+
183+ # ProjectSettings.asset
184+ sed -i '' "s/bundleVersion: .*/bundleVersion: ${{ inputs.unity_version }}/" \
185+ OneSignalExample/ProjectSettings/ProjectSettings.asset
186+
187+ # iOS plugin version (UIApplication+OneSignalUnity.mm)
188+ sed -i '' "s/setSdkVersion:@\"[0-9]*\"/setSdkVersion:@\"${PADDED_VERSION}\"/" \
189+ com.onesignal.unity.ios/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm
190+
191+ - name : Run UpdateProjectVersion
192+ uses : buildalon/unity-action@v3
193+ with :
194+ project-path : OneSignalExample
195+ arguments : -quit -batchmode -nographics -buildTarget Android -executeMethod OneSignalSDK.OneSignalPackagePublisher.UpdateProjectVersion
196+
197+
198+ - name : Run ExportUnityPackage
199+ uses : buildalon/unity-action@v3
200+ with :
201+ project-path : OneSignalExample
202+ arguments : -quit -batchmode -nographics -buildTarget Android -executeMethod OneSignalSDK.OneSignalPackagePublisher.ExportUnityPackage
203+
204+ - name : Commit Release
205+ run : |
206+ git add .
207+ git commit -m "Release ${{ inputs.unity_version }}"
208+ git push
209+
210+ - name : Draft Release
211+ run : |
212+ package_path="OneSignalExample/OneSignal-v${{ inputs.unity_version }}.unitypackage"
213+ gh release create "${{ inputs.unity_version }}" "${package_path}"\
214+ --draft\
215+ --title "${{ inputs.unity_version }} Release"\
216+ --notes "TODO"
217+
218+ create-pr :
219+ needs : [prep, update-version]
220+ uses : OneSignal/sdk-actions/.github/workflows/create-release.yml@main
221+ with :
222+ release_branch : ${{ needs.prep.outputs.release_branch }}
223+ version_from : ${{ needs.update-version.outputs.unity_from }}
224+ version_to : ${{ inputs.unity_version }}
225+ android_from : ${{ needs.update-version.outputs.android_from }}
226+ android_to : ${{ inputs.android_version }}
227+ ios_from : ${{ needs.update-version.outputs.ios_from }}
228+ ios_to : ${{ inputs.ios_version }}
0 commit comments