30
shell: bash --noprofile --norc -exo pipefail {0}
32
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
33
cancel-in-progress: true
36
PYOXIDIZER_VERSION: '0.24.0'
40
name: Get commit message
41
runs-on: ubuntu-latest
42
if: "github.repository == 'bentoml/OpenLLM'"
44
message: ${{ steps.commit_message.outputs.message }}
46
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
49
ref: ${{ github.event.pull_request.head.sha }}
50
- name: Get commit message
54
COMMIT_MSG=$(git log --no-merges -1 --oneline)
55
echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
56
echo github.ref ${{ github.ref }}
58
name: Build wheel and source distribution
59
runs-on: ubuntu-latest
60
needs: get_commit_message
62
contains(needs.get_commit_message.outputs.message, '[binary build]') || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, '03 - Standalone Build')) || (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')))
64
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
67
- uses: bentoml/setup-bentoml-action@862aa8fa0e0c3793fcca4bfe7a62717a497417e4
69
bentoml-version: 'main'
70
- name: Pull latest change
71
if: ${{ github.event_name != 'pull_request' }}
72
run: git pull --autostash --no-edit --gpg-sign --ff origin main
73
- name: Install build frontend
74
run: python -m pip install --upgrade build
78
python -m build -sw openllm-python/
79
- name: Upload artifacts
80
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
82
name: binary-artefacts
83
path: openllm-python/dist/*
84
if-no-files-found: error
86
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
91
working-directory: openllm-python
92
runs-on: ${{ matrix.job.os }}
98
- target: aarch64-unknown-linux-gnu
101
- target: x86_64-unknown-linux-gnu
104
- target: x86_64-unknown-linux-musl
107
- target: i686-unknown-linux-gnu
110
- target: powerpc64le-unknown-linux-gnu
119
- target: aarch64-apple-darwin
121
- target: x86_64-apple-darwin
124
version: ${{ steps.version.outputs.version }}
127
CARGO_BUILD_TARGET: ${{ matrix.job.target }}
129
PYAPP_VERSION: '0.10.1'
130
PYAPP_PIP_EXTERNAL: 'true'
132
- name: Checkout code
133
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
136
- name: Pull latest change
137
if: ${{ github.event_name != 'pull_request' }}
138
run: git pull --autostash --no-edit --gpg-sign --ff origin main
141
mkdir $PYAPP_REPO && curl -L https://github.com/ofek/pyapp/releases/download/v$PYAPP_VERSION/source.tar.gz | tar --strip-components=1 -xzf - -C $PYAPP_REPO
142
- name: Set up Python
143
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c
145
python-version-file: .python-version-default
146
- name: Install Hatch
147
run: pip install -U hatch
148
- name: Install Rust toolchain
149
uses: dtolnay/rust-toolchain@78c6b5541adb5849f5d72d15da722aedb26327ca
151
targets: ${{ matrix.job.target }}
152
- name: Set up cross compiling
154
uses: taiki-e/install-action@5794068c211bc8f5f4514b7c3f03d6adbe66f1b7
157
- name: Configure cross compiling
159
run: echo "CARGO=cross" >> $GITHUB_ENV
160
- name: Configure target
162
config_file="$PYAPP_REPO/.cargo/config_${{ matrix.job.target }}.toml"
163
if [[ -f "$config_file" ]]; then
164
mv "$config_file" "$PYAPP_REPO/.cargo/config.toml"
166
- name: Download Python artifacts
167
if: ${{ !startsWith(github.event.ref, 'refs/tags') }}
168
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
170
name: binary-artefacts
171
path: openllm-python/dist
172
- name: Configure embedded project
173
if: ${{ !startsWith(github.event.ref, 'refs/tags') }}
176
wheel="$(echo *.whl)"
177
mv "$wheel" "../$PYAPP_REPO"
178
echo "PYAPP_PROJECT_PATH=$wheel" >> $GITHUB_ENV
180
run: hatch build --target app
183
- name: Set project version
186
old_version="$(hatch version)"
187
version="${old_version/dev/}"
189
if [[ "$version" != "$old_version" ]]; then
191
find . -type f -iname "openllm-*" | while read -r file; do
192
binary=$(echo "$file" | sed 's/dev//')
197
echo "version=$version" >> $GITHUB_OUTPUT
199
- name: Archive binary
203
find . -type f -iname "openllm-*" | while read -r file; do
204
if [[ "$file" =~ -pc-windows- ]]; then
205
7z a "../../packaging/${file:0:-4}.zip" "$file"
207
binary="${file/dev/}"
209
tar -czf "../../packaging/$binary.tar.gz" "$file"
212
- name: Upload staged archive
213
if: runner.os != 'Linux'
214
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
216
name: staged-${{ runner.os }}
217
path: openllm-python/packaging/*
218
if-no-files-found: error
219
- name: Upload archive
220
if: runner.os == 'Linux'
221
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
224
path: openllm-python/packaging/*
225
if-no-files-found: error
227
name: Build Windows installers
230
runs-on: windows-2022
232
VERSION: ${{ needs.binaries.outputs.version }}
235
working-directory: openllm-python
237
- name: Checkout code
238
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
239
- name: Set up Python
240
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c
242
python-version-file: .python-version-default
243
- name: Pull latest change
244
run: git pull --autostash --no-edit --gpg-sign --ff origin main
245
- name: Install PyOxidizer ${{ env.PYOXIDIZER_VERSION }}
246
run: pip install pyoxidizer==${{ env.PYOXIDIZER_VERSION }}
247
- name: Download staged binaries
248
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
250
name: staged-${{ runner.os }}
251
path: openllm-python/archives
252
- name: Extract staged binaries
255
for f in archives/*; do
259
- name: Prepare binaries
263
if [[ "$f" =~ openllm-${{ env.VERSION }}-(.+).exe$ ]]; then
264
target="${BASH_REMATCH[1]}"
265
mkdir -p "targets/$target"
266
mv "$f" "targets/$target/${{ env.APP_NAME }}.exe"
269
- name: Build installers
271
pyoxidizer build windows_installers --release --var version ${{ env.VERSION }}
272
- name: Prepare installers
275
mv build/*/release/*/*.{exe,msi} installers
276
- name: Upload binaries
277
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
280
path: openllm-python/archives/*
281
if-no-files-found: error
282
- name: Upload installers
283
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
286
path: openllm-python/installers/*