Skip to content

Commit 42f62f3

Browse files
authored
Merge pull request #75 from mxcl/api
2 parents 7375a11 + 89df3df commit 42f62f3

10 files changed

Lines changed: 606 additions & 387 deletions

File tree

.github/workflows/checks.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,38 @@ jobs:
110110
echo >&2 "error: expected action to fail, but it succeeded"
111111
exit 1
112112
113+
missing-api-key-id-fails:
114+
runs-on: macos-latest
115+
steps:
116+
- uses: actions/checkout@v2
117+
- uses: ./
118+
id: xcodebuild
119+
with:
120+
authentication-key-base64: 'Cg=='
121+
authentication-key-issuer-id: '14sb3dw0-r3t1-83u1-g381-4k9sg1t3w8r2'
122+
working-directory: fixtures/debug
123+
continue-on-error: true
124+
- if: steps.xcodebuild.outcome == 'success'
125+
run: |
126+
echo >&2 "error: expected action to fail, but it succeeded"
127+
exit 1
128+
129+
missing-api-key-issuer-id-fails:
130+
runs-on: macos-latest
131+
steps:
132+
- uses: actions/checkout@v2
133+
- uses: ./
134+
id: xcodebuild
135+
with:
136+
authentication-key-base64: 'Cg=='
137+
authentication-key-id: 'JW271KX2u3'
138+
working-directory: fixtures/debug
139+
continue-on-error: true
140+
- if: steps.xcodebuild.outcome == 'success'
141+
run: |
142+
echo >&2 "error: expected action to fail, but it succeeded"
143+
exit 1
144+
113145
null-none-action:
114146
runs-on: macos-latest
115147
strategy:

README.md

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ if you think we could have figured it out but didn’t please open a ticket.
142142

143143
GitHub’s images have a **limited selection** of Xcodes.
144144

145-
- GitHub list what is available for the current 10.15 image [here][gha-xcode-list].
145+
- GitHub list what is available for the current [10.15][gha-xcode-list-catalina]
146+
and [11][gha-xcode-list-big-sur] images.
146147
- We run a scheduled workflow to determine what is available [here][automated-list].
147148

148149
To install other versions first use [sinoru/actions-setup-xcode], then
@@ -174,31 +175,105 @@ This behavior cannot currently be disabled, PR welcome.
174175

175176
## Code Signing
176177

178+
> This feature requires macOS.
179+
180+
Code signing can be enabled with either an App Store Connect API key, or with a
181+
certificate.
182+
183+
### Using an App Store Connect API Key
184+
185+
> This feature requires Xcode 13 or later.
186+
187+
[Create][create-api-key-instructions] an API key on
188+
[App Store Connect][create-api-key]. Download your key and Base64-encode it:
189+
190+
```bash
191+
base64 AuthKey_9XXXX9XXXX.p8
192+
```
193+
194+
Create [GitHub Secrets][secrets] for your base64-encoded key, the key ID, and
195+
the key's issuer ID. The IDs are displayed on App Store Connect.
196+
177197
```yaml
178198
jobs:
179199
build:
180200
runs-on: macos-latest
181201
steps:
182202
- use: mxcl/xcodebuild@v1
183203
with:
184-
code-sign-certificate: ${{ secrets.CERTIFICATE_BASE64 }}
185-
code-sign-certificate-passphrase: ${{ secrets.CERTIFICATE_PASSPHRASE}}
204+
authentication-key-base64: ${{ secrets.APP_STORE_CONNECT_KEY_BASE64 }}
205+
authentication-key-id: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
206+
authentication-key-issuer-id: ${{ secrets.APP_STORE_CONNECT_KEY_ISSER_ID }}
186207
```
187208

188-
> This feature requires macOS.
209+
Certificates and provisioning profiles will be created automatically using the
210+
App Store Connect API. Certificates will appear in your
211+
[list of certificates](cert-list) as `Created via API`.
212+
213+
Devices will be registered automatically. GitHub-hosted runners will appear in
214+
in your [list of devices](device-list) as `mac-NUMBER.local`.
215+
216+
> :warning: This may cause undesired behavior when using GitHub-hosted runners.
217+
> For best results, use App Store Connect API keys only on self-hosted runners.
218+
219+
For more information on this method of code signing, please review the
220+
["Distribute apps in Xcode with cloud signing"][cloud-signing] talk from WWDC21.
221+
222+
### Using a Specific Certificate
189223

190-
A code signing certificate can be installed to the macOS Keychain. It is
191-
automatically removed from the Keychain in a post action.
224+
If you are not able to use an App Store Connect API key, and you have a specific
225+
code signing certificate you'd like to use, it can be installed to the macOS
226+
Keychain. It is automatically removed from the Keychain in a post action.
227+
228+
```yaml
229+
jobs:
230+
build:
231+
runs-on: macos-latest
232+
steps:
233+
- use: mxcl/xcodebuild@v1
234+
with:
235+
code-sign-certificate: ${{ secrets.CERTIFICATE_BASE64 }}
236+
code-sign-certificate-passphrase: ${{ secrets.CERTIFICATE_PASSPHRASE}}
237+
```
192238

