Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conform to altool's path expectations #4

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

export async function appStoreConnectApiKey(
secretValue: string,
destinationDir: string = process.env.RUNNER_TEMP || ''
destinationDir: string = ''

Check failure on line 14 in src/app-store-connect-api-key.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Type string trivially inferred from a string literal, remove type annotation
): 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')

Check failure on line 19 in src/app-store-connect-api-key.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Replace `process.env.HOME·as·string,·'.appstoreconnect/private_keys'` with `⏎······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(

Check failure on line 24 in src/app-store-connect-api-key.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Replace `⏎····destinationDir,⏎····'keyinfo.json'⏎··` with `destinationDir,·'keyinfo.json'`
destinationDir,
'.app-store-connect-api-key.json'
'keyinfo.json'
)
fs.writeFileSync(apiKeyPath, decodedSecret)
const decodedPrivateKey = Buffer.from(
Expand All @@ -28,9 +32,14 @@
).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)

Check failure on line 41 in src/app-store-connect-api-key.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Replace `'app-store-connect-api-key-issuer-id',·appStoreAuthConfig.issuerId)··⏎` with `⏎····'app-store-connect-api-key-issuer-id',⏎····appStoreAuthConfig.issuerId⏎··)`

}

export async function buildAppStoreConnectApiKeyObject(
Expand Down
Loading