-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
116 lines (112 loc) · 5.61 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
name: 'Publish iOS Application to Appstore'
description: 'Publish iOS Application to Testflight'
author: 'UmutSERIFLER'
branding:
icon: 'cast'
color: 'green'
inputs:
projectName:
description: "Project name is an input that will be used for action"
required: true
certificateBase64:
description: "Encrypted certificate Base64"
required: true
p12FilePassword:
description: "Password is used for p12"
required: true
provisionProfileBase64:
description: "Provision Profile is encrypted Base64"
required: true
keychainPassword:
description: "Keychain Password to save p12 file"
required: true
appstoreAPIKey:
description: "AppStore API Key to upload app"
required: true
appstoreAPIKeyID:
description: "AppStore API Key ID to upload app"
required: true
appstoreAPIIssuer:
description: "AppStore API Key Issuer to upload app"
required: true
teamID:
description: "Team ID for app group"
required: true
mobileProvision:
description: "Mobile Provision Name"
required: true
runs:
using: 'composite'
steps:
- name: Clean Project
run: |
xcodebuild clean -project ${{ inputs.projectName }}.xcodeproj -scheme ${{ inputs.projectName }} -destination 'generic/platform=iOS'
shell: bash
- name: Build for Testing
run: |
xcodebuild build-for-testing -scheme ${{ inputs.projectName }} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
shell: bash
- name: Test Without Building
run: |
xcodebuild test-without-building -scheme ${{ inputs.projectName }} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.2'
shell: bash
- name: Install the Apple certificate and provisioning profile
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 "${{ inputs.certificateBase64 }}" | base64 --decode -o $CERTIFICATE_PATH
echo -n "${{ inputs.provisionProfileBase64 }}" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "${{ inputs.keychainPassword }}" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "${{ inputs.keychainPassword }}" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "${{ inputs.p12FilePassword }}" -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
shell: bash
- name: Clean Project
run: |
xcodebuild clean -project ${{ inputs.projectName }}.xcodeproj -scheme ${{ inputs.projectName }} -destination 'generic/platform=iOS' -configuration Release
shell: bash
- name: Build Project
run: |
xcodebuild build -project ${{ inputs.projectName }}.xcodeproj -scheme ${{ inputs.projectName }} -destination 'generic/platform=iOS' -allowProvisioningUpdates -configuration Release
shell: bash
- name: Archive Project
run: |
xcodebuild archive -project ${{ inputs.projectName }}.xcodeproj -scheme ${{ inputs.projectName }} -destination 'generic/platform=iOS' -archivePath ./build/archive/${{ inputs.projectName }}.xcarchive
shell: bash
- name: Import Data to Plist & Increase Build Number
run: |
plutil -insert method -string app-store ./build/archive/${{ inputs.projectName }}.xcarchive/Info.plist
plutil -insert provisioningProfiles -json '{"${{ inputs.teamID }}":"${{ inputs.mobileProvision }}"}' ./build/archive/${{ inputs.projectName }}.xcarchive/Info.plist
oldVersion=$(plutil -extract "ApplicationProperties.CFBundleVersion" raw ./build/archive/${{ inputs.projectName }}.xcarchive/Info.plist)
newVersion="$(($oldVersion+1))"
echo New Version $newVersion
plutil -replace "ApplicationProperties.CFBundleVersion" -string "$newVersion" ./build/archive/${{ inputs.projectName }}.xcarchive/Info.plist
plutil -p ./build/archive/${{ inputs.projectName }}.xcarchive/Info.plist
shell: bash
- name: Export Archive
run: |
xcodebuild -exportArchive -archivePath ./build/archive/${{ inputs.projectName }}.xcarchive -exportPath $RUNNER_TEMP/export -exportOptionsPlist ./build/archive/${{ inputs.projectName }}.xcarchive/Info.plist -configuration Release -allowProvisioningUpdates
shell: bash
- name: Authentication Keys Decode Step
run: |
mkdir -p ~/private_keys
echo -n "${{ inputs.appstoreAPIKey }}" | base64 --decode --o ~/private_keys/AuthKey_${{ inputs.appstoreAPIKeyID }}.p8
echo "Private Key has been implemented"
shell: bash
- name: Validate App
run: |
xcrun altool --validate-app -f /Users/runner/work/_temp/export/${{ inputs.projectName }}.ipa -t ios --apiKey ${{ inputs.appstoreAPIKeyID }} --apiIssuer ${{ inputs.appstoreAPIIssuer }} --show-progress --verbose --output-format json
shell: bash
- name: Upload App
run: |
xcrun altool --upload-app -f /Users/runner/work/_temp/export/${{ inputs.projectName }}.ipa -t ios --apiKey ${{ inputs.appstoreAPIKeyID }} --apiIssuer ${{ inputs.appstoreAPIIssuer }} --show-progress --verbose --output-format json
shell: bash