-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaction.yml
191 lines (189 loc) · 7.01 KB
/
action.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
name: 'XCode-Deploy'
description: 'Archive, Export, and Upload a build to App Store Connect (TestFlight)'
author: 'Vincent Frascello'
branding:
icon: 'upload-cloud'
color: 'yellow'
inputs:
xcode-version:
description: 'The version of XCode to use. Defaults to the latest stable version.'
requred: false
default: 'latest-stable'
configuration:
description: 'Configuration (default: Release)'
required: true
default: 'Release'
scheme:
description: 'Leave blank and Action will search for default scheme.'
required: false
default: ''
path-to-export-options:
description: 'Relative path and filename to ExportOptions.plist'
required: true
default: 'ExportOptions.plist'
update-build:
description: 'Sets Build Number to # of commits.'
required: true
default: true
type: choice
options:
- true
- false
install-pods:
description: 'Run Pod Install'
required: true
default: false
type: choice
options:
- true
- false
resolve-package-dependencies:
description: 'Resolve Package Dependencies'
required: true
default: false
type: choice
options:
- true
- false
distribution-certificate-p12:
description: 'base64 representation of the distribution certificate.'
required: true
distribution-certificate-password:
description: 'password to unlock the distribution certificate.'
required: true
app-store-provisioning-profile:
description: 'base64 representation of the provisioning profile.'
required: true
auth-key-id:
description: 'App Store Connect API Auth Key ID.'
required: true
auth-key-issuer-id:
description: 'App Store Connect API Issuer ID.'
required: true
auth-key-p8:
description: 'base64 representation of the App Store Connect AuthKey.'
required: true
runs:
using: 'composite'
steps:
- name: Sanitize input
shell: bash
env:
SCHEME: ${{ inputs.scheme }}
CONFIGURATION: ${{ inputs.configuration }}
PATH_TO_EXPORT_OPTIONS: ${{ inputs.path-to-export-options }}
run: |
echo "[XCode-Deploy]: Checking Input for invalid characters..."
if [[ "$SCHEME" == ${SCHEME//[^a-zA-Z0-9_\.- ]/} ]] && \
[[ "$CONFIGURATION" == ${CONFIGURATION//[^a-zA-Z0-9_\.- ]/} ]] && \
[[ "$PATH_TO_EXPORT_OPTIONS" == ${PATH_TO_EXPORT_OPTIONS//^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\.[a-zA-Z0-9_-]+$/} ]]; then
echo "Inputs OK"
exit 0
else
echo "Bad Inputs"
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine File To Build
shell: bash
run: |
echo "[XCode-Deploy]: Determining file to build..."
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" \
&& file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; \
else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
echo "TYPE=$filetype_parameter" >> $GITHUB_ENV
echo "FILE_TO_BUILD=$file_to_build" >> $GITHUB_ENV
echo "PROJECT_NAME=$(echo "$file_to_build" | cut -f 1 -d '.')" >> $GITHUB_ENV
- name: Setup Pods
if: inputs.install-pods == 'true'
shell: bash
run: |
echo "[XCode-Deploy]: Installing Pods..."
pod install
- name: Resolve Package Dependencies
if: inputs.resolve-package-dependencies == 'true'
shell: bash
run: |
echo "[XCode-Deploy]: Resolving Package Dependencies..."
xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath .
- name: Setup Scheme
shell: bash
run: |
echo "[XCode-Deploy]: Searching for default Scheme..."
if [ "${{ inputs.scheme }}" == "" ]; then
scheme_list=$(xcodebuild -list -json | tr -d "\n")
scheme=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]")
echo $scheme | cat >scheme
echo "[XCode-Deploy]: Using default scheme: $scheme..."
else
echo "[XCode-Deploy]: Using provided Scheme: ${{ inputs.scheme }}"
scheme=${{ inputs.scheme }}
fi
echo "SCHEME=$scheme" >> $GITHUB_ENV
- name: Import Certificates
uses: apple-actions/import-codesign-certs@v1
id: codesign
with:
p12-file-base64: ${{ inputs.distribution-certificate-p12 }}
p12-password: ${{ inputs.distribution-certificate-password }}
keychain: codesign
- name: Install App Store Profile
uses: akiojin/install-provisioning-profile-github-action@v1.0
with:
base64: ${{ inputs.app-store-provisioning-profile }}
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1.4.1
with:
xcode-version: ${{ inputs.xcode-version }}
- name: Increment Build Number
shell: bash
if: inputs.update-build == 'true'
run: |
echo "[XCode-Deploy]: Updating Build Number to commit depth..."
count=`git rev-list --count HEAD`
xcrun agvtool new-version -all $count
- name: Build and Archive
uses: sersoft-gmbh/xcodebuild-action@v2
with:
action: archive
${{ env.TYPE }}: ${{ env.FILE_TO_BUILD }}
scheme: ${{ env.SCHEME }}
sdk: iphoneos
build-settings: >
-archivePath ${{ env.PROJECT_NAME }}.xcarchive
derived-data-path: build/derivedData
destination: generic/platform=iOS
configuration: ${{ inputs.configuration }}
- name: Get App Store Connect API Key
uses: timheuer/base64-to-file@v1.1
with:
fileName: AuthKey_${{ inputs.auth-key-id }}.p8
fileDir: ${{ github.workspace }}/private_keys
encodedString: ${{ inputs.auth-key-p8 }}
- name: Export Xcode archive
shell: bash
run: |
echo "[XCode-Deploy]: Exporting archive using xcodebuild..."
xcodebuild -exportArchive -verbose \
-sdk iphoneos \
-archivePath ${{ github.workspace }}/${{ env.PROJECT_NAME }}.xcarchive \
-exportOptionsPlist ${{ github.workspace }}/${{ inputs.path-to-export-options }} \
-exportPath ${{ github.workspace }} \ -authenticationKeyIssuerID ${{ inputs.auth-key-issuer-id }} \
-authenticationKeyID ${{ inputs.auth-key-id }} \
-authenticationKeyPath ${{ github.workspace }}/private_keys/AuthKey_${{ inputs.auth-key-id }}.p8 \
- name: Upload to App Store Connect
shell: bash
run: |
echo "[XCode-Deploy]: Uploading archive using altool..."
xcrun altool --upload-app -f ${{ github.workspace }}/${{ env.PROJECT_NAME }}.ipa -t iOS \
--apiIssuer ${{ inputs.auth-key-issuer-id }} --apiKey ${{ inputs.auth-key-id }}
- name: Cleanup
shell: bash
run: |
echo "[XCode-Deploy]: Removing Keychain and private_keys folder..."
security delete-keychain codesign.keychain
rm -rf ${{ github.workspace }}/private_keys || true