Skip to content

Commit e9b5fee

Browse files
committed
Add a PR check workflow
1 parent 2f75261 commit e9b5fee

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050

5151
- run: npm run build
5252
env:
53+
ENABLE_SIGNING: true
5354
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5455
# For Mac notarization:
5556
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}

.github/workflows/pr-check.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# PR check workflow - should be equilvalent to the build step of the CI workflow, but
2+
# with signing disabled (and obviously no publishing etc either).
3+
4+
name: PR Check
5+
on:
6+
- pull_request
7+
- push
8+
jobs:
9+
build:
10+
name: Build & test (unsigned)
11+
strategy:
12+
matrix:
13+
include:
14+
- platform: linux
15+
arch: x64
16+
os: "ubuntu-22.04"
17+
- platform: linux
18+
arch: arm64
19+
os: "ubuntu-24.04-arm"
20+
- platform: windows
21+
arch: x64
22+
os: "windows-2022"
23+
- platform: mac
24+
arch: x64
25+
os: "macos-13"
26+
- platform: mac
27+
arch: arm64
28+
os: "macos-14"
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 22.20.0
36+
check-latest: true
37+
cache: 'npm'
38+
39+
- name: Install system FPM to fix ARM64 Linux builds
40+
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install ruby ruby-dev build-essential
44+
sudo gem install --no-document fpm
45+
46+
- run: npm ci
47+
48+
- run: npm run build
49+
env:
50+
# Build dev builds only
51+
ENABLE_SIGNING: false
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
USE_SYSTEM_FPM: ${{ matrix.platform == 'linux' && matrix.arch == 'arm64' }}
54+
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: ${{ matrix.platform }}-${{ matrix.arch }}-distributables
58+
path: dist/HttpToolkit-*
59+
if-no-files-found: error

electron-builder.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This config just re-exposes the config from package.json, but
2+
// disables code signing & notarization for PR builds where it won't work.
3+
4+
const packageJson = require('./package.json');
5+
6+
const unsignedMode = process.env.ENABLE_SIGNING !== 'true';
7+
8+
const config = packageJson.build;
9+
10+
if (unsignedMode) {
11+
console.log('\nBuilding in UNSIGNED mode\n');
12+
13+
// Make it abundantly clear in the output that the builds aren't signed, so
14+
// we don't accidentally distribute them. Different app & file names throughout.
15+
config.productName = packageJson.name + ' - dev build';
16+
config.extraMetadata.name += '-dev';
17+
config.extraMetadata.productName += '-dev';
18+
19+
config.artifactName = config.artifactName.replace('${ext}', 'dev.${ext}');
20+
for (let field in config) {
21+
if (config[field]?.artifactName) {
22+
config[field].artifactName =
23+
config[field].artifactName.replace('${ext}', 'dev.${ext}');
24+
}
25+
}
26+
27+
config.mac.forceCodeSigning = false;
28+
config.mac.notarize = false;
29+
config.win.forceCodeSigning = false;
30+
process.env.CSC_IDENTITY_AUTO_DISCOVERY = 'false';
31+
} else {
32+
console.log('\nBuilding in SIGNED mode\n');
33+
}
34+
35+
module.exports = config;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "npm run build:src && npm run build:electron",
1313
"build:src": "tsc",
1414
"postbuild:src": "tsx ./strip-preload-map.ts",
15-
"build:electron": "npm run server:setup && electron-builder build",
15+
"build:electron": "npm run server:setup && electron-builder build --config electron-builder.config.js",
1616
"build:dir-only": "npm run server:setup && electron-builder --dir",
1717
"start": "npm run server:setup && npm run start:app",
1818
"start:dev": "tsx ./skip-server.ts && cross-env HTK_DEV=true APP_URL='http://localhost:8080' npm run start:app",
@@ -77,7 +77,7 @@
7777
},
7878
"nsis": {
7979
"installerIcon": "./src/icons/icon.ico",
80-
"artifactName": "HttpToolkit-${version}.exe",
80+
"artifactName": "HttpToolkit-${version}.${ext}",
8181
"deleteAppDataOnUninstall": true,
8282
"oneClick": false,
8383
"allowToChangeInstallationDirectory": true,

0 commit comments

Comments
 (0)