Skip to content

Commit

Permalink
Fixup flags and make them verbose (#5)
Browse files Browse the repository at this point in the history
Fixup flags and make them verbose
  • Loading branch information
Sean Robertson authored Nov 21, 2019
2 parents 223de5a + f6a2893 commit 4fc1c95
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hooks/command
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,17 @@ function get_signing_identity {
# identity: The identity to use for signing.
function sign_and_validate {
signing_target="${1}"
identity="${2}"
keychain="${2}"
identity="${3}"

codesign --verify --verbose --display --deep -s "${identity}" "${signing_target}"
codesign --verbose --display --deep --keychain "${codesigning_keychain}" --sign "${identity}" "${signing_target}"
retval=$?
if [[ "${retval}" -ne 0 ]]; then
echo "codesigning of target '${signing_target}' failed: error code '${retval}'"
exit 4
fi

codesign --verify --deep --strict "${signing_target}"
codesign --verify --verbose --deep --strict "${signing_target}"
retval=$?
if [[ "${retval}" -ne 0 ]]; then
echo "Unable to verify that '${signing_target}' has a valid code signature: error code '${retval}'"
Expand Down Expand Up @@ -136,7 +137,7 @@ echo "--- Unlocking the keychain"
unlock_keychain "${codesigning_keychain}" "${keychain_pw}"

echo "--- Finding the code signing identity in the unlocked keychain"
identity=$(get_signing_identity "${BUILDKITE_PLUGIN_MAC_CODESIGN_KEYCHAIN}")
identity=$(get_signing_identity "${codesigning_keychain}")

# Sign things in a local dir so the uploaded artifacts don't have a weird path
signed_dir_fragment="signed"
Expand All @@ -151,7 +152,7 @@ for artifact in $(plugin_read_list INPUT_ARTIFACTS) ; do
unsigned_artifact="$(fetch_artifact ${artifact} ${relative_artifacts_dir})"

echo "${artifact}: signing binary"
signed_artifact="$(sign_and_validate "${unsigned_artifact}" "${identity}")"
signed_artifact="$(sign_and_validate "${unsigned_artifact}" "${codesigning_keychain}" "${identity}")"

# The pushd/popd/dirname/basename shenanigans are so the artifact path in BK is friendlier. EG -
# "signed/$BINARY_NAME"
Expand Down

0 comments on commit 4fc1c95

Please sign in to comment.