-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (116 loc) · 5.39 KB
/
main.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
name: CI
on: [ pull_request, push ]
jobs:
## Test on latest MacOS
# test:
# runs-on: macos-14
# steps:
# - name: Checkout the code
# uses: actions/checkout@v2
# - name: Mock GoogleService-Info.plist
# run: mv NOICommunity/GoogleService-Info_mock.plist NOICommunity/GoogleService-Info.plist
# - name: Resolve package dependencies
# run: xcodebuild -resolvePackageDependencies
# - name: List schemes (optional step to gather information)
# run: xcodebuild -list -project NOICommunity.xcodeproj
# - name: Test the app
# run: |
# set -eo pipefail
# xcodebuild clean test \
# -scheme NOICommunity \
# -destination 'platform=iOS Simulator,OS=16.2,name=iPhone 14' \
# IPHONEOS_DEPLOYMENT_TARGET='16.2' \
# | xcpretty
## Deploy to TestFlight
deploy_testflight:
name: Deploy to Testflight
runs-on: macos-14
if: github.ref == 'refs/heads/main'
# needs: [ test ]
steps:
- name: Checkout the code
uses: actions/checkout@v2
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.IOS_KEY_PASSPHRASE }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.IOS_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEY_PASSPHRASE }}
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 list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
# Force Xcode specific version (if needed)
# This action switches Xcode to the specified version.
# For details on available versions of Xcode, see https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md.
# - name: Force XCode specific version
# run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: Resolve package dependencies
run: xcodebuild -resolvePackageDependencies
- name: Inject GoogleService-Info.plist
env:
GOOGLE_SERVICE_INFO_PLIST: ${{ secrets.GOOGLE_SERVICE_INFO_PLIST }}
run: echo "$GOOGLE_SERVICE_INFO_PLIST" > NOICommunity/GoogleService-Info.plist
- name: Increment build number
run: |
set -eo pipefail
BUILD_NUMBER=$(date "+%Y%m%d%H%M%S")
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" NOICommunity/Info.plist
# Set the -configuration parameter to one of the following options:
# - "Release": uses the production Keycloak server
# - "Release TMA": uses the testingmachine-authentication Keycloak server
# - "Release DEVELOPER_MENU": same as "Release" but includes the Developer Menu
# - "Release TMA DEVELOPER_MENU": same as "Release TMA" but includes the Developer Menu
- name: Archive the project
run: |
set -eo pipefail
xcodebuild clean archive \
-configuration "Release" \
-scheme NOICommunity \
-sdk iphoneos \
-archivePath "$PWD/build/NOICommunity.xcarchive" \
-destination "generic/platform=iOS,name=Any iOS Device"
- name: Export .ipa
run: |
set -eo pipefail
xcodebuild -archivePath "$PWD/build/NOICommunity.xcarchive" \
-exportOptionsPlist exportOptions.plist \
-exportPath $PWD/build \
-allowProvisioningUpdates \
-exportArchive
- name: Publish the App on TestFlight
if: success()
env:
APPLEID_USERNAME: ${{ secrets.APPLEID_USERNAME }}
APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }}
run: |
xcrun altool \
--upload-app \
-t ios \
-f $PWD/build/NOICommunity.ipa \
-u "$APPLEID_USERNAME" \
-p "$APPLEID_PASSWORD" \
--verbose
- name: Upload dSYMs to Firebase Crashlytics
if: success()
run: |
BUILD_DIR=$(xcodebuild -showBuildSettings | grep -m 1 "BUILD_DIR" | cut -d'=' -f2)
${BUILD_DIR%Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/upload-symbols \
-gsp "NOICommunity/GoogleService-Info.plist" \
-p ios \
"$PWD/build/NOICommunity.xcarchive/dSYMs"