Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3c64ce7

Browse files
committedJul 26, 2023
ci: add esigner script
1 parent 4798288 commit 3c64ce7

File tree

8 files changed

+131
-71
lines changed

8 files changed

+131
-71
lines changed
 

‎.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ npm-debug.log.*
3131
# eslint ignores hidden directories by default:
3232
# https://github.com/eslint/eslint/issues/8429
3333
.erb
34-
.eslintrc.js
34+
.eslintrc.js
35+
36+
sign.js

‎.github/workflows/release.yaml renamed to ‎.github/workflows/mac-release.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ on:
77

88
jobs:
99
publish:
10-
runs-on: ${{ matrix.os }}
11-
12-
strategy:
13-
matrix:
14-
os: [macos-latest, windows-2022]
15-
10+
runs-on: macos-latest
1611
steps:
1712
- name: Checkout git repo
1813
uses: actions/checkout@v3

‎.github/workflows/win-release.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
publish:
10+
runs-on: windows-latest
11+
12+
steps:
13+
- name: Checkout git repo
14+
uses: actions/checkout@v3
15+
16+
- name: Install Node and NPM
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 16
20+
cache: npm
21+
22+
- name: Download eSigner Signing Tool
23+
run: Invoke-WebRequest -OutFile esigner.zip -Uri https://invisal.s3.ap-southeast-1.amazonaws.com/CodeSignTool-v1.2.7-windows.zip
24+
25+
- name: Unpack eSigner Signing Tool
26+
run: Expand-Archive esigner.zip ./CodeSignTool-v1.2.7-windows
27+
28+
- name: Install and build
29+
run: |
30+
npm install
31+
npm run postinstall
32+
npm run build
33+
34+
- name: Publish releases
35+
env:
36+
# These values are used for auto updates signing
37+
WINDOWS_SIGN_USER_NAME: ${{ secrets.WINDOWS_SIGN_USER_NAME }}
38+
WINDOWS_SIGN_USER_PASSWORD: ${{ secrets.WINDOWS_SIGN_USER_PASSWORD }}
39+
WINDOWS_SIGN_CREDENTIAL_ID: ${{ secrets.WINDOWS_SIGN_CREDENTIAL_ID }}
40+
WINDOWS_SIGN_USER_TOTP: ${{ secrets.WINDOWS_SIGN_USER_TOTP }}
41+
42+
# This is used for uploading release assets to github
43+
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
44+
run: |
45+
npm exec electron-builder -- --publish always

‎package-lock.json

Lines changed: 32 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@
193193
]
194194
},
195195
"win": {
196+
"signingHashAlgorithms": [
197+
"sha256"
198+
],
199+
"sign": "./sign.js",
196200
"target": [
197201
"nsis",
198202
"portable"

‎release/temp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

‎sign.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
const childProcess = require('child_process');
4+
5+
const TEMP_DIR = path.join(__dirname, 'release', 'temp');
6+
7+
if (!fs.statSync(TEMP_DIR).isDirectory()) {
8+
fs.mkdirSync(TEMP_DIR);
9+
}
10+
11+
function sign(configuration) {
12+
// credentials from ssl.com
13+
const USER_NAME = process.env.WINDOWS_SIGN_USER_NAME;
14+
const USER_PASSWORD = process.env.WINDOWS_SIGN_USER_PASSWORD;
15+
const CREDENTIAL_ID = process.env.WINDOWS_SIGN_CREDENTIAL_ID;
16+
const USER_TOTP = process.env.WINDOWS_SIGN_USER_TOTP;
17+
18+
if (USER_NAME && USER_PASSWORD && USER_TOTP && CREDENTIAL_ID) {
19+
console.log(`Signing ${configuration.path}`);
20+
const { base, dir } = path.parse(configuration.path);
21+
// CodeSignTool can't sign in place without verifying the overwrite with a
22+
// y/m interaction so we are creating a new file in a temp directory and
23+
// then replacing the original file with the signed file.
24+
const tempFile = path.join(TEMP_DIR, base);
25+
const setDir = `cd ./CodeSignTool-v1.2.7-windows`;
26+
const signFile = `CodeSignTool sign -input_file_path="${configuration.path}" -output_dir_path="${TEMP_DIR}" -credential_id="${CREDENTIAL_ID}" -username="${USER_NAME}" -password="${USER_PASSWORD}" -totp_secret="${USER_TOTP}"`;
27+
const moveFile = `move "${tempFile}" "${dir}"`;
28+
childProcess.execSync(`${setDir} && ${signFile} && ${moveFile}`, {
29+
stdio: 'inherit',
30+
});
31+
} else {
32+
console.warn(`sign.js - Can't sign file ${
33+
configuration.path
34+
}, missing value for:
35+
${USER_NAME ? '' : 'WINDOWS_SIGN_USER_NAME'}
36+
${USER_PASSWORD ? '' : 'WINDOWS_SIGN_USER_PASSWORD'}
37+
${CREDENTIAL_ID ? '' : 'WINDOWS_SIGN_CREDENTIAL_ID'}
38+
${USER_TOTP ? '' : 'WINDOWS_SIGN_USER_TOTP'}
39+
`);
40+
process.exit(1);
41+
}
42+
}
43+
44+
exports.default = sign;

‎test.xlsx

-15.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.