Skip to content

Commit

Permalink
Merge pull request #4 from nodeselector/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeselector authored Aug 2, 2024
2 parents 94d64ad + 3659e4a commit 1b2cba5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
13 changes: 13 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ inputs:
* The password for the keychain. * Only valid for the `certificate`
asset-type.
default: ''
outputs:
app-store-connect-api-key-key-id:
description: >
* The identifier of the App Store Connect API key. * Only valid for the
`app-store-connect-api-key` asset-type.
app-store-connect-api-key-issuer-id:
description: >
* The identifier of the App Store Connect API key issuer. * Only valid for
the `app-store-connect-api-key` asset-type.
app-store-connect-api-key-key-path:
description: >
* The private key of the App Store Connect API key. * Only valid for the
`app-store-connect-api-key` asset-type.
runs:
using: node20
main: dist/index.js
39 changes: 35 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions src/app-store-connect-api-key.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs'
import path from 'node:path'
import { spawn } from './spawn'
import * as core from '@actions/core'

type AppStoreAuthConfig = {
keyId: string
Expand All @@ -10,16 +11,19 @@ type AppStoreAuthConfig = {

export async function appStoreConnectApiKey(
secretValue: string,
destinationDir: string = process.env.RUNNER_TEMP || ''
destinationDir: string = ''
): Promise<void> {
if (!destinationDir) {
throw new Error('RUNNER_TEMP not set')
// see man altool for path expectations. most of the xcode tools allow you to specify a path
// but notably, not altool.
destinationDir = path.join(process.env.HOME as string, '.appstoreconnect/private_keys')
fs.mkdirSync(destinationDir, { recursive: true })
}
const decodedSecret = Buffer.from(secretValue, 'base64').toString('utf-8')
const appStoreAuthConfig: AppStoreAuthConfig = JSON.parse(decodedSecret)
const apiKeyPath = path.join(
destinationDir,
'.app-store-connect-api-key.json'
'keyinfo.json'
)
fs.writeFileSync(apiKeyPath, decodedSecret)
const decodedPrivateKey = Buffer.from(
Expand All @@ -28,9 +32,14 @@ export async function appStoreConnectApiKey(
).toString('utf-8')
const privateKeyPath = path.join(
destinationDir,
'.app-store-connect-api-key.p8'
`AuthKey_${appStoreAuthConfig.keyId}.p8` // altool expects this naming convention
)
fs.writeFileSync(privateKeyPath, decodedPrivateKey)

core.setOutput('app-store-connect-api-key-key-path', privateKeyPath)
core.setOutput('app-store-connect-api-key-key-id', appStoreAuthConfig.keyId)
core.setOutput('app-store-connect-api-key-issuer-id', appStoreAuthConfig.issuerId)

}

export async function buildAppStoreConnectApiKeyObject(
Expand Down

0 comments on commit 1b2cba5

Please sign in to comment.