Skip to content

Commit 3630589

Browse files
committed
ci: Update create-release-prs workflow
* This script will read the VERSION and update the 2 podspec files and the ONESIGNAL_VERSION's in the SDK * Add this to the CD script as a step. * This is similar to existing scripts `update_swift_package.sh` and `build_all_frameworks.sh` - Also, rename cd.yml to create-release-prs.yml for clarity
1 parent 7a22b21 commit 3630589

File tree

3 files changed

+348
-100
lines changed

3 files changed

+348
-100
lines changed

.github/workflows/cd.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
name: Create Release PRs
2+
3+
# Note: The "Use workflow from" dropdown selects which version of THIS workflow to run.
4+
# Always select "main" unless you're testing workflow changes from another branch.
5+
# The "base_branch" input below determines where the release PR will be targeted.
6+
7+
# This workflow bumps version and creates PRs in the iOS-SDK and XCFramework SDK.
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: "The version number of the release (e.g., 5.2.15 or 5.2.3-beta-01)"
14+
type: string
15+
required: true
16+
base_branch:
17+
description: 'Target branch for the PR (e.g. main for regular releases, 5.3-main for 5.3.x releases)'
18+
type: string
19+
required: false
20+
default: 'main'
21+
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
26+
jobs:
27+
bump-version:
28+
runs-on: macos-13
29+
30+
env:
31+
VERSION: ${{ github.event.inputs.version }}
32+
BASE_BRANCH: ${{ github.event.inputs.base_branch }}
33+
RELEASE_BRANCH: rel/${{ github.event.inputs.version }}
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
steps:
37+
- name: 📋 Display Configuration
38+
run: |
39+
echo "============================================"
40+
echo "📦 Release Version: $VERSION"
41+
echo "🎯 Base Branch (PR Target): $BASE_BRANCH"
42+
echo "🌿 Release Branch (to create): $RELEASE_BRANCH"
43+
echo "============================================"
44+
45+
- name: Checkout OneSignal-iOS-SDK
46+
uses: actions/checkout@v4
47+
with:
48+
ref: ${{ env.BASE_BRANCH }}
49+
fetch-depth: 0
50+
51+
- name: Create Release Branch
52+
run: |
53+
# Delete remote branch if it exists
54+
git push origin --delete $RELEASE_BRANCH || true
55+
56+
# Create and checkout new release branch
57+
git checkout -b $RELEASE_BRANCH
58+
echo "Created release branch: $RELEASE_BRANCH"
59+
60+
# Configure git user (only needed once per repo)
61+
git config --local user.email "noreply@onesignal.com"
62+
git config --local user.name "github-actions[bot]"
63+
64+
- name: Setup Xcode
65+
uses: maxim-lobanov/setup-xcode@v1
66+
with:
67+
xcode-version: '15.2'
68+
69+
- name: Install the Apple distribution certificate and provisioning profile (OneSignal)
70+
uses: apple-actions/import-codesign-certs@v2
71+
with:
72+
keychain-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
73+
p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
74+
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
75+
76+
- name: Install the Apple distribution certificate and provisioning profile (Lilomi)
77+
uses: apple-actions/import-codesign-certs@v2
78+
with:
79+
create-keychain: false # do not create a new keychain for this value
80+
keychain-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
81+
p12-file-base64: ${{ secrets.DEV_CERTIFICATES_P12 }}
82+
p12-password: ${{ secrets.DEV_CERTIFICATES_P12_PASSWORD }}
83+
84+
- name: Update Version in SDK and Podspec Files
85+
run: |
86+
cd iOS_SDK/OneSignalSDK
87+
chmod +x ./update_version.sh
88+
./update_version.sh $VERSION
89+
shell: bash
90+
91+
- name: Commit Version Bump and Push Changes
92+
run: |
93+
git commit -am "chore: bump version to $VERSION"
94+
git push origin $RELEASE_BRANCH
95+
96+
- name: Build Binaries
97+
run: |
98+
cd iOS_SDK/OneSignalSDK
99+
chmod +x ./build_all_frameworks.sh
100+
./build_all_frameworks.sh
101+
shell: bash
102+
103+
- name: Code Sign
104+
run: |
105+
cd iOS_SDK/OneSignalSDK
106+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_Core/OneSignalCore.xcframework
107+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_Extension/OneSignalExtension.xcframework
108+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_InAppMessages/OneSignalInAppMessages.xcframework
109+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_Location/OneSignalLocation.xcframework
110+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_Notifications/OneSignalNotifications.xcframework
111+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_OSCore/OneSignalOSCore.xcframework
112+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_Outcomes/OneSignalOutcomes.xcframework
113+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_User/OneSignalUser.xcframework
114+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_XCFramework/OneSignalFramework.xcframework
115+
codesign --timestamp -v --sign "Apple Distribution: OneSignal, Inc. (J3J28YJX9L)" OneSignal_LiveActivities/OneSignalLiveActivities.xcframework
116+
shell: bash
117+
118+
- name: Commit Build and Push Changes
119+
run: |
120+
git commit -am "chore: build binaries"
121+
git push origin $RELEASE_BRANCH
122+
123+
- name: Update Swift Package
124+
run: |
125+
cd iOS_SDK/OneSignalSDK
126+
chmod +x ./update_swift_package.sh
127+
./update_swift_package.sh $VERSION
128+
shell: bash
129+
130+
- name: Commit Swift Package and Push Changes
131+
run: |
132+
git commit -am "chore: update Swift package"
133+
git push origin $RELEASE_BRANCH
134+
135+
- name: Fetch Last GitHub Release Tag
136+
id: fetch_last_release
137+
run: |
138+
echo "Fetching latest GitHub release tag..."
139+
LAST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
140+
141+
if [[ -z "$LAST_TAG" ]]; then
142+
echo "❌ No previous release tag found. Cannot generate release notes."
143+
exit 0
144+
fi
145+
146+
echo "✅ Found last release tag: $LAST_TAG"
147+
echo "range=$LAST_TAG..HEAD" >> $GITHUB_OUTPUT
148+
149+
- name: Generate Release Notes from PR Titles
150+
run: |
151+
echo "## 🔖 Auto-Generated Release Notes" > pr_body.md
152+
echo "" >> pr_body.md
153+
154+
if [[ "$VERSION" == *"alpha"* ]]; then
155+
CHANNEL="alpha"
156+
elif [[ "$VERSION" == *"beta"* ]]; then
157+
CHANNEL="beta"
158+
else
159+
CHANNEL="current"
160+
fi
161+
162+
echo "**Channels:** $CHANNEL" >> pr_body.md
163+
echo "" >> pr_body.md
164+
165+
RANGE="${{ steps.fetch_last_release.outputs.range }}"
166+
echo "📦 Commit range: $RANGE"
167+
168+
COMMITS=$(git log "$RANGE" --pretty=format:"%H" | sort -u)
169+
170+
if [[ -z "$COMMITS" ]]; then
171+
echo "❌ No commits found. Exiting."
172+
exit 0
173+
fi
174+
175+
> raw_titles.txt
176+
for SHA in $COMMITS; do
177+
PR_INFO=$(gh api "repos/${{ github.repository }}/commits/$SHA/pulls" \
178+
-H "Accept: application/vnd.github.groot-preview+json" 2>/dev/null)
179+
180+
TITLE=$(echo "$PR_INFO" | jq -r '.[0].title // empty')
181+
NUMBER=$(echo "$PR_INFO" | jq -r '.[0].number // empty')
182+
183+
if [[ -n "$TITLE" && -n "$NUMBER" ]]; then
184+
echo "$TITLE ([#$NUMBER](https://github.com/${{ github.repository }}/pull/$NUMBER))" >> raw_titles.txt
185+
echo "✅ $SHA → $TITLE (#$NUMBER)"
186+
else
187+
echo "⚠️ $SHA → No PR found"
188+
fi
189+
done
190+
191+
sort -fu raw_titles.txt > pr_titles.txt
192+
193+
if [[ ! -s pr_titles.txt ]]; then
194+
echo "❌ No PR titles found from commits. Exiting."
195+
exit 0
196+
fi
197+
198+
echo "" >> pr_body.md
199+
echo "### 🚀 New Features" >> pr_body.md
200+
grep -i '^feat' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
201+
202+
echo "" >> pr_body.md
203+
echo "### 🐛 Bug Fixes" >> pr_body.md
204+
grep -i '^bug' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
205+
206+
echo "" >> pr_body.md
207+
echo "### 🔧 Improvements" >> pr_body.md
208+
grep -i -E '^(perf|refactor)' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
209+
210+
echo "" >> pr_body.md
211+
echo "### 📝 Uncategorized PRs" >> pr_body.md
212+
grep -v -i -E '^(feat|bug|perf|refactor)' pr_titles.txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
213+
214+
echo "" >> pr_body.md
215+
echo "### 📦 Version" >> pr_body.md
216+
echo "$VERSION" >> pr_body.md
217+
218+
- name: Create Pull Request for iOS SDK
219+
run: |
220+
gh pr create \
221+
--title "Release $VERSION" \
222+
--body-file pr_body.md \
223+
--head "$RELEASE_BRANCH" \
224+
--base "$BASE_BRANCH"
225+
226+
- name: Checkout OneSignal-XCFramework
227+
uses: actions/checkout@v4
228+
with:
229+
repository: OneSignal/OneSignal-XCFramework
230+
ref: ${{ env.BASE_BRANCH }}
231+
path: xcframework-repo
232+
token: ${{ secrets.PAT_TOKEN_ONESIGNAL_XCFRAMEWORK }}
233+
234+
- name: Update Package.swift in XCFramework Repository
235+
run: |
236+
# Copy Package.swift from iOS SDK to XCFramework repo
237+
cp Package.swift xcframework-repo/Package.swift
238+
239+
# Navigate to XCFramework repo
240+
cd xcframework-repo
241+
242+
# Delete remote branch if it exists
243+
git push origin --delete $RELEASE_BRANCH || true
244+
245+
# Create release branch
246+
git checkout -b $RELEASE_BRANCH
247+
248+
# Configure git
249+
git config --local user.email "noreply@onesignal.com"
250+
git config --local user.name "github-actions[bot]"
251+
252+
# Commit changes
253+
git commit -am "Release $VERSION"
254+
255+
# Push to remote
256+
git push origin $RELEASE_BRANCH
257+
258+
- name: Create Pull Request for XCFramework Repository
259+
env:
260+
GH_TOKEN: ${{ secrets.PAT_TOKEN_ONESIGNAL_XCFRAMEWORK }}
261+
262+
run: |
263+
cd xcframework-repo
264+
gh pr create \
265+
--title "Release $VERSION" \
266+
--body-file ../pr_body.md \
267+
--head "$RELEASE_BRANCH" \
268+
--base "$BASE_BRANCH"

0 commit comments

Comments
 (0)