Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code signing on the windows for jbrowse desktop #4571

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,29 @@ jobs:
- name: Install build deps
run: |
apt install --yes python3 make gcc libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
# We are just cloning the esigner repo instead of calling their github
# action directly https://github.com/SSLcom/esigner-codesign
- name: Get ssl.com esigner zip file and unzip
run: |
mkdir products/jbrowse-desktop/code_signer
cd products/jbrowse-desktop/code_signer
wget https://www.ssl.com/download/codesigntool-for-linux-and-macos -O out.zip
unzip out.zip
chmod +x CodeSignTool.sh
cd ../../../

- name: Build app
env:
WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
WINDOWS_SIGN_USER_NAME: ${{ secrets.WINDOWS_SIGN_USER_NAME }}
WINDOWS_SIGN_USER_PASSWORD: ${{ secrets.WINDOWS_SIGN_USER_PASSWORD }}
WINDOWS_SIGN_CREDENTIAL_ID: ${{ secrets.WINDOWS_SIGN_CREDENTIAL_ID }}
WINDOWS_SIGN_USER_TOTP: ${{ secrets.WINDOWS_SIGN_USER_TOTP }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chown --recursive root:root /github/home
yarn build-electron:win --publish always
working-directory: products/jbrowse-desktop

buildmac:
needs: createrelease
name: Build Mac desktop app
Expand Down
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export default tseslint.config(
'products/jbrowse-img/**/*',
'products/jbrowse-web/scripts/*',
'products/jbrowse-desktop/scripts/*',
'products/jbrowse-desktop/sign.js',
'products/jbrowse-desktop/linux-sandbox-fix.js',
'products/jbrowse-aws-lambda-functions/**/*.js',
'plugins/data-management/scripts/*.js',
Expand Down
4 changes: 4 additions & 0 deletions products/jbrowse-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
"productName": "JBrowse 2",
"copyright": "Copyright © 2019",
"win": {
"sign": "./sign.js",
"signingHashAlgorithms": [
"sha256"
],
"publish": [
"github"
],
Expand Down
48 changes: 48 additions & 0 deletions products/jbrowse-desktop/sign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// this script adapted from
// https://github.com/electron-userland/electron-builder/issues/6158#issuecomment-899798533
const path = require('path')
const fs = require('fs')
const childProcess = require('child_process')

const TEMP_DIR = path.join(__dirname, 'release', 'temp')

if (!fs.existsSync(TEMP_DIR)) {
fs.mkdirSync(TEMP_DIR, { recursive: true })
}

function sign(configuration) {
console.log(`Signing ${configuration.path}`)
// we move signed files to a file named tmp.exe because our product name
// contains a space, meaning our .exe contains a space, which CodeSignTool
// balks at even with attempted backslash escaping, so we rename to tmp.exe
const tmpExe = `tmp-${Math.random()}.exe`

// note: CodeSignTool can't sign in place without verifying the overwrite
// with a y/m interaction so we are creating a new file in a temp directory
// and then replacing the original file with the signed file.
const signFile = [
// code_signer is directory containing the CodeSignTool script in
// products/jbrowse-desktop that is created by .github/workflows/release.sh
// on windows
'CODE_SIGN_TOOL_PATH=code_signer bash code_signer/CodeSignTool.sh sign',
`-input_file_path='${tmpExe}'`,
`-output_dir_path='${TEMP_DIR}'`,
`-credential_id='${process.env.WINDOWS_SIGN_CREDENTIAL_ID}'`,
`-username='${process.env.WINDOWS_SIGN_USER_NAME}'`,
`-password='${process.env.WINDOWS_SIGN_USER_PASSWORD}'`,
`-totp_secret='${process.env.WINDOWS_SIGN_USER_TOTP}'`,
].join(' ')
const preMoveFile = `cp "${configuration.path}" "${tmpExe}"`
const postMoveFile = `cp "${path.join(TEMP_DIR, tmpExe)}" "${configuration.path}"`
childProcess.execSync(preMoveFile, {
stdio: 'inherit',
})
childProcess.execSync(signFile, {
stdio: 'inherit',
})
childProcess.execSync(postMoveFile, {
stdio: 'inherit',
})
}

exports.default = sign
Loading