mirror of
https://github.com/BloopAI/apple-code-sign-action.git
synced 2026-08-23 12:28:32 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21e6f8327e | ||
|
|
a00d97f64d | ||
|
|
e513b347e2 | ||
|
|
73aa91133e | ||
|
|
5590f32ee8 | ||
|
|
cb7589dd10 | ||
|
|
7833348d60 | ||
|
|
f6c06bf15d | ||
|
|
7bfe322d33 | ||
|
|
f30a36a011 | ||
|
|
2f12e94a4f | ||
|
|
ee15cda862 | ||
|
|
0eaa356b2b | ||
|
|
d39c8a8a72 | ||
|
|
de0535843d | ||
|
|
37549037a5 | ||
|
|
579c4a847f | ||
|
|
36cd284d61 | ||
|
|
44d0985b7f | ||
|
|
4faec512b2 | ||
|
|
165551546a | ||
|
|
43dfc37334 | ||
|
|
209077882c | ||
|
|
b744d20f21 | ||
|
|
48a26101e4 | ||
|
|
9b1d704b84 | ||
|
|
691f3baeab | ||
|
|
8b7951bc50 | ||
|
|
ba99b5bfe7 | ||
|
|
9302c685ae | ||
|
|
17d1ceb43d |
10
.github/linters/.yaml-lint.yml
vendored
10
.github/linters/.yaml-lint.yml
vendored
@@ -1,10 +0,0 @@
|
||||
rules:
|
||||
document-end: disable
|
||||
document-start:
|
||||
level: warning
|
||||
present: false
|
||||
line-length:
|
||||
level: warning
|
||||
max: 80
|
||||
allow-non-breakable-words: true
|
||||
allow-non-breakable-inline-mappings: true
|
||||
13
.github/workflows/check-dist.yml
vendored
13
.github/workflows/check-dist.yml
vendored
@@ -8,16 +8,7 @@
|
||||
# what is expected from the build.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
@@ -58,7 +49,7 @@ jobs:
|
||||
|
||||
# If index.js was different than expected, upload the expected version as
|
||||
# a workflow artifact.
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
|
||||
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@@ -1,11 +1,6 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "releases/*"
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
test-javascript:
|
||||
@@ -60,7 +55,7 @@ jobs:
|
||||
env:
|
||||
PEM_KEY: ${{ secrets.DEVELOPER_ID_APPLICATION_PEM_KEY }}
|
||||
run: |
|
||||
echo $PEM_KEY | tr ' ' '\n' > key.pem
|
||||
echo "$PEM_KEY" | tr ' ' '\n' > key.pem
|
||||
|
||||
- name: Test Sign PEM Source
|
||||
uses: ./
|
||||
|
||||
14
.github/workflows/linter.yml
vendored
14
.github/workflows/linter.yml
vendored
@@ -1,12 +1,6 @@
|
||||
name: Lint Code Base
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -36,9 +30,13 @@ jobs:
|
||||
|
||||
- name: Lint Code Base
|
||||
id: super-linter
|
||||
uses: super-linter/super-linter/slim@v5
|
||||
uses: super-linter/super-linter/slim@v7
|
||||
env:
|
||||
DEFAULT_BRANCH: main
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JAVASCRIPT_DEFAULT_STYLE: prettier
|
||||
VALIDATE_CHECKOV: false
|
||||
VALIDATE_GITLEAKS: false
|
||||
VALIDATE_JSCPD: false
|
||||
VALIDATE_MARKDOWN: false
|
||||
VALIDATE_NATURAL_LANGUAGE: false
|
||||
|
||||
26
README.md
26
README.md
@@ -28,8 +28,12 @@ It is up to the caller to do something with the file/directory operated on.
|
||||
See [action.yml](action.yml) for the set of inputs. The file should be
|
||||
self-documenting.
|
||||
|
||||
The only output is `output_path`, which holds the filesystem path of the
|
||||
signed/notarized/stapled entity.
|
||||
The outputs are:
|
||||
|
||||
- `output_path`: filesystem path of the signed/notarized/stapled entity (or the
|
||||
first path when multiple `input_path` values are provided).
|
||||
- `output_paths`: newline-separated list of output paths when multiple
|
||||
`input_path` values are provided.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -147,3 +151,21 @@ steps:
|
||||
app_store_connect_api_issuer: 'abcdef-42-2411312...'
|
||||
app_store_connect_api_key: 'DEADBEEF'
|
||||
```
|
||||
|
||||
Notarize multiple signed assets in parallel.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
# Add steps here to materialize signed assets (.app/.zip/.dmg/etc).
|
||||
|
||||
- name: Notarize (parallel)
|
||||
uses: BloopAI/apple-code-sign-action@v1
|
||||
with:
|
||||
input_path: |
|
||||
MyApp.zip
|
||||
MyOtherApp.zip
|
||||
sign: false
|
||||
notarize: true
|
||||
notarize_concurrency: 2
|
||||
app_store_connect_api_key_json_file: app_store_key.json
|
||||
```
|
||||
|
||||
10
action.yml
10
action.yml
@@ -26,6 +26,10 @@ inputs:
|
||||
description: 'Whether to notarize'
|
||||
default: 'false'
|
||||
|
||||
notarize_concurrency:
|
||||
description: 'Max parallel notarization submissions when input_path is multi-line (0 = unlimited)'
|
||||
default: '0'
|
||||
|
||||
# Attaches a pre-issued "notarization ticket" to an entity.
|
||||
staple:
|
||||
description: 'Whether to staple a notarization ticket'
|
||||
@@ -109,11 +113,13 @@ inputs:
|
||||
# this mechanism.
|
||||
rcodesign_version:
|
||||
description: 'Version of the rcodesign tool to use'
|
||||
default: '0.26.0'
|
||||
default: '0.28.0'
|
||||
|
||||
outputs:
|
||||
output_path:
|
||||
description: 'Path to signed/notarized/stapled entity'
|
||||
description: 'Path to signed/notarized/stapled entity (first when multiple input_path values)'
|
||||
output_paths:
|
||||
description: 'Newline-separated list of output paths when multiple input_path values are provided'
|
||||
|
||||
runs:
|
||||
using: node20
|
||||
|
||||
2284
dist/index.js
generated
vendored
2284
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
20
dist/licenses.txt
generated
vendored
20
dist/licenses.txt
generated
vendored
@@ -166,10 +166,22 @@ uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
5443
package-lock.json
generated
5443
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@@ -54,20 +54,20 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/tool-cache": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.23.3",
|
||||
"@babel/eslint-parser": "^7.23.3",
|
||||
"@babel/preset-env": "^7.23.3",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"babel-preset-jest": "^29.6.3",
|
||||
"eslint": "^8.54.0",
|
||||
"eslint-plugin-github": "^4.10.1",
|
||||
"eslint-plugin-jest": "^27.6.0",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.1.0"
|
||||
"@babel/core": "^7.26.0",
|
||||
"@babel/eslint-parser": "^7.28.5",
|
||||
"@babel/preset-env": "^7.28.5",
|
||||
"@vercel/ncc": "^0.38.4",
|
||||
"babel-preset-jest": "^30.2.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-github": "^5.0.2",
|
||||
"eslint-plugin-jest": "^29.12.1",
|
||||
"jest": "^30.2.0",
|
||||
"prettier": "^3.5.0"
|
||||
}
|
||||
}
|
||||
203
src/main.js
203
src/main.js
@@ -1,8 +1,51 @@
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const tool_cache = require('@actions/tool-cache')
|
||||
const toolCache = require('@actions/tool-cache')
|
||||
const os = require('os')
|
||||
|
||||
async function mapWithConcurrency(items, concurrency, fn) {
|
||||
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
||||
throw new Error('concurrency must be a positive integer')
|
||||
}
|
||||
|
||||
const results = new Array(items.length)
|
||||
let nextIndex = 0
|
||||
|
||||
async function worker() {
|
||||
for (let index = nextIndex++; index < items.length; index = nextIndex++) {
|
||||
results[index] = await fn(items[index], index)
|
||||
}
|
||||
}
|
||||
|
||||
const workers = Array.from(
|
||||
{ length: Math.min(concurrency, items.length) },
|
||||
() => worker()
|
||||
)
|
||||
await Promise.all(workers)
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
async function execRcodesign(rcodesign, args) {
|
||||
let stdout = ''
|
||||
let stderr = ''
|
||||
|
||||
const exitCode = await exec.exec(rcodesign, args, {
|
||||
silent: true,
|
||||
ignoreReturnCode: true,
|
||||
listeners: {
|
||||
stdout: data => {
|
||||
stdout += data.toString()
|
||||
},
|
||||
stderr: data => {
|
||||
stderr += data.toString()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return { exitCode, stdout, stderr }
|
||||
}
|
||||
|
||||
async function getRcodesign(version) {
|
||||
const platform = os.platform()
|
||||
const arch = os.arch()
|
||||
@@ -48,14 +91,14 @@ async function getRcodesign(version) {
|
||||
|
||||
core.info(`Downloading rcodesign from ${url}`)
|
||||
|
||||
const toolPath = await tool_cache.downloadTool(url)
|
||||
const toolPath = await toolCache.downloadTool(url)
|
||||
|
||||
let destDir
|
||||
|
||||
if (url.endsWith('.tar.gz')) {
|
||||
destDir = await tool_cache.extractTar(toolPath, 'rcodesign')
|
||||
destDir = await toolCache.extractTar(toolPath, 'rcodesign')
|
||||
} else {
|
||||
destDir = await tool_cache.extractZip(toolPath, 'rcodesign')
|
||||
destDir = await toolCache.extractZip(toolPath, 'rcodesign')
|
||||
}
|
||||
|
||||
let exe = `${destDir}/${directory}/rcodesign`
|
||||
@@ -68,10 +111,29 @@ async function getRcodesign(version) {
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const inputPath = core.getInput('input_path', { required: true })
|
||||
const inputPathRaw = core.getInput('input_path', { required: true })
|
||||
let inputPaths = core.getMultilineInput('input_path')
|
||||
if (inputPaths.length === 1 && inputPaths[0].includes('\n')) {
|
||||
inputPaths = inputPaths[0]
|
||||
.split(/\r?\n/)
|
||||
.map(line => line.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
if (inputPaths.length === 0) {
|
||||
throw new Error('input_path is required')
|
||||
}
|
||||
|
||||
const hasMultipleInputPaths = inputPaths.length > 1
|
||||
const inputPath = inputPaths[0] || inputPathRaw.trim()
|
||||
const outputPath = core.getInput('output_path')
|
||||
const sign = core.getBooleanInput('sign')
|
||||
const notarize = core.getBooleanInput('notarize')
|
||||
const notarizeConcurrencyInput = core.getInput('notarize_concurrency')
|
||||
const notarizeConcurrency = parseInt(notarizeConcurrencyInput || '0', 10)
|
||||
if (Number.isNaN(notarizeConcurrency) || notarizeConcurrency < 0) {
|
||||
throw new Error('notarize_concurrency must be a non-negative integer')
|
||||
}
|
||||
|
||||
const staple = core.getBooleanInput('staple')
|
||||
const configFiles = core.getMultilineInput('config_file')
|
||||
const profile = core.getInput('profile')
|
||||
@@ -96,9 +158,22 @@ async function run() {
|
||||
|
||||
const rcodesign = await getRcodesign(rcodesignVersion)
|
||||
|
||||
let signedPaths = inputPaths
|
||||
let signedPath = inputPath
|
||||
|
||||
if (hasMultipleInputPaths && outputPath) {
|
||||
throw new Error(
|
||||
'output_path cannot be used with multiple input_path values'
|
||||
)
|
||||
}
|
||||
|
||||
if (sign) {
|
||||
if (hasMultipleInputPaths) {
|
||||
throw new Error(
|
||||
'Multiple input_path values are not supported when sign=true'
|
||||
)
|
||||
}
|
||||
|
||||
const args = ['sign']
|
||||
|
||||
for (const path of configFiles) {
|
||||
@@ -143,6 +218,7 @@ async function run() {
|
||||
}
|
||||
|
||||
await exec.exec(rcodesign, args)
|
||||
signedPaths = [signedPath]
|
||||
}
|
||||
|
||||
let stapled = false
|
||||
@@ -176,9 +252,64 @@ async function run() {
|
||||
args.push('--wait')
|
||||
}
|
||||
|
||||
args.push(signedPath)
|
||||
const concurrency =
|
||||
notarizeConcurrency > 0 ? notarizeConcurrency : signedPaths.length
|
||||
|
||||
await exec.exec(rcodesign, args)
|
||||
core.info(`Submitting ${signedPaths.length} file(s) for notarization`)
|
||||
|
||||
const results = await mapWithConcurrency(
|
||||
signedPaths,
|
||||
concurrency,
|
||||
async path => {
|
||||
core.info(`Starting notarization: ${path}`)
|
||||
|
||||
const { exitCode, stdout, stderr } = await execRcodesign(rcodesign, [
|
||||
...args,
|
||||
path
|
||||
])
|
||||
|
||||
if (exitCode === 0) {
|
||||
return { path, ok: true, stdout, stderr }
|
||||
}
|
||||
|
||||
return { path, ok: false, exitCode, stdout, stderr }
|
||||
}
|
||||
)
|
||||
|
||||
const failures = results.filter(r => !r.ok)
|
||||
for (const result of results) {
|
||||
core.startGroup(
|
||||
result.ok
|
||||
? `notary-submit: ${result.path}`
|
||||
: `notary-submit failed: ${result.path}`
|
||||
)
|
||||
|
||||
if (!result.ok) {
|
||||
core.error(`exit code: ${result.exitCode}`)
|
||||
}
|
||||
|
||||
if (result.stdout.trim()) {
|
||||
if (result.ok) {
|
||||
core.info(result.stdout.trim())
|
||||
} else {
|
||||
core.error(result.stdout.trim())
|
||||
}
|
||||
}
|
||||
if (result.stderr.trim()) {
|
||||
if (result.ok) {
|
||||
core.info(result.stderr.trim())
|
||||
} else {
|
||||
core.error(result.stderr.trim())
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
if (failures.length > 0) {
|
||||
throw new Error(
|
||||
`Notarization failed for: ${failures.map(f => f.path).join(', ')}`
|
||||
)
|
||||
}
|
||||
|
||||
if (staple) {
|
||||
stapled = true
|
||||
@@ -192,12 +323,64 @@ async function run() {
|
||||
args.push('--config-file', path)
|
||||
}
|
||||
|
||||
args.push(signedPath)
|
||||
const concurrency =
|
||||
notarizeConcurrency > 0 ? notarizeConcurrency : signedPaths.length
|
||||
|
||||
await exec.exec(rcodesign, args)
|
||||
const results = await mapWithConcurrency(
|
||||
signedPaths,
|
||||
concurrency,
|
||||
async path => {
|
||||
core.info(`Stapling notarization ticket: ${path}`)
|
||||
|
||||
const { exitCode, stdout, stderr } = await execRcodesign(rcodesign, [
|
||||
...args,
|
||||
path
|
||||
])
|
||||
|
||||
if (exitCode === 0) {
|
||||
return { path, ok: true, stdout, stderr }
|
||||
}
|
||||
|
||||
return { path, ok: false, exitCode, stdout, stderr }
|
||||
}
|
||||
)
|
||||
|
||||
const failures = results.filter(r => !r.ok)
|
||||
for (const result of results) {
|
||||
core.startGroup(
|
||||
result.ok ? `staple: ${result.path}` : `staple failed: ${result.path}`
|
||||
)
|
||||
|
||||
if (!result.ok) {
|
||||
core.error(`exit code: ${result.exitCode}`)
|
||||
}
|
||||
|
||||
if (result.stdout.trim()) {
|
||||
if (result.ok) {
|
||||
core.info(result.stdout.trim())
|
||||
} else {
|
||||
core.error(result.stdout.trim())
|
||||
}
|
||||
}
|
||||
if (result.stderr.trim()) {
|
||||
if (result.ok) {
|
||||
core.info(result.stderr.trim())
|
||||
} else {
|
||||
core.error(result.stderr.trim())
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
if (failures.length > 0) {
|
||||
throw new Error(
|
||||
`Stapling failed for: ${failures.map(f => f.path).join(', ')}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
core.setOutput('output_path', signedPath)
|
||||
core.setOutput('output_path', signedPaths[0])
|
||||
core.setOutput('output_paths', signedPaths.join('\n'))
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user