Skip to content

Commit 9202bd9

Browse files
committed
First attempt at signing and notarizing framework in GitHub Actions. (temporarily disabled non apple runners for debugging)
1 parent 9ea7c95 commit 9202bd9

File tree

1 file changed

+90
-7
lines changed

1 file changed

+90
-7
lines changed

.github/workflows/cppcmake.yml

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,52 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
config:
38-
- {name: "ubuntu-22.04", os: "ubuntu-22.04", cmake_extra: "-DLSL_BUNDLED_PUGIXML=OFF" }
39-
- {name: "ubuntu-24.04", os: "ubuntu-24.04", cmake_extra: "-DLSL_BUNDLED_PUGIXML=OFF" }
40-
- {name: "windows-x64", os: "windows-latest", cmake_extra: "-T v142,host=x86"}
41-
- {name: "windows-32", os: "windows-latest", cmake_extra: "-T v142,host=x86 -A Win32"}
38+
# - {name: "ubuntu-22.04", os: "ubuntu-22.04", cmake_extra: "-DLSL_BUNDLED_PUGIXML=OFF" }
39+
# - {name: "ubuntu-24.04", os: "ubuntu-24.04", cmake_extra: "-DLSL_BUNDLED_PUGIXML=OFF" }
40+
# - {name: "windows-x64", os: "windows-latest", cmake_extra: "-T v142,host=x86"}
41+
# - {name: "windows-32", os: "windows-latest", cmake_extra: "-T v142,host=x86 -A Win32"}
4242
- {name: "macOS-latest", os: "macOS-latest", cmake_extra: "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64 -DLSL_FRAMEWORK=ON" }
4343

4444
steps:
4545
- uses: actions/checkout@v4
4646

