Skip to content

Commit e9ca950

Browse files
committed
Enhance macOS signing workflow for comprehensive binary handling
- Add explicit signing logic for `.dylib` and executable files with improved detection and logging. - Strengthen main executable and app bundle signing with `--deep` and stricter runtime options. - Refine package creation process with `pkgbuild --component` for better reliability. - Introduce signature verification for installer packages with `pkgutil`.
1 parent 4c1fdc4 commit e9ca950

File tree

1 file changed

+51
-8
lines changed

1 file changed

+51
-8
lines changed

.github/workflows/macos.yml

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,28 +107,64 @@ jobs:
107107
- name: Sign the application
108108
run: |
109109
echo "=== Signing all binaries in the .app bundle ==="
110-
# Find and sign all Mach-O binaries and libraries first
110+
111+
# 1. Sign any .dylib files first
112+
echo "Signing shared libraries (.dylib)..."
113+
find ./target/gluonfx/x86_64-darwin/${{ env.APP_NAME }}.app -name "*.dylib" | while read -r file; do
114+
echo "Signing dylib: $file"
115+
chmod +w "$file"
116+
codesign --force --verify --verbose \
117+
--sign "Developer ID Application: Ozkan Pakdil (${{ env.TEAM_ID }})" \
118+
--options runtime \
119+
--timestamp \
120+
--entitlements ./entitlements.plist \
121+
"$file" || true
122+
done
123+
124+
# 2. Find and sign all Mach-O binaries and libraries in reverse depth order
111125
# We use a more comprehensive search to ensure all nested binaries are caught
112-
# and we sign them in reverse depth order (deepest first)
113-
# Using find with -exec file {} \; to correctly identify Mach-O files regardless of extension
114-
# Also signing in reverse order of depth to ensure child binaries are signed before parents
115-
find ./target/gluonfx/x86_64-darwin/${{ env.APP_NAME }}.app -type f | xargs -I {} sh -c 'if file "{}" | grep -q "Mach-O"; then echo "{}"; fi' | sort -r | while read file; do
126+
# Using find with file to correctly identify Mach-O files regardless of extension
127+
echo "Scanning for Mach-O binaries..."
128+
# Identify all potential binaries and libraries using the 'file' command
129+
find ./target/gluonfx/x86_64-darwin/${{ env.APP_NAME }}.app -type f -print0 | while read -r -d '' file; do
130+
if file "$file" | grep -qE "Mach-O|current ar archive"; then
131+
echo "$file"
132+
fi
133+
done | sort -r | while read -r file; do
116134
echo "Signing binary: $file"
117135
# Ensure we have write permissions
118136
chmod +w "$file"
137+
# We sign with --options runtime and --timestamp as required by Apple
119138
codesign --force --verify --verbose \
120139
--sign "Developer ID Application: Ozkan Pakdil (${{ env.TEAM_ID }})" \
121140
--options runtime \
122141
--timestamp \
123142
--entitlements ./entitlements.plist \
124-
"$file"
143+
"$file" || echo "Warning: Failed to sign $file, might not be necessary if it is not a loadable binary."
144+
done
145+
146+
# 3. Double-check for any missed executable files (files with +x permission)
147+
echo "Checking for additional executable files..."
148+
find ./target/gluonfx/x86_64-darwin/${{ env.APP_NAME }}.app -type f -perm +111 -print0 | while read -r -d '' file; do
149+
# Only sign if it's not already signed or needs resigning
150+
if ! codesign -v "$file" 2>/dev/null; then
151+
echo "Signing missed executable: $file"
152+
chmod +w "$file"
153+
codesign --force --verify --verbose \
154+
--sign "Developer ID Application: Ozkan Pakdil (${{ env.TEAM_ID }})" \
155+
--options runtime \
156+
--timestamp \
157+
--entitlements ./entitlements.plist \
158+
"$file" || true
159+
fi
125160
done
126161
127162
# Explicitly sign the main executable again just to be sure
128163
echo "=== Signing main executable ==="
129164
MAIN_EXE="./target/gluonfx/x86_64-darwin/${{ env.APP_NAME }}.app/Contents/MacOS/${{ env.APP_NAME }}"
130165
if [ -f "$MAIN_EXE" ]; then
131166
chmod +w "$MAIN_EXE"
167+
# Sign the main executable with entitlements and runtime options
132168
codesign --force --verify --verbose \
133169
--sign "Developer ID Application: Ozkan Pakdil (${{ env.TEAM_ID }})" \
134170
--options runtime \
@@ -138,7 +174,8 @@ jobs:
138174
fi
139175
140176
echo "=== Signing the .app bundle ==="
141-
codesign --force --verify --verbose \
177+
# Use --deep as a final verification/reinforcement, though individual signing is better
178+
codesign --force --verify --verbose --deep \
142179
--sign "Developer ID Application: Ozkan Pakdil (${{ env.TEAM_ID }})" \
143180
--options runtime \
144181
--timestamp \
@@ -153,16 +190,22 @@ jobs:
153190
- name: Create and sign installer package
154191
run: |
155192
echo "=== Creating signed .pkg installer ==="
156-
pkgbuild --root ./target/gluonfx/x86_64-darwin/ \
193+
# Use --component to correctly package the .app bundle, which is more reliable than --root for single apps
194+
# Ensure the .app bundle is signed before packaging
195+
pkgbuild --component ./target/gluonfx/x86_64-darwin/${{ env.APP_NAME }}.app \
157196
--identifier ${{ env.BUNDLE_ID }} \
158197
--version ${{ env.APP_VERSION }} \
159198
--install-location /Applications \
160199
--sign "Developer ID Installer: Ozkan Pakdil (${{ env.TEAM_ID }})" \
161200
Swaggerific.pkg
162201
202+
# Create the final distribution package
163203
productbuild --package Swaggerific.pkg \
164204
--sign "Developer ID Installer: Ozkan Pakdil (${{ env.TEAM_ID }})" \
165205
SwaggerificInstaller.pkg
206+
207+
echo "=== Verifying pkg signature ==="
208+
pkgutil --check-signature SwaggerificInstaller.pkg
166209
167210
- name: Setup notarization credentials
168211
run: |

0 commit comments

Comments
 (0)