Skips signing when there is no upload URL (#5120)

* Skips signing when there is no upload URL so we can run the scripts locally

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Fixes prebuild command and improves post build command to not depend on psiexec

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-11-01 11:06:04 -07:00
committed by GitHub
parent fa83a1fff8
commit 2cc4f322b7
2 changed files with 74 additions and 42 deletions
+29 -9
View File
@@ -6,21 +6,41 @@
#
#
if(NOT CPACK_UPLOAD_URL) # Skip signing if we are not uploading the package
return()
endif()
file(REAL_PATH "${CPACK_SOURCE_DIR}/.." _root_path)
set(_cpack_wix_out_dir ${CPACK_TOPLEVEL_DIRECTORY})
file(TO_NATIVE_PATH "${_root_path}/scripts/signer/Platform/Windows/signer.ps1" _sign_script)
set(_signing_command
psexec.exe
-accepteula
-nobanner
-s
powershell.exe
unset(_signing_command)
find_program(_psiexec_path psexec.exe)
if(_psiexec_path)
list(APPEND _signing_command
${_psiexec_path}
-accepteula
-nobanner
-s
)
endif()
find_program(_powershell_path powershell.exe REQUIRED)
list(APPEND _signing_command
${_powershell_path}
-NoLogo
-ExecutionPolicy Bypass
-ExecutionPolicy Bypass
-File ${_sign_script}
)
# This requires to have a valid local certificate. In continuous integration, these certificates are stored
# in the machine directly.
# You can generate a test certificate to be able to run this in a PowerShell elevated promp with:
# New-SelfSignedCertificate -DnsName foo.o3de.com -Type CodeSigning -CertStoreLocation Cert:\CurrentUser\My
# Export-Certificate -Cert (Get-ChildItem Cert:\CurrentUser\My\<cert thumbprint>) -Filepath "c:\selfsigned.crt"
# Import-Certificate -FilePath "c:\selfsigned.crt" -Cert Cert:\CurrentUser\TrustedPublisher
# Import-Certificate -FilePath "c:\selfsigned.crt" -Cert Cert:\CurrentUser\Root
message(STATUS "Signing executable files in ${_cpack_wix_out_dir}")
execute_process(
COMMAND ${_signing_command} -exePath ${_cpack_wix_out_dir}
@@ -32,6 +52,6 @@ execute_process(
if(NOT ${_signing_result} EQUAL 0)
message(FATAL_ERROR "An error occurred during signing executable files. ${_signing_errors}")
else()
message(STATUS "Signing exes complete!")
endif()
message(STATUS "Signing exes complete!")