Skip to content

Commit 7da32ee

Browse files
authored
Merge pull request #148 from arduino/development
Development to Main
2 parents 169a01a + 94d0263 commit 7da32ee

File tree

10 files changed

+201
-151
lines changed

10 files changed

+201
-151
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
env:
1616
JOB_TRANSFER_ARTIFACT: build-artifacts
17+
NODE_VERSION: 18.17
1718

1819
jobs:
1920
build:
@@ -22,7 +23,7 @@ jobs:
2223
fail-fast: false
2324
matrix:
2425
config:
25-
- os: windows-2019
26+
- os: [self-hosted, windows-sign-pc]
2627
- os: ubuntu-latest
2728
- os: macos-13
2829
- os: macos-14
@@ -31,15 +32,17 @@ jobs:
3132

3233
steps:
3334
- name: Checkout
34-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3536

36-
- name: Install Node.js 16.x
37-
uses: actions/setup-node@v3
37+
- name: Install Node.js ${{ env.NODE_VERSION }}
38+
if: runner.name != 'WINDOWS-SIGN-PC'
39+
uses: actions/setup-node@v4
3840
with:
39-
node-version: '16'
41+
node-version: ${{ env.NODE_VERSION }}
4042
registry-url: 'https://registry.npmjs.org'
4143

4244
- name: Install Python 3.x
45+
if: runner.name != 'WINDOWS-SIGN-PC'
4346
uses: actions/setup-python@v4
4447
with:
4548
python-version: '3.11.x'
@@ -51,11 +54,18 @@ jobs:
5154
AC_USERNAME: ${{ secrets.AC_USERNAME }}
5255
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
5356
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
57+
INSTALLER_CERT_WINDOWS_CER: "/tmp/cert.cer"
58+
# We are hardcoding the path for signtool because is not present on the windows PATH env var by default.
59+
# Keep in mind that this path could change when upgrading to a new runner version
60+
SIGNTOOL_PATH: "C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x86/signtool.exe"
61+
WIN_CERT_PASSWORD: ${{ secrets.INSTALLER_CERT_WINDOWS_PASSWORD }}
62+
WIN_CERT_CONTAINER_NAME: ${{ secrets.INSTALLER_CERT_WINDOWS_CONTAINER }}
5463
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5564
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5665
# IS_NIGHTLY: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
5766
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
5867
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
68+
5969
run: |
6070
# See: https://www.electron.build/code-signing
6171
if [ $IS_FORK = true ]; then

backend/ipc.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
getAllFiles
77
} = require('./helpers.js')
88

9-
module.exports = function registerIPCHandlers(win, ipcMain, app) {
9+
module.exports = function registerIPCHandlers(win, ipcMain, app, dialog) {
1010
ipcMain.handle('open-folder', async (event) => {
1111
console.log('ipcMain', 'open-folder')
1212
const folder = await openFolderDialog(win)
@@ -43,7 +43,8 @@ module.exports = function registerIPCHandlers(win, ipcMain, app) {
4343

4444
ipcMain.handle('save-file', (event, filePath, content) => {
4545
console.log('ipcMain', 'save-file', filePath, content)
46-
fs.writeFileSync(filePath, content, 'utf8')
46+
const data = Buffer.from(content);
47+
fs.writeFileSync(filePath, data)
4748
return true
4849
})
4950

@@ -122,6 +123,12 @@ module.exports = function registerIPCHandlers(win, ipcMain, app) {
122123
return app.getAppPath()
123124
})
124125

126+
ipcMain.handle('open-dialog', (event, opt) => {
127+
console.log('ipcMain', 'open-dialog', opt)
128+
const response = dialog.showMessageBoxSync(win, opt)
129+
return response != opt.cancelId
130+
})
131+
125132
win.on('close', (event) => {
126133
console.log('BrowserWindow', 'close')
127134
event.preventDefault()

build_resources/windowsCustomSign.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const childProcess = require('child_process');
2+
3+
exports.default = async function (configuration) {
4+
if (!process.env.GITHUB_ACTIONS) {
5+
return;
6+
}
7+
8+
const SIGNTOOL_PATH = process.env.SIGNTOOL_PATH;
9+
const INSTALLER_CERT_WINDOWS_CER = process.env.INSTALLER_CERT_WINDOWS_CER;
10+
const CERT_PASSWORD = process.env.WIN_CERT_PASSWORD;
11+
const CONTAINER_NAME = process.env.WIN_CERT_CONTAINER_NAME;
12+
const filePath = configuration.path;
13+
14+
if (
15+
SIGNTOOL_PATH &&
16+
INSTALLER_CERT_WINDOWS_CER &&
17+
CERT_PASSWORD &&
18+
CONTAINER_NAME
19+
) {
20+
childProcess.execSync(
21+
`"${SIGNTOOL_PATH}" sign -d "Arduino Lab for MicroPython" -f "${INSTALLER_CERT_WINDOWS_CER}" -csp "eToken Base Cryptographic Provider" -k "[{{${CERT_PASSWORD}}}]=${CONTAINER_NAME}" -fd sha256 -tr http://timestamp.digicert.com -td SHA256 -v "${filePath}"`,
22+
{ stdio: 'inherit' }
23+
);
24+
} else {
25+
console.warn(
26+
`Custom windows signing was no performed one of the following variables was not provided: SIGNTOOL_PATH (${SIGNTOOL_PATH}), INSTALLER_CERT_WINDOWS_CERT (${INSTALLER_CERT_WINDOWS_CER}), CERT_PASSWORD (${CERT_PASSWORD}), CONTAINER_NAME (${CONTAINER_NAME})`
27+
);
28+
process.exit(1);
29+
}
30+
};

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { app, BrowserWindow, ipcMain } = require('electron')
1+
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
22
const path = require('path')
33
const fs = require('fs')
44

@@ -49,7 +49,7 @@ function createWindow () {
4949
win.show()
5050
})
5151

52-
registerIPCHandlers(win, ipcMain, app)
52+
registerIPCHandlers(win, ipcMain, app, dialog)
5353
registerMenu(win)
5454

5555
app.on('activate', () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy