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

Add support for more codesign arguments #81

Merged
merged 5 commits into from
Aug 12, 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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
zip: all
manifest-path: test-crate/Cargo.toml
codesign: '-'
codesign-prefix: 'com.example.'
codesign-options: 'runtime'
- name: Check action outputs
run: |
echo "outputs.archive should not be empty"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Currently, this action is basically intended to be used in combination with an a
| profile | false | The cargo profile to build. This defaults to the release profile. | String | `release` |
| dry-run | false | Build and compress binaries, but do not upload them (see [action.yml](action.yml) for more) | Boolean | `false` |
| codesign | false | Sign build products using `codesign` on macOS | String | |
| codesign-prefix | false | Prefix for the `codesign` identifier on macOS | String | |
| codesign-options | false | Specifies a set of option flags to be embedded in the code signature on macOS. See the `codesign` manpage for details. | String | |

\[1] Required one of `token` input option or `GITHUB_TOKEN` environment variable. Not required when `dry-run` input option is set to `true`.<br>
\[2] This is optional but it is recommended that this always be set to clarify which target you are building for if macOS is included in the matrix because GitHub Actions changed the default architecture of macos-latest since macos-14.<br>
Expand Down
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ inputs:
codesign:
description: Sign build products using `codesign` on macOS
required: false
codesign-prefix:
description: Prefix for the `codesign` identifier on macOS
required: false
codesign_prefix:
description: Alias for 'codesign-prefix'
required: false
codesign-options:
description: Specifies a set of option flags to be embedded in the code signature on macOS. See the codesign manpage for details.
required: false
codesign_options:
description: Alias for 'codesign-options'
required: false

outputs:
archive:
Expand Down Expand Up @@ -149,3 +161,5 @@ runs:
INPUT_PROFILE: ${{ inputs.profile }}
INPUT_DRY_RUN: ${{ inputs.dry-run || inputs.dry_run }}
INPUT_CODESIGN: ${{ inputs.codesign }}
INPUT_CODESIGN_PREFIX: ${{ inputs.codesign-prefix || inputs.codesign_prefix }}
INPUT_CODESIGN_OPTIONS: ${{ inputs.codesign-options || inputs.codesign_options }}
10 changes: 9 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,16 @@ build() {
do_codesign() {
target_dir="$1"
if [[ -n "${INPUT_CODESIGN:-}" ]]; then
codesign_options=(--sign "${INPUT_CODESIGN}")
if [[ -n "${INPUT_CODESIGN_PREFIX:-}" ]]; then
codesign_options+=(--prefix "${INPUT_CODESIGN_PREFIX}")
fi
if [[ -n "${INPUT_CODESIGN_OPTIONS:-}" ]]; then
codesign_options+=(--options "${INPUT_CODESIGN_OPTIONS}")
fi

for bin_exe in "${bins[@]}"; do
x codesign --sign "${INPUT_CODESIGN}" "${target_dir}/${bin_exe}"
x codesign "${codesign_options[@]}" "${target_dir}/${bin_exe}"
done
fi
}
Expand Down
Loading