47+
- name: Install certificates and provisioning profiles
48+
if: matrix.config.os == 'macOS-latest'
49+
env:
50+
MACOS_CERTIFICATE_APP: ${{ secrets.PROD_MACOS_CERTIFICATE }}
51+
MACOS_CERTIFICATE_INST: ${{ secrets.PROD_MACOS_CERTIFICATE_INST }}
52+
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
53+
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
54+
run: |
55+
# Create temporary keychain
56+
KEYCHAIN_PATH=$RUNNER_TEMP/build.keychain
57+
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" $KEYCHAIN_PATH
58+
security default-keychain -s $KEYCHAIN_PATH
59+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
60+
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" $KEYCHAIN_PATH
61+
62+
# Import certificates from secrets ...
63+
CERTIFICATE_PATH_APP=$RUNNER_TEMP/build_certificate_app.p12
64+
CERTIFICATE_PATH_INST=$RUNNER_TEMP/build_certificate_inst.p12
65+
echo -n "$MACOS_CERTIFICATE_APP" | base64 --decode -o $CERTIFICATE_PATH_APP
66+
echo -n "$MACOS_CERTIFICATE_INST" | base64 --decode -o $CERTIFICATE_PATH_INST
67+
# ... to keychain
68+
security import $CERTIFICATE_PATH_APP -P "$MACOS_CERTIFICATE_PWD" -k $KEYCHAIN_PATH -A -t cert -f pkcs12
69+
security import $CERTIFICATE_PATH_INST -P "$MACOS_CERTIFICATE_PWD" -k $KEYCHAIN_PATH -A -t cert -f pkcs12
70+
71+
# Set trusted partitions (groups of applications) that can access the keychain items
72+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" $KEYCHAIN_PATH
73+
security list-keychain -d user -s $KEYCHAIN_PATH
74+
75+
# Get certificate identities into environment variables
76+
CERT_IDENTITY_APP=$(security find-identity -v -p codesigning $KEYCHAIN_PATH | grep "Developer ID Application" | head -1 | awk -F'"' '{print $2}')
77+
echo "APPLE_CODE_SIGN_IDENTITY_APP=$CERT_IDENTITY_APP" >> $GITHUB_ENV
78+
CERT_IDENTITY_INST=$(security find-identity -v -p basic $KEYCHAIN_PATH | grep "Developer ID Installer" | head -1 | awk -F'"' '{print $2}')
79+
echo "APPLE_CODE_SIGN_IDENTITY_INST=$CERT_IDENTITY_INST" >> $GITHUB_ENV
80+
4781
- name: Configure CMake
82+
env:
83+
APPLE_DEVELOPMENT_TEAM: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
4884
run: |
4985
if [[ "${{ matrix.config.name }}" = ubuntu-2* ]]; then
5086
sudo apt-get install -y --no-install-recommends libpugixml-dev
@@ -60,7 +96,7 @@ jobs:
6096
-Dlslgitbranch=${{ github.ref }} \
6197
${{ matrix.config.cmake_extra }} \
6298
${{ github.event.inputs.cmakeextra }}
63-
echo ${PWD}
99+
echo ${PWD}
64100
65101
- name: make
66102
run: cmake --build build --config Release -j
@@ -80,7 +116,24 @@ jobs:
80116
cmake --build examples/build --target install --config Release -j
81117
./examples/build/install/bin/HandleMetaData
82118
83-
- name: package
119+
- name: code signing (macOS)
120+
if: matrix.config.os == 'macOS-latest'
121+
run: |
122+
# Sign the binary
123+
codesign -vvv --force --sign "$APPLE_CODE_SIGN_IDENTITY_APP" \
124+
--entitlements lsl.entitlements \
125+
--timestamp --options runtime \
126+
install/Frameworks/lsl.framework/Versions/A/lsl
127+
codesign -vvv --verify --deep --strict install/Frameworks/lsl.framework/Versions/A/lsl
128+
# Sign the framework itself
129+
codesign -vvv --force --deep --sign "$APPLE_CODE_SIGN_IDENTITY_APP" \
130+
--entitlements lsl.entitlements \
131+
--timestamp --options runtime \
132+
install/Frameworks/lsl.framework
133+
codesign -vvv --verify --deep --strict install/Frameworks/lsl.framework
134+
135+
- name: package (ubuntu, windows)
136+
if: matrix.config.os != 'macOS-latest'
84137
run: |
85138
echo $GITHUB_REF
86139
cmake --build build --target package --config Release -j
@@ -99,6 +152,31 @@ jobs:
99152
cmake -E remove_directory package/_CPack_Packages
100153
cp testing/lslcfgs/default.cfg .
101154
155+
- name: package and notarize (macOS)
156+
if: matrix.config.os == 'macOS-latest'
157+
env:
158+
APPLE_DEVELOPMENT_TEAM: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
159+
APPLE_NOTARIZE_USERNAME: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
160+
APPLE_NOTARIZE_PASSWORD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
161+
run: |
162+
# CMake does a lousy job of creating .pkg files for macOS, so we do it manually
163+
# TODO: However, we need to get the version number from the CMake package!
164+
productbuild --sign "$APPLE_CODE_SIGN_IDENTITY_INST" \
165+
--component install/Frameworks/lsl.framework \
166+
/Library/Frameworks liblsl-1.16.2-Darwin-universal.pkg
167+
# Notarize the package
168+
xcrun notarytool submit liblsl-1.16.2-Darwin-universal.pkg \
169+
--apple-id "$APPLE_NOTARIZE_USERNAME" \
170+
--password "$APPLE_NOTARIZE_PASSWORD" \
171+
--team-id "$APPLE_DEVELOPMENT_TEAM" \
172+
--wait
173+
# Staple the notarization ticket to the package
174+
xcrun stapler staple liblsl-1.16.2-Darwin-universal.pkg
175+
# If notarization fails, you can get the history of notarization requests:
176+
# xcrun notarytool history --apple-id "$APPLE_NOTARIZE_USERNAME" --password "$APPLE_NOTARIZE_PASSWORD" --team-id "$APPLE_DEVELOPMENT_TEAM"
177+
# Then you can check the status of a specific request:
178+
# xcrun notarytool log <request-id> --apple-id "$APPLE_NOTARIZE_USERNAME" --password "$APPLE_NOTARIZE_PASSWORD" --team-id "$APPLE_DEVELOPMENT_TEAM"
179+
102180
- name: upload install dir
103181
uses: actions/upload-artifact@master
104182
with:
@@ -120,7 +198,7 @@ jobs:
120198
ip route
121199
ip -6 route
122200
fi
123-
201+
124202
# run internal tests
125203
- name: unit tests
126204
run: |
@@ -159,3 +237,8 @@ jobs:
159237
MIME=$(file --mime-type $pkg|cut -d ' ' -f2)
160238
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: $TOKEN" -H "Content-Type: $MIME" --data-binary @$pkg $UPLOAD_URL?name=$NAME
161239
done
240+
241+
- name: Clean up keychain
242+
if: matrix.config.os == 'macOS-latest'
243+
run: |
244+
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true

0 commit comments

Comments
 (0)