-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (228 loc) · 9.69 KB
/
publishing.yml
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
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Publishing
on:
push:
branches:
- develop
- hotfix/*
- release/*
tags:
- v*.*.*
jobs:
build:
name: Build
runs-on: macos-latest
environment: apple-app-store
strategy:
matrix:
platform:
- iOS
- macOS
distribution:
- app-store
- standalone
exclude:
- platform: iOS
distribution: standalone
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Cache packages
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts
~/Library/Developer/Xcode/DerivedData/**/SourcePackages/repositories
key: ${{ runner.os }}-${{ matrix.platform }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.platform }}-spm-
- name: Set up signing certificate
env:
CERTIFICATE_DISTRIBUTION_B64: ${{ vars.CERTIFICATE_DISTRIBUTION_B64 }}
CERTIFICATE_DISTRIBUTION_PRIVATE_KEY_B64: ${{ secrets.CERTIFICATE_DISTRIBUTION_PRIVATE_KEY_B64 }}
CERTIFICATE_MAC_INSTALLER_B64: ${{ vars.CERTIFICATE_MAC_INSTALLER_B64 }}
CERTIFICATE_MAC_INSTALLER_PRIVATE_KEY_B64: ${{ secrets.CERTIFICATE_MAC_INSTALLER_PRIVATE_KEY_B64 }}
CERTIFICATE_DEVELOPER_ID_APPLICATION_B64: ${{ vars.CERTIFICATE_DEVELOPER_ID_APPLICATION_B64 }}
CERTIFICATE_DEVELOPER_ID_APPLICATION_PRIVATE_KEY_B64: ${{ secrets.CERTIFICATE_DEVELOPER_ID_APPLICATION_PRIVATE_KEY_B64 }}
CERTIFICATE_DEVELOPER_ID_INSTALLER_B64: ${{ vars.CERTIFICATE_DEVELOPER_ID_INSTALLER_B64 }}
CERTIFICATE_DEVELOPER_ID_INSTALLER_PRIVATE_KEY_B64: ${{ secrets.CERTIFICATE_DEVELOPER_ID_INSTALLER_PRIVATE_KEY_B64 }}
run: |
security create-keychain -p password build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p password build.keychain
security set-keychain-settings build.keychain
for CERTIFICATE in \
$CERTIFICATE_DISTRIBUTION_B64 \
$CERTIFICATE_MAC_INSTALLER_B64 \
$CERTIFICATE_DEVELOPER_ID_APPLICATION_B64 \
$CERTIFICATE_DEVELOPER_ID_INSTALLER_B64; \
do
echo $CERTIFICATE | base64 --decode > /tmp/certificate.cer
security import /tmp/certificate.cer -k build.keychain -P '' -T /usr/bin/codesign -T /usr/bin/productsign
done
for KEY in \
$CERTIFICATE_DISTRIBUTION_PRIVATE_KEY_B64 \
$CERTIFICATE_MAC_INSTALLER_PRIVATE_KEY_B64 \
$CERTIFICATE_DEVELOPER_ID_APPLICATION_PRIVATE_KEY_B64 \
$CERTIFICATE_DEVELOPER_ID_INSTALLER_PRIVATE_KEY_B64; \
do
echo $KEY | base64 --decode > /tmp/key.p12
security import /tmp/key.p12 -k build.keychain -P '' -T /usr/bin/codesign -T /usr/bin/productsign
done
security set-key-partition-list -S apple-tool:,apple: -s -k password build.keychain
- name: Set up App Store Connect authentication
env:
APP_STORE_CONNECT_PRIVATE_KEY_B64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_B64 }}
run: echo $APP_STORE_CONNECT_PRIVATE_KEY_B64 | base64 --decode > /tmp/connect-key.p8
- name: Select Xcode version
run: sudo xcode-select -s /Applications/Xcode_$(cat .xcode-version).app/Contents/Developer
- name: Prepare files
if: ${{ matrix.distribution == 'app-store' }}
env:
CODE_SIGN_IDENTITY: 'Apple Distribution'
PROVISIONING_PROFILE_SPECIFIER: ${{ matrix.platform == 'macOS' && vars.PROVISIONING_PROFILE_NAME_MACOS || vars.PROVISIONING_PROFILE_NAME }}
SENTRY_DSN: ${{ matrix.platform == 'iOS' && secrets.SENTRY_DSN_IOS || secrets.SENTRY_DSN_MACOS }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ matrix.platform == 'iOS' && vars.SENTRY_PROJECT_IOS || vars.SENTRY_PROJECT_MACOS }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: make
- name: Prepare files
if: ${{ matrix.distribution == 'standalone' }}
env:
CODE_SIGN_IDENTITY: 'Developer ID Application'
PROVISIONING_PROFILE_SPECIFIER: ${{ vars.PROVISIONING_PROFILE_NAME_MACOS_STANDALONE }}
run: make
- name: Trust OpenAPI plugin
run: bash .github/workflows/trust-openapi-plugin.sh
- name: Set up Sentry
if: ${{ matrix.distribution == 'app-store' }}
run: curl -sL https://sentry.io/get-cli/ | sh
- name: Build app
env:
CODE_SIGN_IDENTITY: Apple Distribution
PROVISIONING_PROFILE_SPECIFIER: Fyreplace
run: |
xcodebuild archive \
DEVELOPMENT_TEAM=${{ vars.TEAM_ID }} \
-allowProvisioningUpdates \
-authenticationKeyPath /tmp/connect-key.p8 \
-authenticationKeyID ${{ vars.APP_STORE_CONNECT_KEY_ID }} \
-authenticationKeyIssuerID ${{ vars.APP_STORE_CONNECT_ISSUER_ID }} \
-scheme Fyreplace \
-destination generic/platform=${{ matrix.platform }} \
-archivePath archive.xcarchive
- name: Export to IPA
if: ${{ matrix.platform == 'iOS' }}
run: |
/usr/libexec/PlistBuddy -c "Add :method string" ExportOptions.plist
/usr/libexec/PlistBuddy -c "Set :method app-store-connect" ExportOptions.plist
/usr/libexec/PlistBuddy -c "Add :teamId string" ExportOptions.plist
/usr/libexec/PlistBuddy -c "Set :teamId ${{ vars.TEAM_ID }}" ExportOptions.plist
/usr/libexec/PlistBuddy -c "Add :provisioningProfiles dict" ExportOptions.plist
/usr/libexec/PlistBuddy -c "Add :provisioningProfiles:${{ vars.APP_ID }} string ${{ vars.PROVISIONING_PROFILE_NAME }}" ExportOptions.plist
xcodebuild export \
-allowProvisioningUpdates \
-authenticationKeyPath /tmp/connect-key.p8 \
-authenticationKeyID ${{ vars.APP_STORE_CONNECT_KEY_ID }} \
-authenticationKeyIssuerID ${{ vars.APP_STORE_CONNECT_ISSUER_ID }} \
-archivePath archive.xcarchive \
-exportArchive \
-exportOptionsPlist ExportOptions.plist \
-exportPath Export
- name: Export to PKG
if: ${{ matrix.platform == 'macOS' }}
env:
SIGNING_CERTIFICATE: ${{ matrix.distribution == 'app-store' && '3rd Party Mac Developer Installer' || 'Developer ID Installer' }}
run: |
mkdir Export
productbuild \
--component archive.xcarchive/Products/Applications/Fyreplace.app \
/Applications \
Export/Fyreplace.unsigned.pkg
productsign \
--sign "$SIGNING_CERTIFICATE" \
Export/Fyreplace.unsigned.pkg \
Export/Fyreplace.pkg
- name: Upload IPA
uses: actions/upload-artifact@v4
if: ${{ matrix.platform == 'iOS' }}
with:
name: Fyreplace.ipa
path: Export/Fyreplace.ipa
if-no-files-found: error
- name: Upload PKG
uses: actions/upload-artifact@v4
if: ${{ matrix.platform == 'macOS' }}
with:
name: ${{ matrix.distribution == 'standalone' && 'Fyreplace.standalone.pkg' || 'Fyreplace.pkg' }}
path: Export/Fyreplace.pkg
if-no-files-found: error
publish:
name: Publish
needs: build
runs-on: macos-latest
environment: apple-app-store
strategy:
matrix:
platform:
- ios
- osx
distribution:
- app-store
- standalone
exclude:
- platform: ios
distribution: standalone
steps:
- name: Download IPA
uses: actions/download-artifact@v4
if: ${{ matrix.platform == 'ios' }}
with:
name: Fyreplace.ipa
path: /tmp
- name: Download PKG
uses: actions/download-artifact@v4
if: ${{ matrix.platform == 'osx' }}
with:
name: ${{ matrix.distribution == 'standalone' && 'Fyreplace.standalone.pkg' || 'Fyreplace.pkg' }}
path: /tmp
- name: Set up App Store Connect authentication
env:
APP_STORE_CONNECT_PRIVATE_KEY_B64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_B64 }}
run: |
mkdir ~/private_keys
echo $APP_STORE_CONNECT_PRIVATE_KEY_B64 | base64 --decode > ~/private_keys/AuthKey_${{ vars.APP_STORE_CONNECT_KEY_ID }}.p8
- name: Upload to App Store Connect
if: ${{ matrix.distribution == 'app-store' }}
run: |
for OPERATION in '--validate-app' '--upload-app'
do
xcrun altool \
$OPERATION \
--type ${{ matrix.platform }} \
--file /tmp/Fyreplace.* \
--apiKey ${{ vars.APP_STORE_CONNECT_KEY_ID }} \
--apiIssuer ${{ vars.APP_STORE_CONNECT_ISSUER_ID }}
done
- name: Notorize PKG
if: ${{ matrix.distribution == 'standalone' }}
run: |
xcrun notarytool \
submit \
--wait \
--key ~/private_keys/AuthKey_${{ vars.APP_STORE_CONNECT_KEY_ID }}.p8 \
--key-id ${{ vars.APP_STORE_CONNECT_KEY_ID }} \
--issuer ${{ vars.APP_STORE_CONNECT_ISSUER_ID }} \
/tmp/Fyreplace.pkg
xcrun stapler staple /tmp/Fyreplace.pkg
- name: Upload PKG
uses: actions/upload-artifact@v4
if: ${{ matrix.distribution == 'standalone' }}
with:
name: Fyreplace.standalone.pkg
path: /tmp/Fyreplace.pkg
overwrite: true
if-no-files-found: error