Skip to content

Commit 83e12b5

Browse files
committed
Add code signing on release
1 parent 8465a8d commit 83e12b5

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ jobs:
88
with:
99
lfs: true
1010
- uses: actions-rs/toolchain@v1
11-
- run: choco install dotnet netfx-4.8 wixtoolset
11+
- run: choco install dotnet netfx-4.8 python3 wixtoolset
1212
- run: cargo install cargo-wix
13-
- run: cargo wix -v --nocapture
13+
- env:
14+
SSL_COM_USERNAME: ${{ github.event_name == 'release' && secrets.SSL_COM_USERNAME || '' }}
15+
SSL_COM_PASSWORD: ${{ github.event_name == 'release' && secrets.SSL_COM_PASSWORD || '' }}
16+
SSL_COM_CREDENTIAL_ID: ${{ github.event_name == 'release' && secrets.SSL_COM_CREDENTIAL_ID || '' }}
17+
SSL_COM_TOTP_SECRET: ${{ github.event_name == 'release' && secrets.SSL_COM_TOTP_SECRET || '' }}
18+
SIGN: ${{ github.event_name == 'release' && '--sign' || '' }}
19+
run: python build.py %SIGN%
1420
- uses: actions/upload-artifact@v2
1521
with:
1622
name: thelio-io

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
- Install Chocolaty from https://chocolatey.org/install
66
- Launch an Administrator Command Prompt and run the following:
77
```
8-
choco install dotnet netfx-4.8 wixtoolset
8+
choco install dotnet netfx-4.8 python3 wixtoolset
99
```
1010
- Launch a normal Command Prompt and run the following:
1111
```
1212
cargo install cargo-wix
1313
```
1414
- Run the following to build the installer:
1515
```
16-
cargo wix -v --nocapture
16+
python build.py
1717
```
1818
- Execute the installer at `target/wix/thelio-io-0.1.0-x86_64.msi`
19-
- Execute the program from the `bin/thelio-io.exe` file in the install directory
19+
- The installer will start the `System76 Thelio Io` service
20+
- Logs can be viewed in `Event Viewer` under `Windows Logs/Application` with the
21+
source `System76 Thelio Io`

sign.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)