-
Notifications
You must be signed in to change notification settings - Fork 145
148 lines (134 loc) · 4.98 KB
/
python-package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Build and Package Python Library
on:
push:
branches: [ feat/codesign-python-package ]
workflow_dispatch:
inputs:
model_dir:
description: "Path to model directory in janhq/models repo"
required: true
model_name:
description: "name of model to be release"
required: true
env:
MODEL_DIR: models/whispervq # ${{ inputs.model_dir }}
MODEL_NAME: whispervq # ${{ inputs.model_name }}
jobs:
build-and-test:
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
# - os: "linux"
# name: "amd64"
# runs-on: "ubuntu-20-04-cuda-12-0"
- os: "mac"
name: "amd64"
runs-on: "macos-selfhosted-12"
- os: "mac"
name: "arm64"
runs-on: "macos-silicon"
# - os: "windows"
# name: "amd64"
# runs-on: "windows-cuda-12-0"
steps:
- name: Clone
id: checkout
uses: actions/checkout@v3
with:
submodules: recursive
repository: janhq/models
ref: "feat/ci-python-models"
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.11
- name: Install dependencies Windows
if: runner.os == 'windows'
run: |
conda create -y -n ${{env.MODEL_NAME}} python=3.11
source $HOME/miniconda/bin/activate base
conda init
conda activate ${{env.MODEL_NAME}}
python -m pip install --upgrade pip
python -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
- name: Install dependencies Linux
if: runner.os == 'linux'
run: |
conda create -y -n ${{env.MODEL_NAME}} python=3.11
source $HOME/miniconda/bin/activate base
conda init
conda activate ${{env.MODEL_NAME}}
python -m pip install --upgrade pip
python -m pip install -r ${{env.MODEL_DIR}}/requirements.cuda.txt
- name: Install dependencies Mac
if: runner.os == 'macOS'
run: |
conda create -y -n ${{env.MODEL_NAME}} python=3.11
source $HOME/miniconda/bin/activate base
conda init
conda activate ${{env.MODEL_NAME}}
python -m pip install --upgrade pip
python -m pip install -r ${{env.MODEL_DIR}}/requirements.txt
- name: prepare python package windows
if : runner.os == 'windows'
shell: cmd
run: |
source $HOME/miniconda/bin/activate base
conda init
conda activate ${{env.MODEL_NAME}}
for /f "delims=" %%a in ('where python') do set "PYTHON_PATH=%%a"
echo %PYTHON_PATH%
- name: prepare python package unix
if : runner.os != 'windows'
run: |
source $HOME/miniconda/bin/activate base
conda init
conda activate ${{env.MODEL_NAME}}
PYTHON_PATH=$(which python)
echo $PYTHON_PATH
PYTHON_FOLDER=$(dirname $(dirname "$PYTHON_PATH"))
echo "PYTHON_FOLDER=$PYTHON_FOLDER" >> $GITHUB_ENV
echo "github end PYTHON_FOLDER: ${{env.PYTHON_FOLDER}}"
- name: Upload Artifact
if : runner.os == 'macOS' || runner.os == 'linux'
uses: actions/upload-artifact@v4
with:
name: ${{env.MODEL_NAME}}-${{ matrix.os }}-${{ matrix.name }}
path: ${{env.PYTHON_FOLDER}}
codesign:
runs-on: macos-latest
needs: build-and-test
steps:
- name: checkout
uses: actions/checkout@v3
- uses: apple-actions/import-codesign-certs@v2
continue-on-error: true
with:
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{env.MODEL_NAME}}-mac-amd64
path: ${{env.MODEL_NAME}}-mac-amd64
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{env.MODEL_NAME}}-mac-arm64
path: ${{env.MODEL_NAME}}-mac-arm64
- run: |
find "${{env.MODEL_NAME}}-mac-amd64" \( -type f \) -exec codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime {} \;
find "${{env.MODEL_NAME}}-mac-arm64" \( -type f \) -exec codesign --force --entitlements="./engine/templates/macos/entitlements.plist" -s "${{ secrets.DEVELOPER_ID }}" --options=runtime {} \;
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.MODEL_NAME}}-mac-amd64-signed
path: ${{env.MODEL_NAME}}-mac-amd64
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.MODEL_NAME}}-mac-arm64-signed
path: ${{env.MODEL_NAME}}-mac-arm64