1+
12name : Build and Package Python Library
23
34on :
45 push :
5- branches : [ feat/python-package-ci ]
6+ branches : [ feat/codesign- python-package ]
67 workflow_dispatch :
78 inputs :
89 model_dir :
@@ -28,15 +29,15 @@ jobs:
2829 # - os: "linux"
2930 # name: "amd64"
3031 # runs-on: "ubuntu-20-04-cuda-12-0"
31- # - os: "mac"
32- # name: "amd64"
33- # runs-on: "macos-selfhosted-12"
34- # - os: "mac"
35- # name: "arm64"
36- # runs-on: "macos-silicon"
37- - os : " windows"
32+ - os : " mac"
3833 name : " amd64"
39- runs-on : " windows-cuda-12-0"
34+ runs-on : " macos-selfhosted-12"
35+ - os : " mac"
36+ name : " arm64"
37+ runs-on : " macos-silicon"
38+ # - os: "windows"
39+ # name: "amd64"
40+ # runs-on: "windows-cuda-12-0"
4041 steps :
4142 - name : Clone
4243 id : checkout
@@ -45,145 +46,104 @@ jobs:
4546 submodules : recursive
4647 repository : janhq/models
4748 ref : " feat/ci-python-models"
48- - name : use python
49- if : runner.os == 'Windows'
50- uses : actions/setup-python@v5
51- with :
52- python-version : " 3.11"
5349
54- # - name: Install Miniconda on Linux
55- # if: runner.os == 'Linux'
56- # run: |
57- # wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
58- # bash miniconda.sh -b -p $HOME/miniconda
59- # echo "$HOME/miniconda/bin" >> $GITHUB_PATH
60-
61- # - name: Install Miniconda on macOS
62- # if: runner.os == 'macOS'
63- # run: |
64- # if [ "$(uname -m)" = "arm64" ]; then
65- # echo "Running on macOS ARM"
66- # MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh"
67- # else
68- # echo "Running on macOS Intel"
69- # MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh"
70- # fi
71- # echo "Downloading Miniconda from $MINICONDA_URL"
72- # curl -L $MINICONDA_URL -o miniconda.sh
73- # bash miniconda.sh -b -p $HOME/miniconda
74- # echo "$HOME/miniconda/bin" >> $GITHUB_PATH
75-
76- # - name: Install Miniconda on Windows
77- # if: runner.os == 'Windows'
78- # shell: pwsh
79- # run: |
80- # $minicondaUrl = 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe'
81- # $installerPath = "$env:USERPROFILE\\miniconda.exe"
82- # Invoke-WebRequest -Uri $minicondaUrl -OutFile $installerPath
83- # Start-Process -FilePath $installerPath -ArgumentList '/InstallationType=JustMe', '/AddToPath=1', '/RegisterPython=0', '/S', ('/D=' + $env:USERPROFILE + '\\Miniconda3') -Wait
84- # echo "$env:USERPROFILE\\Miniconda3" >> $GITHUB_PATH
50+ - uses : conda-incubator/setup-miniconda@v3
51+ with :
52+ auto-update-conda : true
53+ python-version : 3.11
8554
8655 - name : Install dependencies Windows
8756 if : runner.os == 'windows'
88- shell : pwsh
8957 run : |
90-
91- python3 -m pip install --upgrade pip
92- python3 -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
93-
94- # - name: Install dependencies Linux
95- # if: runner.os == 'linux'
96- # run: |
97- # export PATH=$PATH:$HOME/miniconda/bin/
98- # conda init
99- # conda create -y -n ${{env.MODEL_NAME}} python=3.11
100- # source $HOME/miniconda/bin/activate base
101- # conda activate ${{env.MODEL_NAME}}
102- # python -m pip install --upgrade pip
103- # python -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
58+ conda create -y -n ${{env.MODEL_NAME}} python=3.11
59+ source $HOME/miniconda/bin/activate base
60+ conda init
61+ conda activate ${{env.MODEL_NAME}}
62+ python -m pip install --upgrade pip
63+ python -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
64+ - name : Install dependencies Linux
65+ if : runner.os == 'linux'
66+ run : |
67+ conda create -y -n ${{env.MODEL_NAME}} python=3.11
68+ source $HOME/miniconda/bin/activate base
69+ conda init
70+ conda activate ${{env.MODEL_NAME}}
71+ python -m pip install --upgrade pip
72+ python -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
10473
105- # - name: Install dependencies Mac
106- # if: runner.os == 'macOS'
107- # run: |
108- # export PATH=$PATH:$HOME/miniconda/bin/
109- # conda init
110- # conda create -y -n ${{env.MODEL_NAME}} python=3.11
111- # source $HOME/miniconda/bin/activate base
112- # conda activate ${{env.MODEL_NAME}}
113- # python -m pip install --upgrade pip
114- # python -m pip install -r ${{env.MODEL_DIR}}/requirements.txt
115-
74+ - name : Install dependencies Mac
75+ if : runner.os == 'macOS'
76+ run : |
77+ conda create -y -n ${{env.MODEL_NAME}} python=3.11
78+ source $HOME/miniconda/bin/activate base
79+ conda init
80+ conda activate ${{env.MODEL_NAME}}
81+ python -m pip install --upgrade pip
82+ python -m pip install -r ${{env.MODEL_DIR}}/requirements.txt
11683 - name : prepare python package windows
11784 if : runner.os == 'windows'
118- shell : pwsh
85+ shell : cmd
11986 run : |
120- $pythonPath = where.exe python
121- echo "Python path (where.exe): $pythonPath"
122-
123-
124- $pythonFolder = Split-Path -Path "$pythonPath" -Parent
125- echo "PYTHON_FOLDER=$pythonFolder" >> $env:GITHUB_ENV
126-
127- Move-Item -Path "$pythonFolder\python*.*" -Destination "$pythonFolder\Scripts\" -Force
87+ source $HOME/miniconda/bin/activate base
88+ conda init
89+ conda activate ${{env.MODEL_NAME}}
90+ for /f "delims=" %%a in ('where python') do set "PYTHON_PATH=%%a"
91+ echo %PYTHON_PATH%
12892
129- # - name: prepare python package unix
130- # if : runner.os != 'windows'
131- # run: |
132- # export PATH=$PATH:$HOME/miniconda/bin/
133- # source $HOME/miniconda/bin/activate base
134- # conda activate ${{env.MODEL_NAME}}
135- # PYTHON_PATH=$(which python)
136- # echo $PYTHON_PATH
137- # PYTHON_FOLDER=$(dirname $(dirname "$PYTHON_PATH"))
138- # echo "PYTHON_FOLDER=$PYTHON_FOLDER" >> $GITHUB_ENV
139- # echo "github end PYTHON_FOLDER: ${{env.PYTHON_FOLDER}}"
140-
141- # - name: Upload Artifact
142- # if : runner.os == 'macOS' || runner.os == 'linux'
143- # uses: actions/upload-artifact@v4
144- # with:
145- # name: ${{env.MODEL_NAME}}-${{ matrix.os }}-${{ matrix.name }}
146- # path: ${{env.PYTHON_FOLDER}}
147-
93+ - name : prepare python package unix
94+ if : runner.os != 'windows'
95+ run : |
96+ source $HOME/miniconda/bin/activate base
97+ conda init
98+ conda activate ${{env.MODEL_NAME}}
99+ PYTHON_PATH=$(which python)
100+ echo $PYTHON_PATH
101+ PYTHON_FOLDER=$(dirname $(dirname "$PYTHON_PATH"))
102+ echo "PYTHON_FOLDER=$PYTHON_FOLDER" >> $GITHUB_ENV
103+ echo "github end PYTHON_FOLDER: ${{env.PYTHON_FOLDER}}"
148104 - name : Upload Artifact
149- if : runner.os == 'windows '
105+ if : runner.os == 'macOS' || runner.os == 'linux '
150106 uses : actions/upload-artifact@v4
151107 with :
152108 name : ${{env.MODEL_NAME}}-${{ matrix.os }}-${{ matrix.name }}
153109 path : ${{env.PYTHON_FOLDER}}
154110 include-hidden-files : true
155111
156- # codesign:
157- # runs-on: macos-latest
158- # needs: build-and-test
159- # steps:
160- # - name: checkout
161- # uses: actions/checkout@v3
162- # - uses: apple-actions/import-codesign-certs@v2
163- # continue-on-error: true
164- # with:
165- # p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
166- # p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
167- # - name: Download Artifact
168- # uses: actions/download-artifact@v4
169- # with:
170- # name: ${{env.MODEL_NAME}}-mac-amd64
171- # - name: Download Artifact
172- # uses: actions/download-artifact@v4
173- # with:
174- # name: ${{env.MODEL_NAME}}-mac-amd64
112+ codesign :
113+ runs-on : macos-latest
114+ needs : build-and-test
115+ steps :
116+ - name : checkout
117+ uses : actions/checkout@v3
118+ - uses : apple-actions/import-codesign-certs@v2
119+ continue-on-error : true
120+ with :
121+ p12-file-base64 : ${{ secrets.CODE_SIGN_P12_BASE64 }}
122+ p12-password : ${{ secrets.CODE_SIGN_P12_PASSWORD }}
123+ - name : Download Artifact
124+ uses : actions/download-artifact@v4
125+ with :
126+ name : ${{env.MODEL_NAME}}-mac-amd64
127+ path : ${{env.MODEL_NAME}}-mac-amd64
128+ - name : Download Artifact
129+ uses : actions/download-artifact@v4
130+ with :
131+ name : ${{env.MODEL_NAME}}-mac-arm64
132+ path : ${{env.MODEL_NAME}}-mac-arm64
175133
176- # - run: |
177- # find "${{env.MODEL_NAME}}-mac-amd64" \( -type f -perm +111 -o -name "*.node" \) -exec codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime {} \;
178- # find "${{env.MODEL_NAME}}-mac-arm64" \( -type f -perm +111 -o -name "*.node" \) -exec codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime {} \;
134+ - run : |
135+ 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 {} \;
136+ 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 {} \;
179137
180- # - name: Upload Artifact
181- # uses: actions/upload-artifact@v4
182- # with:
183- # name: ${{env.MODEL_NAME}}-mac-amd64
184- # path: ${{env.MODEL_NAME}}-mac-amd64
185- # - name: Upload Artifact
186- # uses: actions/upload-artifact@v4
187- # with:
188- # name: ${{env.MODEL_NAME}}-mac-arm64
189- # path: ${{env.MODEL_NAME}}-mac-arm64
138+ - name : Upload Artifact
139+ uses : actions/upload-artifact@v4
140+ with :
141+ name : ${{env.MODEL_NAME}}-mac-amd64-signed
142+ path : ${{env.MODEL_NAME}}-mac-amd64
143+ include-hidden-files : true
144+ - name : Upload Artifact
145+ uses : actions/upload-artifact@v4
146+ with :
147+ name : ${{env.MODEL_NAME}}-mac-arm64-signed
148+ path : ${{env.MODEL_NAME}}-mac-arm64
149+ include-hidden-files : true
0 commit comments