Skip to content

Commit e1421f8

Browse files
committed
Add signing keychain to workflow
Add credentials-aware signing keychain for macOS signing requests all (macOS) builds to sign
1 parent 262eaf2 commit e1421f8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/wheels.yml

Lines changed: 45 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,50 @@ 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+
CERTIFICATE="$(mktemp -d)/wmch-devid.p12"
44+
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE }}" | base64 --decode -o $CERTIFICATE
45+
46+
# create a dedicated keychain
47+
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+
68+
# unlock the keychain so build-step doesn't need to know its password
69+
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
70+
3471
- name: Build wheels
3572
uses: pypa/[email protected]
3673

74+
- name: Cleanup Apple Keychain
75+
if: matrix.os == 'macos-12'
76+
shell: bash
77+
run: |
78+
security lock-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
79+
security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
80+
rm -f ${APPLE_SIGNING_KEYCHAIN_PATH}
81+
3782
- uses: actions/upload-artifact@v3
3883
with:
3984
path: ./wheelhouse/*.whl

0 commit comments

Comments
 (0)