|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import argparse |
| 4 | +import os |
| 5 | +import shutil |
| 6 | +import subprocess |
| 7 | +import urllib.request |
| 8 | +from zipfile import ZipFile |
| 9 | + |
| 10 | +# Handle commandline arguments |
| 11 | +parser = argparse.ArgumentParser() |
| 12 | +parser.add_argument('--sign', action='store_true') |
| 13 | +args = parser.parse_args() |
| 14 | + |
| 15 | +# Build .msi |
| 16 | +subprocess.check_call([ |
| 17 | + "cargo", |
| 18 | + "wix", |
| 19 | + "--nocapture", |
| 20 | + "--verbose", |
| 21 | +]) |
| 22 | + |
| 23 | +if args.sign: |
| 24 | + if not os.path.isdir('target/sign'): |
| 25 | + os.mkdir("target/sign") |
| 26 | + |
| 27 | + # Download signing tool |
| 28 | + tool_url = "https://www.ssl.com/download/29773/" |
| 29 | + tool_zip = "target/sign/CodeSignTool.zip" |
| 30 | + if not os.path.isfile(tool_zip): |
| 31 | + if os.path.isfile(tool_zip + ".partial"): |
| 32 | + os.remove(tool_zip + ".partial") |
| 33 | + urllib.request.urlretrieve(tool_url, tool_zip + ".partial") |
| 34 | + os.rename(tool_zip + ".partial", tool_zip) |
| 35 | + |
| 36 | + # Extract signing tool |
| 37 | + tool_dir = "target/sign/CodeSignTool" |
| 38 | + if not os.path.isdir(tool_dir): |
| 39 | + if os.path.isdir(tool_dir + ".partial"): |
| 40 | + shutil.rmtree(tool_dir + ".partial") |
| 41 | + os.mkdir(tool_dir + ".partial") |
| 42 | + with ZipFile(tool_zip, "r") as zip: |
| 43 | + zip.extractall(tool_dir + ".partial") |
| 44 | + os.rename(tool_dir + ".partial", tool_dir) |
| 45 | + |
| 46 | + # Sign with specified cloud signing key |
| 47 | + subprocess.check_call([ |
| 48 | + "cmd", "/c", "CodeSignTool.bat", |
| 49 | + "sign", |
| 50 | + "-credential_id=" + os.environ["SSL_COM_CREDENTIAL_ID"], |
| 51 | + "-username=" + os.environ["SSL_COM_USERNAME"], |
| 52 | + "-password=" + os.environ["SSL_COM_PASSWORD"], |
| 53 | + "-totp_secret=" + os.environ["SSL_COM_TOTP_SECRET"], |
| 54 | + "-input_file_path=../../../wix/thelio-io-0.1.0-x86_64.msi", |
| 55 | + "-output_dir_path=../../", |
| 56 | + ], cwd="target/sign/CodeSignTool/CodeSignTool-v1.0-windows") |
0 commit comments