Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 6525313

Browse files
committed
feat: add codesign for macos
1 parent 6113040 commit 6525313

File tree

1 file changed

+53
-54
lines changed

1 file changed

+53
-54
lines changed

.github/workflows/python-package.yml

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Package Python Library
22

33
on:
44
push:
5-
branches: [ feat/python-package-ci ]
5+
branches: [ feat/python-codesign ]
66
workflow_dispatch:
77
inputs:
88
model_dir:
@@ -38,15 +38,15 @@ jobs:
3838
# - os: "linux"
3939
# name: "amd64"
4040
# runs-on: "ubuntu-20-04-cuda-12-0"
41-
# - os: "mac"
42-
# name: "amd64"
43-
# runs-on: "macos-selfhosted-12"
44-
# - os: "mac"
45-
# name: "arm64"
46-
# runs-on: "macos-silicon"
47-
- os: "windows"
41+
- os: "mac"
4842
name: "amd64"
49-
runs-on: "windows-cuda-12-0"
43+
runs-on: "macos-selfhosted-12"
44+
- os: "mac"
45+
name: "arm64"
46+
runs-on: "macos-13-arm"
47+
# - os: "windows"
48+
# name: "amd64"
49+
# runs-on: "windows-cuda-12-0"
5050
steps:
5151
- name: Clone
5252
id: checkout
@@ -66,13 +66,33 @@ jobs:
6666
with:
6767
python-version: "3.11"
6868

69+
- name: Get Cer for code signing
70+
if: runner.os == 'macOS'
71+
run: base64 -d <<< "$CODE_SIGN_P12_BASE64" > /tmp/codesign.p12
72+
shell: bash
73+
env:
74+
CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
75+
76+
- uses: apple-actions/import-codesign-certs@v2
77+
continue-on-error: true
78+
if: runner.os == 'macOS'
79+
with:
80+
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
81+
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
82+
83+
- name: Get Cer for code signing
84+
if: runner.os == 'macOS'
85+
run: base64 -d <<< "$NOTARIZE_P8_BASE64" > /tmp/notary-key.p8
86+
shell: bash
87+
env:
88+
NOTARIZE_P8_BASE64: ${{ secrets.NOTARIZE_P8_BASE64 }}
89+
6990
- name: Install dependencies Windows
7091
if: runner.os == 'windows'
7192
shell: pwsh
7293
run: |
73-
74-
python3 -m pip install --upgrade pip
75-
python3 -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
94+
python3 -m pip install --upgrade pip
95+
python3 -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
7696
7797
- name: Install dependencies Linux
7898
if: runner.os == 'linux'
@@ -102,9 +122,8 @@ jobs:
102122
echo "Python path (where.exe): $pythonPath"
103123
$pythonFolder = Split-Path -Path "$pythonPath" -Parent
104124
echo "PYTHON_FOLDER=$pythonFolder" >> $env:GITHUB_ENV
105-
106125
copy "$pythonFolder\python*.*" "$pythonFolder\Scripts\"
107-
126+
108127
- name: prepare python package macos
109128
if : runner.os == 'macOs'
110129
run: |
@@ -128,7 +147,22 @@ jobs:
128147
rm -rf $PYTHON_FOLDER/lib/python3.1
129148
echo "PYTHON_FOLDER=$PYTHON_FOLDER" >> $GITHUB_ENV
130149
echo "github end PYTHON_FOLDER: ${{env.PYTHON_FOLDER}}"
131-
150+
151+
- name: Notary macOS Binary
152+
if: runner.os == 'macOS'
153+
run: |
154+
codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime ${{env.PYTHON_FOLDER}}/bin/python
155+
codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime ${{env.PYTHON_FOLDER}}/bin/python3
156+
curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b /usr/local/bin
157+
cd engine/cortex
158+
# Notarize the binary
159+
quill notarize ${{env.PYTHON_FOLDER}}/bin/python
160+
quill notarize ${{env.PYTHON_FOLDER}}/bin/python3
161+
env:
162+
QUILL_NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }}
163+
QUILL_NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }}
164+
QUILL_NOTARY_KEY: "/tmp/notary-key.p8"
165+
132166
- name: Upload Artifact
133167
#if : runner.os == 'windows' || runner.os == 'linux'
134168
uses: actions/upload-artifact@v4
@@ -143,43 +177,8 @@ jobs:
143177
run: |
144178
rm ${{env.PYTHON_FOLDER}}/Scripts/python*.*
145179
146-
codesign:
147-
runs-on: macos-latest
148-
needs: build-and-test
149-
steps:
150-
- name: checkout
151-
uses: actions/checkout@v3
152-
- uses: apple-actions/import-codesign-certs@v2
180+
- name: Remove Keychain
153181
continue-on-error: true
154-
with:
155-
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
156-
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
157-
- name: Download Artifact
158-
uses: actions/download-artifact@v4
159-
with:
160-
name: ${{env.MODEL_NAME}}-mac-amd64
161-
path: ${{env.MODEL_NAME}}-mac-amd64
162-
- name: Download Artifact
163-
uses: actions/download-artifact@v4
164-
with:
165-
name: ${{env.MODEL_NAME}}-mac-arm64
166-
path: ${{env.MODEL_NAME}}-mac-arm64
167-
168-
- run: |
169-
find "${{env.MODEL_NAME}}-mac-amd64" \( -type f -perm +111 \) -exec codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime {} \;
170-
find "${{env.MODEL_NAME}}-mac-arm64" \( -type f -perm +111 \) -exec codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime {} \;
171-
172-
- name: Upload Artifact
173-
uses: actions/upload-artifact@v4
174-
with:
175-
name: ${{env.MODEL_NAME}}-mac-amd64-signed
176-
path: ${{env.MODEL_NAME}}-mac-amd64
177-
include-hidden-files: true
178-
compression-level: 9
179-
- name: Upload Artifact
180-
uses: actions/upload-artifact@v4
181-
with:
182-
name: ${{env.MODEL_NAME}}-mac-arm64-signed
183-
path: ${{env.MODEL_NAME}}-mac-arm64
184-
include-hidden-files: true
185-
compression-level: 9
182+
if: always() && runner.os == 'macOS'
183+
run: |
184+
security delete-keychain signing_temp.keychain

0 commit comments

Comments
 (0)