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

feat: run codesign on macOS #61

Merged
merged 7 commits into from
Dec 3, 2023
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
1 change: 1 addition & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ gtar
lipo
mktemp
zigbuild
codesign
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ jobs:
tar: all
zip: all
manifest-path: test-crate/Cargo.toml
codesign: '-'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Currently, this action is basically intended to be used in combination with an a
| manifest-path | false | Path to Cargo.toml | String | `Cargo.toml` |
| 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 | |

\[1] Required one of `token` input option or `GITHUB_TOKEN` environment variable. Not required when `dry-run` input option is set to `true`.

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ inputs:
description: Alias for 'dry-run'
required: false
default: 'false'
codesign:
description: Sign build products using `codesign` on macOS
required: false

# Note:
# - inputs.* should be manually mapped to INPUT_* due to https://github.com/actions/runner/issues/665
Expand Down Expand Up @@ -117,3 +120,4 @@ runs:
INPUT_REF: ${{ inputs.ref }}
INPUT_PROFILE: ${{ inputs.profile }}
INPUT_DRY_RUN: ${{ inputs.dry-run || inputs.dry_run }}
INPUT_CODESIGN: ${{ inputs.codesign }}
12 changes: 12 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ do_strip() {
done
fi
}
do_codesign() {
target_dir="$1"
if [[ -n "${INPUT_CODESIGN:-}" ]]; then
for bin_exe in "${bins[@]}"; do
x codesign --sign "${INPUT_CODESIGN}" "${target_dir}/${bin_exe}"
done
fi
}

case "${INPUT_TARGET:-}" in
'')
Expand Down Expand Up @@ -336,6 +344,10 @@ case "${INPUT_TARGET:-}" in
;;
esac

if command -v codesign &>/dev/null; then
do_codesign "${target_dir}"
fi

if [[ "${INPUT_TAR/all/${platform}}" == "${platform}" ]] || [[ "${INPUT_ZIP/all/${platform}}" == "${platform}" ]]; then
cwd=$(pwd)
tmpdir=$(mktemp -d)
Expand Down
Loading