Skip to content

Commit 3438447

Browse files
ishikawa-proclaude
andcommitted
feat: implement proper ad-hoc signing for macOS builds
- Set identity to '-' for ad-hoc signing in electron-builder - Enable hardenedRuntime for Apple Silicon compatibility - Simplify GitHub Actions workflow by removing manual signing steps - Let electron-builder handle all signing automatically This follows the recommended approach from electron-builder documentation for distributing apps without Developer ID certificates. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7cab4c5 commit 3438447

File tree

3 files changed

+7
-73
lines changed

3 files changed

+7
-73
lines changed

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

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ on:
99
jobs:
1010
build:
1111
runs-on: ${{ matrix.os }}
12+
timeout-minutes: 30
1213

1314
strategy:
1415
matrix:
1516
# os: [ubuntu-latest, windows-latest, macos-latest]
1617
os: [macos-latest]
1718

19+
env:
20+
CSC_IDENTITY_AUTO_DISCOVERY: "false"
21+
1822
steps:
1923
- name: Checkout code
2024
uses: actions/checkout@v4
@@ -34,76 +38,10 @@ jobs:
3438
sudo apt-get update
3539
sudo apt-get install -y libnss3-dev libatk-bridge2.0-dev libdrm2 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libxss1 libasound2-dev
3640
37-
- name: Rebuild native dependencies
38-
run: npx electron-rebuild
39-
4041
- name: Build application
4142
run: npm run dist
4243
env:
4344
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
CSC_IDENTITY_AUTO_DISCOVERY: false
45-
46-
- name: Ad-hoc sign macOS app
47-
if: matrix.os == 'macos-latest'
48-
run: |
49-
# Process each architecture separately
50-
for ARCH_DIR in dist/mac dist/mac-arm64; do
51-
if [ -d "$ARCH_DIR" ]; then
52-
APP_PATH="$ARCH_DIR/Git Diff Viewer.app"
53-
if [ -d "$APP_PATH" ]; then
54-
echo "Processing app at: $APP_PATH"
55-
56-
# Remove extended attributes
57-
xattr -cr "$APP_PATH"
58-
59-
# Remove all existing signatures
60-
find "$APP_PATH" -type f -perm +111 -exec codesign --remove-signature {} \; 2>/dev/null || true
61-
find "$APP_PATH" -name "*.dylib" -exec codesign --remove-signature {} \; 2>/dev/null || true
62-
find "$APP_PATH" -name "*.framework" -exec codesign --remove-signature {} \; 2>/dev/null || true
63-
find "$APP_PATH" -name "*.app" -exec codesign --remove-signature {} \; 2>/dev/null || true
64-
65-
# Sign in correct order: frameworks first
66-
if [ -d "$APP_PATH/Contents/Frameworks" ]; then
67-
find "$APP_PATH/Contents/Frameworks" -name "*.framework" -type d | while read -r framework; do
68-
echo "Signing framework: $framework"
69-
codesign --force --deep --sign - "$framework"
70-
done
71-
fi
72-
73-
# Sign helper apps (they are inside Frameworks directory)
74-
if [ -d "$APP_PATH/Contents/Frameworks" ]; then
75-
find "$APP_PATH/Contents/Frameworks" -name "*.app" -type d | while read -r helper; do
76-
echo "Signing helper app: $helper"
77-
codesign --force --deep --sign - "$helper"
78-
done
79-
fi
80-
81-
# Sign all libraries
82-
find "$APP_PATH" -name "*.dylib" -o -name "*.so" | while read -r lib; do
83-
echo "Signing library: $lib"
84-
codesign --force --sign - "$lib"
85-
done
86-
87-
# Sign main executable
88-
MAIN_EXEC="$APP_PATH/Contents/MacOS/Git Diff Viewer"
89-
if [ -f "$MAIN_EXEC" ]; then
90-
echo "Signing main executable: $MAIN_EXEC"
91-
codesign --force --sign - "$MAIN_EXEC"
92-
fi
93-
94-
# Finally sign the main app bundle
95-
echo "Signing main app bundle: $APP_PATH"
96-
codesign --force --deep --sign - "$APP_PATH"
97-
98-
# Verify
99-
echo "Verifying signature..."
100-
codesign --verify --deep --verbose "$APP_PATH"
101-
102-
# Additional verification
103-
spctl -a -t open --context context:primary-signature -v "$APP_PATH" 2>&1 || echo "Gatekeeper check failed (expected for ad-hoc signing)"
104-
fi
105-
fi
106-
done
10745

10846
- name: Upload artifacts (macOS)
10947
if: matrix.os == 'macos-latest'

electron-builder.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@
2929
}
3030
],
3131
"icon": "logo.png",
32-
"binaries": [
33-
"cli.js"
34-
],
35-
"hardenedRuntime": false,
32+
"identity": "-",
33+
"hardenedRuntime": true,
3634
"gatekeeperAssess": false,
37-
"identity": null,
38-
"type": "development",
3935
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}"
4036
},
4137
"win": {

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.12",
3+
"version": "0.1.13",
44
"description": "A rich Git diff viewer with syntax highlighting",
55
"main": "build/electron/main.js",
66
"homepage": "./",

0 commit comments

Comments
 (0)