Skip to content

Commit 4d65b86

Browse files
committed
ci: add publish-release.yml to push to pods, SPM
1 parent d17bda7 commit 4d65b86

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: Publish Release to CocoaPods and SPM
2+
3+
# This workflow publishes the OneSignal pods to CocoaPods trunk.
4+
# And creates the tagged release in the OneSignal-XCFramework repository for SPM.
5+
# Run this AFTER the release PR has been merged and the GitHub release has been created.
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: 'Branch or commit SHA to run on (e.g., main, 5.3-main)'
12+
type: string
13+
required: false
14+
default: 'main'
15+
16+
permissions:
17+
contents: write
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
publish:
25+
runs-on: macos-13
26+
27+
env:
28+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
steps:
32+
- name: Checkout OneSignal-iOS-SDK
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ github.event.inputs.ref }}
36+
fetch-depth: 0
37+
38+
- name: Detect current branch
39+
id: detect_branch
40+
run: |
41+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
42+
BRANCH="${{ github.event.inputs.ref }}"
43+
else
44+
BRANCH="${GITHUB_REF#refs/heads/}"
45+
fi
46+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
47+
echo "Detected branch: $BRANCH"
48+
49+
- name: Extract release version from podspec
50+
id: extract_version
51+
run: |
52+
VERSION=$(grep -E "s.version\s*=" OneSignal.podspec | sed -E 's/.*"(.*)".*/\1/')
53+
echo "version=$VERSION" >> $GITHUB_OUTPUT
54+
echo "Extracted version: $VERSION"
55+
56+
- name: 📋 Display Configuration
57+
run: |
58+
echo "============================================"
59+
echo "📦 Release Version: ${{ steps.extract_version.outputs.version }}"
60+
echo "🌿 Branch: ${{ steps.detect_branch.outputs.branch }}"
61+
echo "============================================"
62+
63+
- name: Setup Ruby
64+
uses: ruby/setup-ruby@v1
65+
with:
66+
ruby-version: '3.0'
67+
68+
- name: Install CocoaPods
69+
run: |
70+
gem install cocoapods
71+
pod --version
72+
73+
- name: Validate OneSignal.podspec
74+
run: |
75+
echo "Validating OneSignal.podspec..."
76+
pod spec lint OneSignal.podspec --allow-warnings
77+
78+
- name: Validate OneSignalXCFramework.podspec
79+
run: |
80+
echo "Validating OneSignalXCFramework.podspec..."
81+
pod spec lint OneSignalXCFramework.podspec --allow-warnings
82+
83+
- name: Publish OneSignal.podspec to CocoaPods Trunk
84+
run: |
85+
echo "Publishing OneSignal.podspec to CocoaPods Trunk..."
86+
pod trunk push OneSignal.podspec --allow-warnings
87+
88+
- name: Publish OneSignalXCFramework.podspec to CocoaPods Trunk
89+
run: |
90+
echo "Publishing OneSignalXCFramework.podspec to CocoaPods Trunk..."
91+
pod trunk push OneSignalXCFramework.podspec --allow-warnings
92+
93+
- name: ✅ CocoaPods Published
94+
run: |
95+
VERSION="${{ steps.extract_version.outputs.version }}"
96+
echo "============================================"
97+
echo "✅ Successfully published version $VERSION to CocoaPods!"
98+
echo "============================================"
99+
echo "📦 OneSignal: https://cocoapods.org/pods/OneSignal"
100+
echo "📦 OneSignalXCFramework: https://cocoapods.org/pods/OneSignalXCFramework"
101+
102+
- name: Checkout OneSignal-XCFramework
103+
uses: actions/checkout@v4
104+
with:
105+
repository: OneSignal/OneSignal-XCFramework
106+
ref: ${{ steps.detect_branch.outputs.branch }}
107+
path: xcframework-repo
108+
fetch-depth: 0
109+
token: ${{ secrets.PAT_TOKEN_ONESIGNAL_XCFRAMEWORK }}
110+
111+
- name: Get XCFramework Release PR
112+
id: get_xcframework_pr
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN_ONESIGNAL_XCFRAMEWORK }}
115+
run: |
116+
VERSION="${{ steps.extract_version.outputs.version }}"
117+
118+
# Find the merged release PR in OneSignal-XCFramework repo for this version
119+
PR_NUMBER=$(gh pr list \
120+
--repo OneSignal/OneSignal-XCFramework \
121+
--state merged \
122+
--search "Release $VERSION in:title" \
123+
--json number \
124+
--jq '.[0].number // empty')
125+
126+
if [[ -n "$PR_NUMBER" ]]; then
127+
echo "Found merged XCFramework release PR: #$PR_NUMBER"
128+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
129+
130+
# Get PR body for release notes
131+
gh pr view "$PR_NUMBER" \
132+
--repo OneSignal/OneSignal-XCFramework \
133+
--json body \
134+
--jq '.body' > xcframework_pr_body.md || echo "" > xcframework_pr_body.md
135+
else
136+
echo "No merged release PR found for version $VERSION in OneSignal-XCFramework"
137+
echo "pr_number=" >> $GITHUB_OUTPUT
138+
echo "" > xcframework_pr_body.md
139+
fi
140+
141+
- name: Create GitHub Release for OneSignal-XCFramework
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN_ONESIGNAL_XCFRAMEWORK }}
144+
run: |
145+
VERSION="${{ steps.extract_version.outputs.version }}"
146+
BRANCH="${{ steps.detect_branch.outputs.branch }}"
147+
148+
cd xcframework-repo
149+
150+
# Configure git
151+
git config --local user.email "noreply@onesignal.com"
152+
git config --local user.name "github-actions[bot]"
153+
154+
# Create and push tag
155+
git tag -a "$VERSION" -m "Release $VERSION"
156+
git push origin "$VERSION"
157+
158+
echo "✅ Created and pushed tag: $VERSION to OneSignal-XCFramework"
159+
160+
# Use PR body if available, otherwise create default release notes
161+
if [[ -s ../xcframework_pr_body.md ]] && [[ -n "${{ steps.get_xcframework_pr.outputs.pr_number }}" ]]; then
162+
echo "Using release notes from XCFramework PR #${{ steps.get_xcframework_pr.outputs.pr_number }}"
163+
cp ../xcframework_pr_body.md release_notes.md
164+
else
165+
echo "No PR body found, generating default release notes"
166+
echo "## 🔖 Release $VERSION" > release_notes.md
167+
echo "" >> release_notes.md
168+
echo "This release corresponds to [OneSignal-iOS-SDK $VERSION](https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/$VERSION)" >> release_notes.md
169+
fi
170+
171+
# Determine if this is a pre-release
172+
PRERELEASE_FLAG=""
173+
if [[ "$VERSION" == *"alpha"* ]] || [[ "$VERSION" == *"beta"* ]]; then
174+
PRERELEASE_FLAG="--prerelease"
175+
echo "Marking as pre-release (alpha/beta detected)"
176+
fi
177+
178+
# Create GitHub release
179+
gh release create "$VERSION" \
180+
--repo OneSignal/OneSignal-XCFramework \
181+
--title "Release $VERSION" \
182+
--notes-file release_notes.md \
183+
--target "$BRANCH" \
184+
$PRERELEASE_FLAG
185+
186+
echo "✅ GitHub release created successfully for OneSignal-XCFramework!"
187+
echo "🔗 https://github.com/OneSignal/OneSignal-XCFramework/releases/tag/$VERSION"
188+
189+
- name: ✅ All Steps Complete
190+
run: |
191+
VERSION="${{ steps.extract_version.outputs.version }}"
192+
echo "============================================"
193+
echo "✅ Successfully completed all release steps for version $VERSION"
194+
echo "============================================"
195+
echo "📦 CocoaPods OneSignal: https://cocoapods.org/pods/OneSignal"
196+
echo "📦 CocoaPods OneSignalXCFramework: https://cocoapods.org/pods/OneSignalXCFramework"
197+
echo "🔗 iOS SDK Release: https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/$VERSION"
198+
echo "🔗 XCFramework Release: https://github.com/OneSignal/OneSignal-XCFramework/releases/tag/$VERSION"

0 commit comments

Comments
 (0)