Skip to content

Commit b70e59a

Browse files
committed
Fix subframework signing attempt 3
1 parent d41dd3c commit b70e59a

File tree

1 file changed

+63
-33
lines changed

1 file changed

+63
-33
lines changed

.github/workflows/build+release.yml

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,19 @@ jobs:
6161
id: version
6262
run: |
6363
:
64-
echo "- Extract version from project"
65-
version=$(xcodebuild -scheme "${{ env.buildscheme }}" -configuration Release \
66-
-project "${{ env.projectfile }}" -showBuildSettings \
67-
| sed -nr 's/^.*MARKETING_VERSION = (.*)$/\1/p') 2>/dev/null
64+
echo "- Extract version and bundle id from the project"
65+
xcodebuild -scheme "${{ env.buildscheme }}" -configuration Release \
66+
-project "${{ env.projectfile }}" -showBuildSettings 2>/dev/null > buildsettings.txt
67+
version=$(sed -nr 's/^.*MARKETING_VERSION = (.*)$/\1/p' < buildsettings.txt)
6868
if [[ -z $version ]] ; then
6969
echo "::error::Unable to determine a version number for the current state of the xcode project"
7070
exit 1
7171
fi
72+
bundleID=$(sed -nr 's/^.*PRODUCT_BUNDLE_IDENTIFIER = (.*)$/\1/p' < buildsettings.txt)
73+
if [[ -z $bundleID ]] ; then
74+
echo "::error::Unable to extract bundle id from the xcode project"
75+
exit 1
76+
fi
7277
7378
echo "- Check script inputs"
7479
if [[ -z "${{ inputs.releaseVersion }}" || $version == "${{ inputs.releaseVersion }}" ]] ; then
@@ -114,6 +119,7 @@ jobs:
114119
fi
115120
116121
echo "version=$version" >> $GITHUB_OUTPUT
122+
echo "bundleID=$bundleID" >> $GITHUB_OUTPUT
117123
echo "releaseName=$releaseName" >> $GITHUB_OUTPUT
118124
echo "releaseArchivename=$releaseNameNoSpaces" >> $GITHUB_OUTPUT
119125
echo "isPrerelease=$isPrerelease" >> $GITHUB_OUTPUT
@@ -209,41 +215,51 @@ jobs:
209215
210216
echo "- Sign subcomponents..."
211217
# this is thanks to https://stackoverflow.com/a/11284404/592739
218+
# within this section change the Internal Field Separator (IFS) to
219+
# iterate over newline-separated paths that contain spaces
220+
savedIFS=$IFS
221+
IFS=$(echo -en "\n\b")
222+
212223
subitems=""
224+
addsubitems()
225+
{
226+
if [ -z "$subitems" ] ; then
227+
subitems="$1"
228+
else
229+
subitems="$subitems"$'\n'"$1"
230+
fi
231+
}
232+
213233
frameworksdir="${{ env.builddir }}/${{ env.bundlename }}/Contents/Frameworks"
214234
if [ -d "$frameworksdir" ] ; then
215235
frameworksdirdylibs=$(find "$frameworksdir" -depth -name "*.dylib")
216-
subitems="$frameworksdirdylibs"
236+
if [ -n "$frameworksdirdylibs" ] ; then
237+
addsubitems "$frameworksdirdylibs"
238+
fi
217239
frameworksdirbundles=$(find "$frameworksdir" -depth -type d -name "*.bundle")
218-
if [ -n "$frameworksdirbundles" -a -z "$subitems" ] ; then
219-
subitems="$frameworksdirbundles"
220-
elif [ -n "$frameworksdirbundles" ] ; then
221-
subitems="$subitems"$'\n'"$frameworksdirbundles"
240+
if [ -n "$frameworksdirbundles" ] ; then
241+
addsubitems "$frameworksdirbundles"
222242
fi
223243
frameworksdirframeworks=$(find "$frameworksdir" -depth -type d -name "*.framework")
224-
if [ -n "$frameworksdirframeworks" -a -z "$subitems" ] ; then
225-
subitems="$frameworksdirframeworks"
226-
elif [ -n "$frameworksdirframeworks" ] ; then
227-
subitems="$subitems"$'\n'"$frameworksdirframeworks"
244+
if [ -n "$frameworksdirframeworks" ] ; then
245+
for framework in $frameworksdirframeworks; do
246+
frameworksubapp=$(find "$framework" -depth -type d -name "*.app")
247+
if [ -n "$frameworksubapp" ] ; then
248+
addsubitems "$frameworksubapp"
249+
fi
250+
# search for executables with limited depth to avoid ones within an .app
251+
frameworksubexecutable=$(find "$framework" -depth 4 -type f -perm +111)
252+
if [ -n "$frameworksubexecutable" ] ; then
253+
addsubitems "$frameworksubexecutable"
254+
fi
255+
done
256+
addsubitems "$frameworksdirframeworks"
228257
fi
258+
229259
fi
230260
# potentially grab more subitems from other places within the .app here
231-
#resourcesdir="${{ env.builddir }}/${{ env.bundlename }}/Contents/Resources"
232-
#...
233-
# not totally sure we have to manually sign the executable separately
234-
executableitem="${{ env.builddir }}/${{ env.bundlename }}/Contents/MacOS/${{ env.productname }}"
235-
if [ -x "$executableitem" -a -z "$subitems" ] ; then
236-
subitems="$executableitem"
237-
elif [ -x "$executableitem" ] ; then
238-
subitems="$subitems"$'\n'"$executableitem"
239-
else
240-
echo "::error::App bundle executable not found for signing"
241-
fi
261+
# ie. resourcesdir="${{ env.builddir }}/${{ env.bundlename }}/Contents/Resources"
242262
243-
# change the Internal Field Separator (IFS) to allow newline-separated
244-
# paths that contain spaces
245-
savedIFS=$IFS
246-
IFS=$(echo -en "\n\b")
247263
for subitem in $subitems; do
248264
xcrun codesign --force -s "${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}" \
249265
--options runtime -v "$subitem"
@@ -258,8 +274,6 @@ jobs:
258274
if: success()
259275
run: |
260276
:
261-
test -d "${{ env.builddir }}/${{ env.bundlename }}" || exit 1
262-
263277
if [[ -z "${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}" ]] ; then
264278
echo "::error::Secret PROD_MACOS_NOTARIZATION_APPLE_ID not defined"
265279
exit 1
@@ -294,7 +308,7 @@ jobs:
294308
# characteristics. Visit the Notarization docs for more information and strategies on how to optimize it if
295309
# you're curious
296310
297-
echo "- Notarize"
311+
echo "- Notarize app"
298312
xcrun notarytool submit "notarization.zip" --keychain-profile "notarytool-profile" --wait \
299313
2>&1 | tee notarytool-out.txt
300314
if [ ${PIPESTATUS[0]} -ne 0 ] || grep -q Invalid notarytool-out.txt ; then
@@ -331,8 +345,6 @@ jobs:
331345
id: dmg
332346
run: |
333347
:
334-
test -d "${{ env.builddir }}/${{ env.bundlename }}" || exit 1
335-
336348
if ! command -v create-dmg >/dev/null 2>&1 ; then
337349
echo "::warning::Required helper script not found: create-dmg. Skipping dmg creation"
338350
# not sure if need to do `echo "file=whatever" >> $GITHUB_OUTPUT`
@@ -365,6 +377,24 @@ jobs:
365377
#xcrun stapler staple "${{ env.builddir }}/$imageFileName"
366378
367379
echo "file=${{ env.builddir }}/$imageFileName" >> $GITHUB_OUTPUT
380+
381+
- name: "Sign and notarize disk image"
382+
if: success()
383+
run: |
384+
:
385+
echo "- Notarize disk image"
386+
xcrun notarytool submit "${{ steps.dmg.outputs.file }}" --keychain-profile "notarytool-profile" --wait \
387+
2>&1 | tee notarytool-out.txt
388+
if [ ${PIPESTATUS[0]} -ne 0 ] || grep -q Invalid notarytool-out.txt ; then
389+
if sed -nr '/^[[:space:]]*id: (.*)$/{s//\1/p;q;}' notarytool-out.txt > notarytool-id.txt ; then
390+
echo "- Extract notarytool failure log"
391+
xcrun notarytool log "$(<notarytool-id.txt)" --keychain-profile "notarytool-profile"
392+
fi
393+
exit 1
394+
fi
395+
396+
echo "- Attach staple"
397+
xcrun stapler staple "${{ steps.dmg.outputs.file }}"
368398
369399
- name: Release Notes
370400
id: notes

0 commit comments

Comments
 (0)