-
Notifications
You must be signed in to change notification settings - Fork 31
236 lines (208 loc) · 9.35 KB
/
Copy pathios-release.yml
File metadata and controls
236 lines (208 loc) · 9.35 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: iOS Github Release
on:
workflow_dispatch:
pull_request:
types: [ closed ]
branches: [ dev ]
permissions:
contents: write
pull-requests: read
jobs:
release:
runs-on: macos-26
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'ios_github_release'))
steps:
- name: Checkout dev
uses: actions/checkout@v6
with:
ref: dev
fetch-depth: 0
- name: Configure git identity
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml') }}
restore-keys: |
gradle-${{ runner.os }}-
# WebRTC.xcframework is gitignored (~32 MB extracted, dSYMs shipped
# separately) and downloaded per IOS-BUILD-INSTRUCTIONS.md. If the
# version/patch ever bumps, update both places — it's only referenced
# here and in that doc.
- name: Cache WebRTC.xcframework
id: cache-webrtc
uses: actions/cache@v4
with:
path: iosApp/Frameworks/WebRTC.xcframework
key: webrtc-xcframework-m125-cow-bloat-fix.1
- name: Download WebRTC.xcframework
if: steps.cache-webrtc.outputs.cache-hit != 'true'
run: |
set -euo pipefail
curl -L --fail \
"https://github.com/teancom/webrtc/releases/download/m125-cow-bloat-fix.1/WebRTC.xcframework.m125-cow-bloat-fix.1.zip" \
-o /tmp/WebRTC.xcframework.zip
mkdir -p iosApp/Frameworks
unzip -q /tmp/WebRTC.xcframework.zip -d iosApp/Frameworks/
rm /tmp/WebRTC.xcframework.zip
# Fail loudly if the zip didn't contain what we expect — catches
# upstream release-format changes before they turn into opaque
# archive failures.
test -d iosApp/Frameworks/WebRTC.xcframework/ios-arm64/WebRTC.framework
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Extract current version
id: version
run: |
VERSION_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" iosApp/iosApp/Info.plist)
BUILD_NUM=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" iosApp/iosApp/Info.plist)
echo "Shipping iOS $VERSION_NAME ($BUILD_NUM)"
echo "name=$VERSION_NAME" >> "$GITHUB_OUTPUT"
echo "build=$BUILD_NUM" >> "$GITHUB_OUTPUT"
echo "tag=ios-v${VERSION_NAME}-build-${BUILD_NUM}" >> "$GITHUB_OUTPUT"
- name: Guard against duplicate tag
run: |
git fetch --tags
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "::error title=CFBundleVersion not bumped::Tag ${{ steps.version.outputs.tag }} already exists. Open a PR that bumps CFBundleVersion in iosApp/iosApp/Info.plist, merge it into dev, then dispatch this workflow again."
exit 1
fi
- name: Import signing cert and provisioning profile
env:
CERT_B64: ${{ secrets.IOS_DIST_CERT_P12_BASE64 }}
CERT_PASS: ${{ secrets.IOS_DIST_CERT_PASSWORD }}
PROFILE_B64: ${{ secrets.IOS_PROVISIONING_PROFILE_BASE64 }}
KC_PASS: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
set -euo pipefail
# Decode secrets into files
echo "$CERT_B64" | base64 -d > /tmp/dist.p12
echo "$PROFILE_B64" | base64 -d > /tmp/profile.mobileprovision
# Create & unlock an ephemeral keychain. Put it at the front of the
# user search list so xcodebuild/codesign find our identity before
# the default login keychain.
KEYCHAIN=/tmp/build.keychain-db
security create-keychain -p "$KC_PASS" "$KEYCHAIN"
security set-keychain-settings -lut 21600 "$KEYCHAIN"
security unlock-keychain -p "$KC_PASS" "$KEYCHAIN"
# Import the .p12 (cert + private key in one blob)
security import /tmp/dist.p12 \
-k "$KEYCHAIN" \
-P "$CERT_PASS" \
-T /usr/bin/codesign \
-T /usr/bin/productsign
# Authorize codesign to use the private key without a GUI prompt —
# required because security import alone leaves the key unusable.
security set-key-partition-list \
-S apple-tool:,apple: \
-s \
-k "$KC_PASS" \
"$KEYCHAIN"
security list-keychains -d user -s "$KEYCHAIN" login.keychain-db
# Install the provisioning profile where xcodebuild looks for it.
# We use the traditional ~/Library/MobileDevice path; xcodebuild CLI
# reads from here regardless of Xcode version.
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp /tmp/profile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/
# Sanity check — we should see our Apple Distribution identity
security find-identity -v -p codesigning "$KEYCHAIN"
- name: Archive
run: |
xcodebuild \
-project iosApp/iosApp.xcodeproj \
-scheme iosApp \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath "$PWD/build/iosApp.xcarchive" \
archive
- name: Export IPA
run: |
xcodebuild -exportArchive \
-archivePath "$PWD/build/iosApp.xcarchive" \
-exportOptionsPlist iosApp/ExportOptions.plist \
-exportPath "$PWD/build/ipa"
ls -la build/ipa/
- name: Upload to App Store Connect
env:
KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ID }}
ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_ISSUER_ID }}
KEY_P8: ${{ secrets.APP_STORE_CONNECT_API_KEY_P8 }}
run: |
set -euo pipefail
mkdir -p ~/private_keys
# altool looks for the key at ~/private_keys/AuthKey_<KEY_ID>.p8
printf '%s' "$KEY_P8" > ~/private_keys/AuthKey_${KEY_ID}.p8
IPA=$(ls build/ipa/*.ipa | head -1)
echo "Uploading $IPA"
xcrun altool --upload-app \
-f "$IPA" \
-t ios \
--apiKey "$KEY_ID" \
--apiIssuer "$ISSUER_ID"
- name: Create and push tag
run: |
git tag -a "${{ steps.version.outputs.tag }}" \
-m "iOS v${{ steps.version.outputs.name }} build ${{ steps.version.outputs.build }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Generate release notes
id: notes
run: |
PREV_TAG=$(git tag -l 'ios-v*' --sort=-v:refname | grep -v "^${{ steps.version.outputs.tag }}$" | head -1)
if [ -n "$PREV_TAG" ]; then
# Only commits that touched iOS-relevant paths since the last iOS tag
NOTES=$(git log --pretty=format:"- %s" "$PREV_TAG"..HEAD -- iosApp composeApp ':!.github' ':!androidApp' || true)
else
NOTES="Initial iOS release"
fi
# Fallback if the path filter produced nothing
if [ -z "$NOTES" ]; then
NOTES="No iOS-specific changes since $PREV_TAG"
fi
# Write to a file so multi-line content survives the GITHUB_OUTPUT delimiter
printf '%s' "$NOTES" > /tmp/release-notes.md
echo "file=/tmp/release-notes.md" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: "iOS ${{ steps.version.outputs.name }} (${{ steps.version.outputs.build }})"
body_path: ${{ steps.notes.outputs.file }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summary
if: success()
run: |
NEXT_BUILD=$(( ${{ steps.version.outputs.build }} + 1 ))
{
echo "## iOS Release — success"
echo ""
echo "- **Version**: ${{ steps.version.outputs.name }} (${{ steps.version.outputs.build }})"
echo "- **Tag**: [\`${{ steps.version.outputs.tag }}\`](https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag }})"
echo "- Build should appear in App Store Connect → TestFlight → Builds within a few minutes."
echo ""
echo "### Before the next release"
echo ""
echo "Bump \`CFBundleVersion\` in \`iosApp/iosApp/Info.plist\` from \`${{ steps.version.outputs.build }}\` to \`${NEXT_BUILD}\` (or higher) in a PR and merge it into \`dev\`. The duplicate-tag guard will block a re-dispatch until this is done."
} >> "$GITHUB_STEP_SUMMARY"
- name: Clean up keychain
if: always()
run: |
security delete-keychain /tmp/build.keychain-db 2>/dev/null || true
rm -f /tmp/dist.p12 /tmp/profile.mobileprovision
rm -rf ~/private_keys