193239
To export your certificate from Xcode and Base64 encode it, follow
194240
[these instructions][export]. Store any secrets, including certificates and
195241
passphrases, in GitHub as [Encrypted Secrets][secrets].
196242

243+
### Specifying an Identity
244+
197245
You may specify a `code-sign-identity` to override any `CODE_SIGN_IDENTITY`
198246
specified by your project.
199247

248+
### Disabling Code Signing
249+
200250
To disable code signing, you can specify `code-sign-identity: '-'`.
201251
252+
### Provisioning Profiles
253+
254+
If you are not able to use an App Store Connect API key, and you have specific
255+
provisioning profiles you'd like to use, you can specify profiles for Mac
256+
`provisioning-profiles-base64`, or for iOS or other devices using
257+
`mobile-provisioning-profiles-base64`.
258+
259+
To export your provisioning profiles from Xcode and Base64 encode these, follow
260+
[these instructions][export]. Store any secrets, including provisioning
261+
profiles, in GitHub as [Encrypted Secrets][secrets].
262+
263+
```yaml
264+
jobs:
265+
build:
266+
runs-on: macos-latest
267+
steps:
268+
- use: mxcl/xcodebuild@v1
269+
with:
270+
mobile-provisioning-profiles-base64: |
271+
${{ secrets.IPHONE_PROVISIONING_PROFILE_BASE64 }}
272+
${{ secrets.IPAD_PROVISIONING_PROFILE_BASE64 }}
273+
provisioning-profiles-base64: |
274+
${{ secrets.MAC_PROVISIONING_PROFILE_BASE64 }}
275+
```
276+
202277
## Caveats
203278

204279
- The selected Xcode remains the default Xcode for the image for the duration of
@@ -265,7 +340,13 @@ This action does not support Windows.
265340
1. Create a [Pull Request](https://github.com/mxcl/xcodebuild/compare)
266341

267342
[automated-list]: https://flatgithub.com/mxcl/.github/?filename=versions.json
268-
[gha-xcode-list]: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode
343+
[cloud-signing]: https://developer.apple.com/videos/play/wwdc2021/10204/
344+
[create-api-key]: https://appstoreconnect.apple.com/access/api
345+
[create-api-key-instructions]: https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api
346+
[cert-list]: https://developer.apple.com/account/resources/certificates/list
347+
[device-list]: https://developer.apple.com/account/resources/devices/list
348+
[gha-xcode-list-catalina]: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode
349+
[gha-xcode-list-big-sur]: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#xcode
269350
[sinoru/actions-setup-xcode]: https://github.com/sinoru/actions-setup-xcode
270351
[img]: https://raw.githubusercontent.com/mxcl/xcodebuild/gh-pages/XCResult.png
271352
[secrets]: https://docs.github.com/en/actions/reference/encrypted-secrets

action.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,33 @@ inputs:
3232
description: Enables code coverage
3333
required: false
3434
default: 'false'
35+
authentication-key-base64:
36+
description: |
37+
A Base64-encoded authentication key issued by App Store Connect. If
38+
specified, `xcodebuild`` will authenticate with the Apple Developer
39+
website using this credential. The `authentication-key-id` and
40+
`authentication-key-issuer-id` parameters are required. Using this key,
41+
`xcodebuild` will register the GitHub Actions runner device and manage
42+
code signing certificates for it. Please note that this may cause
43+
undesired behavior when using GitHub-hosted runners. For best results, use
44+
App Store Connect API keys only on self-hosted runners.
45+
required: false
46+
authentication-key-id:
47+
description: |
48+
The key identifier associated with the App Store Conect authentication key
49+
specified in `authentication-key-base64`. This string can be located in
50+
the users and access details for your provider at
51+
"https://appstoreconnect.apple.com". For best results, use App Store
52+
Connect API keys only on self-hosted runners.
53+
required: false
54+
authentication-key-issuer-id:
55+
description: |
56+
The App Store Connect issuer identifier associated with the authentication
57+
key specified in `authentication-key-base64`. This string can be located
58+
in the users and access details for your provider at
59+
"https://appstoreconnect.apple.com". For best results, use App Store
60+
Connect API keys only on self-hosted runners.
61+
required: false
3562
code-sign-certificate:
3663
description: |
3764
A Base64-encoded certificate to be installed to the macOS Keychain for
@@ -51,6 +78,14 @@ inputs:
5178
Identity to be used for code signing. If your project specifies a
5279
`CODE_SIGN_IDENTITY`, this will override it.
5380
required: false
81+
mobile-provisioning-profiles-base64:
82+
description: |
83+
A multiline list of Base64-encoded mobile provisioning profiles.
84+
required: false
85+
provisioning-profiles-base64:
86+
description: |
87+
A multiline list of Base64-encoded Mac provisioning profiles.
88+
required: false
5489
working-directory:
5590
description: ''
5691
required: false

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sourcemap-register.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)