forked from OwnTube-tv/web-client
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (213 loc) · 8.87 KB
/
testflight.yml
File metadata and controls
233 lines (213 loc) · 8.87 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
name: Upload to Testflight
on:
workflow_call:
inputs:
owntube_source:
required: false
type: string
description: "The repository with OwnTube-tv/web-client code. Defaults to the source repository."
use_parent_repo_customizations:
required: false
type: boolean
description: "Should a parent repo be used for customizations? (Required for branded builds)"
target:
required: true
type: string
description: Upload iOS (iphoneos) or tvOS (appletvos) app
runner-label:
type: string
default: "macos-latest"
customizations_env_content:
required: false
type: string
build_info:
required: true
type: string
code_sign_identity:
required: true
type: string
secrets:
BUILD_CERTIFICATE_BASE64:
required: true
description: A base64-encoded representation of the code signing certificate
PROVISIONING_PROFILE_BASE64:
required: true
description: A base64-encoded representation of the provisioning profile containing the certificate
P12_PASSWORD:
required: true
description: Password to the certificate
PROVISIONING_PROFILE_SPECIFIER:
required: true
description: Provisioning profile specifier, e.g. MyOwnTube Apple Profile
APPLE_DEVELOPMENT_TEAM:
required: true
description: Unique Apple team ID
APPLE_API_PRIVATE_KEY:
required: true
description: A base64-encoded representation of the Apple Api key p8 file from App Store Connect
APPLE_API_KEY:
required: true
description: Identifier for the Apple API key
APPLE_API_KEY_ISSUER:
required: true
description: Apple API key issuer ID
jobs:
testflight:
runs-on: ${{ inputs.runner-label }}
environment: owntube
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ inputs.owntube_source || github.repository }}
- name: Checkout parent repo with customizations
uses: actions/checkout@v4
if: ${{ inputs.use_parent_repo_customizations }}
with:
path: customizations
- name: Setup Node 20
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Dependencies
run: cd OwnTube.tv/ && npm install
- name: Create .env File
id: create_env
if: ${{ inputs.customizations_env_content != '' }}
run: |
echo "BUNDLE_ID=$(echo "${{ inputs.customizations_env_content }}" | grep '^EXPO_PUBLIC_IOS_BUNDLE_IDENTIFIER=' | cut -d'=' -f2)" >> $GITHUB_OUTPUT
echo "APP_NAME=$(echo "${{ inputs.customizations_env_content }}" | grep '^EXPO_PUBLIC_APP_NAME=' | cut -d'=' -f2 | sed "s/['\"]//g")" >> $GITHUB_OUTPUT
echo "${{ inputs.customizations_env_content }}" > ./OwnTube.tv/.env
- name: Expo Prebuild assets
run: |
if [ "${{ inputs.target }}" == "appletvos" ]; then
export EXPO_TV=1
fi
export LC_CTYPE=UTF-8
cd OwnTube.tv/ && npx expo prebuild --clean --platform ios
- name: Inject Build Info
run: |
cat > ./OwnTube.tv/build-info.json << 'EOF'
${{ inputs.build_info }}
EOF
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROVISIONING_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: "CI_PASSWORD"
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 16.4
- name: Build and archive app for upload to Testflight by @${{ github.actor }}
env:
APPLE_DEVELOPMENT_TEAM: ${{ secrets.APPLE_DEVELOPMENT_TEAM }}
PROVISIONING_PROFILE_SPECIFIER: ${{ secrets.PROVISIONING_PROFILE_SPECIFIER }}
run: |
if [ "${{ inputs.target }}" == "appletvos" ]; then
export EXPO_TV=1
fi
cd OwnTube.tv/ios/
WORKSPACE_FILE=$(find . -maxdepth 1 -name "*.xcworkspace")
SCHEME=$(xcodebuild -list | sed -n '/Schemes:/,$p' | tail -n +2 | head -n 1 | xargs)
if [[ -n "$WORKSPACE_FILE" && -n "$SCHEME" ]]; then
echo "Running xcodebuild with workspace $WORKSPACE_FILE and scheme $SCHEME"
xcodebuild \
-workspace "$WORKSPACE_FILE" \
-sdk ${{ inputs.target }} \
-scheme "$SCHEME" \
-configuration Release \
-quiet \
-archivePath ./build/OwnTube.xcarchive \
archive \
DEVELOPMENT_TEAM="$APPLE_DEVELOPMENT_TEAM" \
CODE_SIGN_STYLE=Manual \
CODE_SIGN_IDENTITY="${{ inputs.code_sign_identity }}" \
PROVISIONING_PROFILE_SPECIFIER="$PROVISIONING_PROFILE_SPECIFIER" \
CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO \
OTHER_CODE_SIGN_FLAGS="--keychain $RUNNER_TEMP/app-signing.keychain-db"
else
echo "Error: No .xcworkspace or scheme file found."
exit 1
fi
- name: Export archive
env:
APPLE_DEVELOPMENT_TEAM: ${{ secrets.APPLE_DEVELOPMENT_TEAM }}
PROVISIONING_PROFILE_SPECIFIER: ${{ secrets.PROVISIONING_PROFILE_SPECIFIER }}
run: |
cd OwnTube.tv/ios
echo "<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store-connect</string>
<key>uploadSymbols</key>
<true/>
<key>uploadBitcode</key>
<false/>
<key>teamID</key>
<string>"$APPLE_DEVELOPMENT_TEAM"</string>
<key>destination</key>
<string>export</string>
<key>provisioningProfiles</key>
<dict>
<key>${{ steps.create_env.outputs.BUNDLE_ID || 'com.owntubetv.owntube' }}</key>
<string>"$PROVISIONING_PROFILE_SPECIFIER"</string>
</dict>
</dict>
</plist>
" > ./ExportOptions.plist &&
xcodebuild \
-exportArchive \
-archivePath ./build/OwnTube.xcarchive \
-exportPath ./build/OwnTube \
-exportOptionsPlist ExportOptions.plist
- name: Install private API key P8
env:
APPLE_API_PRIVATE_KEY: ${{ secrets.APPLE_API_PRIVATE_KEY }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
run: |
mkdir -p ~/private_keys
echo -n "$APPLE_API_PRIVATE_KEY" | base64 --decode --output ~/private_keys/AuthKey_$APPLE_API_KEY.p8
- name: Upload app
env:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }}
run: |
IPA_NAME="${{ steps.create_env.outputs.APP_NAME }}"
IPA_NAME="${IPA_NAME// /}"
cd OwnTube.tv/ios
xcrun altool --upload-app \
--type ${{ inputs.target }} \
--file build/OwnTube/$IPA_NAME.ipa \
--apiKey "$APPLE_API_KEY" \
--apiIssuer "$APPLE_API_KEY_ISSUER"
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
rm -rf ~/private_keys
security list-keychains -s ~/Library/Keychains/login.keychain-db
security lock-keychain ~/Library/Keychains/login.keychain-db