2022-05-24 08:25:12 +02:00
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import subprocess
|
|
|
|
|
2022-05-24 09:12:29 +02:00
|
|
|
def main():
|
2022-05-27 06:57:16 +02:00
|
|
|
print("before sha1sum:")
|
2022-05-25 07:26:24 +02:00
|
|
|
os.system("sha1sum hishtory-* 2>&1")
|
2022-05-24 09:12:29 +02:00
|
|
|
|
|
|
|
print("file:")
|
2022-05-25 07:26:24 +02:00
|
|
|
os.system("file hishtory-* 2>&1")
|
2022-05-24 09:12:29 +02:00
|
|
|
|
2023-11-05 21:22:47 +01:00
|
|
|
assertPresentAndNotAscii("hishtory-darwin-arm64")
|
|
|
|
assertPresentAndNotAscii("hishtory-darwin-amd64")
|
|
|
|
|
|
|
|
# TODO: Update this file to fail if the input files don't exist
|
2022-05-24 09:12:29 +02:00
|
|
|
|
|
|
|
print("signing...")
|
|
|
|
os.system("""
|
2023-11-05 21:22:47 +01:00
|
|
|
set -emo pipefail
|
2022-05-27 07:24:56 +02:00
|
|
|
cp hishtory-darwin-arm64 hishtory-darwin-arm64-unsigned
|
2022-05-27 08:09:00 +02:00
|
|
|
cp hishtory-darwin-amd64 hishtory-darwin-amd64-unsigned
|
2022-05-24 09:12:29 +02:00
|
|
|
echo $MACOS_CERTIFICATE | base64 -d > certificate.p12
|
|
|
|
security create-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
|
|
|
|
security default-keychain -s build.keychain
|
|
|
|
security unlock-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
|
|
|
|
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
|
|
|
|
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PWD build.keychain
|
|
|
|
/usr/bin/codesign --force -s 6D4E1575A0D40C370E294916A8390797106C8A6E hishtory-darwin-arm64 -v
|
|
|
|
/usr/bin/codesign --force -s 6D4E1575A0D40C370E294916A8390797106C8A6E hishtory-darwin-amd64 -v
|
|
|
|
""")
|
|
|
|
|
2022-05-27 06:57:16 +02:00
|
|
|
print("after sha1sum:")
|
|
|
|
os.system("sha1sum hishtory-* 2>&1")
|
|
|
|
|
2022-05-24 09:12:29 +02:00
|
|
|
|
2022-05-24 08:25:12 +02:00
|
|
|
|
2023-11-05 21:22:47 +01:00
|
|
|
def assertPresentAndNotAscii(fn):
|
|
|
|
if not os.path.exists(fn):
|
|
|
|
raise Exception(f"{fn=} does not exist, did it fail to download?")
|
2022-05-24 08:25:12 +02:00
|
|
|
out = subprocess.check_output(["file", fn]).decode('utf-8')
|
|
|
|
if "ASCII text" in out:
|
2023-11-05 21:22:47 +01:00
|
|
|
raise Exception(f"{fn=} is of type {out}")
|
2022-05-24 08:25:12 +02:00
|
|
|
|
2022-05-24 09:12:29 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|