Skip to content

Commit dbb09de

Browse files
committed
Add signing keychain to workflow
Add credentials-aware signing keychain for macOS signing requests all (macOS) builds to sign
1 parent 3a6b9b0 commit dbb09de

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/wheels.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ env:
1212
LIBZIM_DL_VERSION: "2023-04-19"
1313
MACOSX_DEPLOYMENT_TARGET: "11.0"
1414
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
15+
# APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step
16+
APPLE_SIGNING_KEYCHAIN_PROFILE: "build-profile"
17+
APPLE_SIGNING_IDENTITY: "${{ secrets.APPLE_SIGNING_IDENTITY }}"
18+
SIGN_APPLE: "yes"
1519

1620

1721
jobs:
@@ -31,9 +35,47 @@ jobs:
3135
with:
3236
platforms: all
3337

38+
- name: Prepare Apple Keychain for Signing
39+
if: matrix.os == 'macos-12'
40+
shell: bash
41+
run: |
42+
# store certificate on filesystem
43+
export CERTIFICATE="$(mktemp -d)/wmch-devid.p12"
44+
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE }}" | base64 --decode -o $CERTIFICATE
45+
46+
# create a dedicated keychain
47+
export APPLE_SIGNING_KEYCHAIN_PATH="$(mktemp -d)/build.keychain"
48+
echo "APPLE_SIGNING_KEYCHAIN_PATH=${APPLE_SIGNING_KEYCHAIN_PATH}" >> "$GITHUB_ENV"
49+
security create-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
50+
security default-keychain -s ${APPLE_SIGNING_KEYCHAIN_PATH}
51+
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
52+
53+
# import certificate into keychain then remove from filesystem
54+
security import ${CERTIFICATE} -k ${APPLE_SIGNING_KEYCHAIN_PATH} -P "${{ secrets.APPLE_SIGNING_P12_PASSWORD }}" -A
55+
rm $CERTIFICATE
56+
57+
# store signing credentials into the keychain
58+
security set-key-partition-list -S "apple-tool:,apple:" -s -k mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
59+
security find-identity -v
60+
xcrun notarytool store-credentials \
61+
--apple-id "${{ secrets.APPLE_SIGNING_ALTOOL_USERNAME }}" \
62+
--password "${{ secrets.APPLE_SIGNING_ALTOOL_PASSWORD }}" \
63+
--team-id "${{ secrets.APPLE_SIGNING_TEAM }}" \
64+
--validate \
65+
--keychain ${APPLE_SIGNING_KEYCHAIN_PATH} \
66+
${APPLE_SIGNING_KEYCHAIN_PROFILE}
67+
3468
- name: Build wheels
3569
uses: pypa/[email protected]
3670

71+
- name: Cleanup Apple Keychain
72+
if: matrix.os == 'macos-12'
73+
shell: bash
74+
run: |
75+
security lock-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
76+
security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
77+
rm -f ${APPLE_SIGNING_KEYCHAIN_PATH}
78+
3779
- uses: actions/upload-artifact@v3
3880
with:
3981
path: ./wheelhouse/*.whl

0 commit comments

Comments
 (0)