Skip to content

Commit 07a1b16

Browse files
committed
ci: add publish-release.yml to push to pods, SPM
* Pushes OneSignal and OneSignalXCFramework pods * Takes the release notes from OneSignal-iOS-SDK and makes a release XCFramework
1 parent d17bda7 commit 07a1b16

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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 iOS SDK Release Body
112+
id: get_ios_release
113+
run: |
114+
VERSION="${{ steps.extract_version.outputs.version }}"
115+
116+
# Fetch the release body from OneSignal-iOS-SDK
117+
if gh release view "$VERSION" --repo OneSignal/OneSignal-iOS-SDK --json body --jq '.body' > ios_release_body.md 2>/dev/null; then
118+
echo "✅ Found iOS SDK release for version $VERSION"
119+
echo "found=true" >> $GITHUB_OUTPUT
120+
else
121+
echo "⚠️ No iOS SDK release found for version $VERSION"
122+
echo "found=false" >> $GITHUB_OUTPUT
123+
echo "" > ios_release_body.md
124+
fi
125+
126+
- name: Create GitHub Release for OneSignal-XCFramework
127+
env:
128+
GH_TOKEN: ${{ secrets.PAT_TOKEN_ONESIGNAL_XCFRAMEWORK }}
129+
run: |
130+
VERSION="${{ steps.extract_version.outputs.version }}"
131+
BRANCH="${{ steps.detect_branch.outputs.branch }}"
132+
133+
cd xcframework-repo
134+
135+
# Configure git
136+
git config --local user.email "noreply@onesignal.com"
137+
git config --local user.name "github-actions[bot]"
138+
139+
# Create and push tag
140+
git tag -a "$VERSION" -m "Release $VERSION"
141+
git push origin "$VERSION"
142+
143+
echo "✅ Created and pushed tag: $VERSION to OneSignal-XCFramework"
144+
145+
# Use iOS SDK release body if available, otherwise create default release notes
146+
if [[ "${{ steps.get_ios_release.outputs.found }}" == "true" ]] && [[ -s ../ios_release_body.md ]]; then
147+
echo "Using release notes from iOS SDK release"
148+
cp ../ios_release_body.md release_notes.md
149+
else
150+
echo "No iOS SDK release body found, generating default release notes"
151+
echo "## 🔖 Release $VERSION" > release_notes.md
152+
echo "" >> release_notes.md
153+
echo "This release corresponds to [OneSignal-iOS-SDK $VERSION](https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/$VERSION)" >> release_notes.md
154+
fi
155+
156+
# Determine if this is a pre-release
157+
PRERELEASE_FLAG=""
158+
if [[ "$VERSION" == *"alpha"* ]] || [[ "$VERSION" == *"beta"* ]]; then
159+
PRERELEASE_FLAG="--prerelease"
160+
echo "Marking as pre-release (alpha/beta detected)"
161+
fi
162+
163+
# Create GitHub release
164+
gh release create "$VERSION" \
165+
--repo OneSignal/OneSignal-XCFramework \
166+
--title "$VERSION" \
167+
--notes-file release_notes.md \
168+
--target "$BRANCH" \
169+
$PRERELEASE_FLAG
170+
171+
echo "✅ GitHub release created successfully for OneSignal-XCFramework!"
172+
echo "🔗 https://github.com/OneSignal/OneSignal-XCFramework/releases/tag/$VERSION"
173+
174+
- name: ✅ All Steps Complete
175+
run: |
176+
VERSION="${{ steps.extract_version.outputs.version }}"
177+
echo "============================================"
178+
echo "✅ Successfully completed all release steps for version $VERSION"
179+
echo "============================================"
180+
echo "📦 CocoaPods OneSignal: https://cocoapods.org/pods/OneSignal"
181+
echo "📦 CocoaPods OneSignalXCFramework: https://cocoapods.org/pods/OneSignalXCFramework"
182+
echo "🔗 iOS SDK Release: https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/$VERSION"
183+
echo "🔗 XCFramework Release: https://github.com/OneSignal/OneSignal-XCFramework/releases/tag/$VERSION"

0 commit comments

Comments
 (0)