-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (115 loc) · 5.73 KB
/
ios.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
name: iOS
on:
push:
branches:
- main
- ci-version-code # TODO: this is a temporary branch for testing (REMOVE)
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: macos-latest
steps:
- name: Check Xcode version
run: /usr/bin/xcodebuild -version
- name: Checkout Repo
uses: actions/checkout@v4
- name: Get Build Number
uses: ./.github/workflows/build-number.yml
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_DEV_CERT }}
DISTRIBUTION_CERTIFICATE_BASE64: ${{ secrets.IOS_DISTRIBUTION_CERT }}
P12_PASSWORD: ${{ secrets.IOS_CERT_PASSWORD }}
DISTRIBUTION_P12_PASSWORD: ${{ secrets.IOS_DISTRO_CERT_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.IOS_PROVISIONING_PROFILE }}
DISTRIBUTION_PROFILE_BASE64: ${{ secrets.IOS_DISTRIBUTION_PROFILE }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
BUILD_CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
DISTRO_CERTIFICATE_PATH=$RUNNER_TEMP/distro_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
DISTRO_PP_PATH=$RUNNER_TEMP/distro_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo "$BUILD_CERTIFICATE_BASE64" | sed 's/[^A-Za-z0-9+/=]//g' | base64 --decode -o $BUILD_CERTIFICATE_PATH
echo "$DISTRIBUTION_CERTIFICATE_BASE64" | sed 's/[^A-Za-z0-9+/=]//g' | base64 --decode -o $DISTRO_CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
echo -n "$DISTRIBUTION_PROFILE_BASE64" | base64 --decode -o $DISTRO_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 $BUILD_CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
echo "imported build cert"
security import $DISTRO_CERTIFICATE_PATH -P "$DISTRIBUTION_P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
echo "imported distribution cert"
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $DISTRO_PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
cache: gradle
- name: Setup gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
# DEBUG: print out all environment variables
- name: Output Run ID
run: echo ${{ github.run_id }}
- name: Output Run Number
run: echo ${{ github.run_number }}
- name: Output Run Attempt
run: echo ${{ github.run_attempt }}
- name: Generate Version Code
run: |
echo "VERSION_CODE=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
- name: Build Artifact with Xcode
run: xcodebuild -project iosApp/iosApp.xcodeproj -scheme iosApp -configuration Debug -destination generic/platform=iOS -archivePath $RUNNER_TEMP/Tidy.xcarchive archive
- name: Upload Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: iOS Archive
path: ${{ runner.temp }}/**/*.xcarchive
# Only run the following steps when a push event occurs on main branch
- name: Build IPA Artifact with Xcode
if: github.event_name == 'push'
env:
IOS_EXPORT_OPTIONS: ${{ secrets.IOS_EXPORT_OPTIONS }}
run: |
EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist
echo -n "$IOS_EXPORT_OPTIONS" | base64 --decode -o $EXPORT_OPTS_PATH
xcodebuild -exportArchive -archivePath $RUNNER_TEMP/Tidy.xcarchive -exportPath $RUNNER_TEMP -exportOptionsPlist $EXPORT_OPTS_PATH
- name: Upload to Github Artifacts
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: app
path: ${{ runner.temp }}/**/*.ipa
- name: Upload to TestFlight
if: github.event_name == 'push'
env:
IOS_APPSTORE_PRIVATE_KEY: ${{ secrets.IOS_APPSTORE_PRIVATE_KEY }}
APPSTORE_API_KEY_ID: ${{ secrets.IOS_APPSTORE_API_KEY_ID }}
run: |
mkdir -p ./private_keys
echo "$IOS_APPSTORE_PRIVATE_KEY" | sed 's/[^A-Za-z0-9+/=]//g' | base64 --decode -o "./private_keys/AuthKey_$APPSTORE_API_KEY_ID.p8"
xcrun altool --validate-app -f ${{ runner.temp }}/Tidy.ipa -t ios --apiKey "$APPSTORE_API_KEY_ID" --apiIssuer ${{ secrets.IOS_APPSTORE_ISSUER_ID }}
xcrun altool --upload-app -f ${{ runner.temp }}/Tidy.ipa -t ios --apiKey "$APPSTORE_API_KEY_ID" --apiIssuer ${{ secrets.IOS_APPSTORE_ISSUER_ID }}
# - name: Upload app to TestFlight
# if: github.event_name == 'push'
# uses: apple-actions/upload-testflight-build@v1
# with:
# app-path: $RUNNER_TEMP/Tidy.ipa
# issuer-id: ${{ secrets.IOS_APPSTORE_ISSUER_ID }}
# api-key-id: ${{ secrets.IOS_APPSTORE_API_KEY_ID }}
# api-private-key: $RUNNER_TEMP/appstore_private_key.p8