Skip to content

Commit e3959ef

Browse files
ishikawa-proclaude
andcommitted
feat: update to latest electron-builder best practices
- Changed identity from null to '-' for proper ad-hoc signing - Switched to universal builds for better compatibility - Improved signing process with proper order and hardened runtime - Added quarantine attribute removal with xattr - Use ditto for proper ZIP creation with resource forks - Removed deprecated options (extends, buildDependenciesFromSource, etc.) Based on electron-builder v24 documentation and 2025 best practices. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dffbd08 commit e3959ef

File tree

3 files changed

+55
-28
lines changed

3 files changed

+55
-28
lines changed

.github/workflows/build-and-release.yml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818

1919
env:
2020
CSC_IDENTITY_AUTO_DISCOVERY: "false"
21-
CSC_FOR_PULL_REQUEST: "true"
2221

2322
steps:
2423
- name: Checkout code
@@ -43,25 +42,56 @@ jobs:
4342
run: npx electron-rebuild
4443

4544
- name: Build application
46-
run: npm run dist
45+
run: npx electron-builder --mac --publish=never
4746
env:
4847
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4948

50-
- name: Fix code signing (macOS)
49+
- name: Unify code signing (macOS)
5150
if: matrix.os == 'macos-latest'
5251
run: |
53-
# Re-sign all apps with consistent ad-hoc signature
54-
for APP in dist/mac*/Git\ Diff\ Viewer.app; do
55-
if [ -d "$APP" ]; then
56-
echo "Re-signing $APP with ad-hoc signature..."
57-
# Remove all existing signatures
58-
find "$APP" -type f -perm +111 -exec codesign --remove-signature {} \; 2>/dev/null || true
59-
# Sign with ad-hoc
60-
codesign --force --deep --sign - "$APP"
61-
# Verify
62-
codesign --verify --deep --verbose "$APP"
63-
fi
64-
done
52+
APP="dist/mac/Git Diff Viewer.app"
53+
if [ -d "$APP" ]; then
54+
echo "======================================"
55+
echo "Unifying code signatures for: $APP"
56+
echo "======================================"
57+
58+
# Remove all existing signatures
59+
find "$APP" -type d -name '*.app' -exec codesign --remove-signature {} \; 2>/dev/null || true
60+
find "$APP" -type f \( -perm /111 -o -name '*.dylib' -o -name '*.so' -o -name '*.node' \) \
61+
-exec codesign --remove-signature {} \; 2>/dev/null || true
62+
63+
# Sign frameworks and libraries first
64+
echo "Signing frameworks and libraries..."
65+
find "$APP/Contents/Frameworks" -type f \( -perm /111 -o -name '*.dylib' -o -name '*.so' -o -name '*.node' \) \
66+
-exec codesign --force --sign - {} \; 2>/dev/null || true
67+
68+
# Sign nested helper apps
69+
echo "Signing helper apps..."
70+
find "$APP/Contents/Frameworks" -type d -name '*.app' | while read -r helper; do
71+
codesign --force --deep --sign - "$helper"
72+
done
73+
74+
# Sign main app with hardened runtime
75+
echo "Signing main app with hardened runtime..."
76+
codesign --force --deep --options runtime --timestamp=none --sign - "$APP"
77+
78+
# Remove quarantine attributes
79+
xattr -cr "$APP"
80+
81+
# Verify signature
82+
echo "======================================"
83+
echo "Verifying signature..."
84+
echo "======================================"
85+
codesign --verify --deep --strict --verbose=2 "$APP"
86+
fi
87+
88+
- name: Create ZIP with ditto (macOS)
89+
if: matrix.os == 'macos-latest'
90+
run: |
91+
APP="dist/mac/Git Diff Viewer.app"
92+
if [ -d "$APP" ]; then
93+
ditto -c -k --sequesterRsrc --keepParent "$APP" "dist/Git-Diff-Viewer-${GITHUB_REF##*/}-mac.zip"
94+
fi
6595
6696
- name: Upload artifacts (macOS)
6797
if: matrix.os == 'macos-latest'
@@ -70,9 +100,7 @@ jobs:
70100
name: macos-build
71101
path: |
72102
dist/*.dmg
73-
dist/*.zip
74103
dist/*-mac.zip
75-
dist/*-mac-*.zip
76104
77105
- name: Upload artifacts (Windows)
78106
if: matrix.os == 'windows-latest'

electron-builder.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
{
22
"appId": "com.diffviewer.app",
33
"productName": "Git Diff Viewer",
4-
"extends": null,
54
"directories": {
65
"output": "dist"
76
},
87
"files": [
98
"build/**/*",
109
"package.json",
11-
"cli.js"
10+
"cli.js",
11+
"!.vscode/**",
12+
"!.git/**",
13+
"!node_modules/.cache/**"
1214
],
1315
"extraMetadata": {
1416
"main": "build/electron/main.js"
1517
},
1618
"npmRebuild": false,
17-
"buildDependenciesFromSource": true,
18-
"nodeGypRebuild": false,
1919
"mac": {
2020
"category": "public.app-category.developer-tools",
2121
"target": [
2222
{
2323
"target": "dmg",
24-
"arch": ["x64", "arm64"]
24+
"arch": ["universal"]
2525
},
2626
{
2727
"target": "zip",
28-
"arch": ["x64", "arm64"]
28+
"arch": ["universal"]
2929
}
3030
],
3131
"icon": "logo.png",
32-
"identity": null,
32+
"identity": "-",
3333
"hardenedRuntime": true,
34-
"gatekeeperAssess": false,
35-
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}"
34+
"artifactName": "${productName}-${version}-${os}.${ext}"
3635
},
3736
"win": {
3837
"target": "nsis",
@@ -42,4 +41,4 @@
4241
"target": "AppImage",
4342
"icon": "logo.png"
4443
}
45-
}
44+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diff-viewer",
3-
"version": "0.1.16",
3+
"version": "0.1.17",
44
"description": "A rich Git diff viewer with syntax highlighting",
55
"main": "build/electron/main.js",
66
"homepage": "./",

0 commit comments

Comments
 (0)