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