-
Notifications
You must be signed in to change notification settings - Fork 8
346 lines (324 loc) · 12.2 KB
/
Copy pathrelease.yml
File metadata and controls
346 lines (324 loc) · 12.2 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
name: LangBuilder Release
run-name: LangBuilder Release by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
release_branch:
description: "Branch to release from. This is the branch that contains the source code for the release."
required: true
type: string
release_package_base:
description: "Release LangBuilder Base"
required: true
type: boolean
default: false
release_package_main:
description: "Release LangBuilder"
required: true
type: boolean
default: false
build_docker_base:
description: "Build Docker Image for LangBuilder Base"
required: true
type: boolean
default: false
build_docker_main:
description: "Build Docker Image for LangBuilder"
required: true
type: boolean
default: false
build_docker_ep:
description: "Build Docker Image for LangBuilder with Entrypoint"
required: false
type: boolean
default: false
pre_release:
description: "Pre-release"
required: false
type: boolean
default: false
create_release:
description: "Whether to create a gh release"
required: false
type: boolean
default: true
jobs:
ci:
if: ${{ github.event.inputs.release_package_base == 'true' || github.event.inputs.release_package_main == 'true' }}
name: CI
uses: ./.github/workflows/ci.yml
with:
branch: ${{ inputs.release_branch }}
python-versions: "['3.10', '3.11', '3.12', '3.13']"
frontend-tests-folder: "tests"
release: true
secrets: inherit
build-base:
name: Build LangBuilder Base
needs: [ci]
if: inputs.release_package_base == true
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-version.outputs.version }}
skipped: ${{ steps.check-version.outputs.skipped }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.release_branch }}
- name: Debug branch information
run: |
echo "Workflow triggered from: ${{ github.ref }}"
echo "Checking out branch: ${{ inputs.release_branch }}"
echo "Current branch after checkout: $(git branch --show-current)"
echo "Current commit: $(git rev-parse HEAD)"
- name: Setup Environment
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: "3.13"
prune-cache: false
- name: Install the project
run: uv sync
- name: Check for dependency incompatibility
run: uv pip check
- name: Check Version
id: check-version
run: |
version=$(uv tree | grep 'langbuilder-base' | awk '{print $3}' | sed 's/^v//' | head -n 2 | xargs)
last_released_version=$(curl -s "https://pypi.org/pypi/langbuilder-base/json" | jq -r '.releases | keys | .[]' | sort -V | tail -n 1)
if [ "$version" = "$last_released_version" ]; then
echo "Version $version is already released. Skipping release."
echo skipped=true >> $GITHUB_OUTPUT
exit 0
else
echo version=$version >> $GITHUB_OUTPUT
echo skipped=false >> $GITHUB_OUTPUT
fi
- name: Build project for distribution
if: steps.check-version.outputs.skipped == 'false'
run: make build base=true args="--wheel"
- name: Test CLI
if: steps.check-version.outputs.skipped == 'false'
run: |
# TODO: Unsure why the whl is not built in src/backend/base/dist
mkdir src/backend/base/dist
mv dist/*.whl src/backend/base/dist
uv pip install src/backend/base/dist/*.whl
uv run python -m langbuilder run --host localhost --port 7860 --backend-only &
SERVER_PID=$!
# Wait for the server to start
timeout 120 bash -c 'until curl -f http://localhost:7860/api/v1/auto_login; do sleep 2; done' || (echo "Server did not start in time" && kill $SERVER_PID && exit 1)
# Terminate the server
kill $SERVER_PID || (echo "Failed to terminate the server" && exit 1)
sleep 20 # give the server some time to terminate
# Check if the server is still running
if kill -0 $SERVER_PID 2>/dev/null; then
echo "Failed to terminate the server"
exit 0
else
echo "Server terminated successfully"
fi
# PyPI publishing moved to after cross-platform testing
- name: Upload Artifact
if: steps.check-version.outputs.skipped == 'false'
uses: actions/upload-artifact@v4
with:
name: dist-base
path: src/backend/base/dist
build-main:
name: Build LangBuilder Main
if: inputs.release_package_main == true
needs: [build-base]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.release_branch }}
- name: Debug branch information
run: |
echo "Workflow triggered from: ${{ github.ref }}"
echo "Checking out branch: ${{ inputs.release_branch }}"
echo "Current branch after checkout: $(git branch --show-current)"
echo "Current commit: $(git rev-parse HEAD)"
- name: Setup Environment
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: "3.13"
prune-cache: false
- name: Install the project
run: uv sync
- name: Check for dependency incompatibility
run: uv pip check
# If pre-release is true, we need to check if ["a", "b", "rc", "dev", "post"] is in the version string
# if the version string is incorrect, we need to exit the workflow
- name: Check if pre-release
if: inputs.pre_release == 'true'
run: |
version=$(uv tree | grep 'langbuilder' | grep -v 'langbuilder-base' | awk '{print $2}' | sed 's/^v//')
if [[ "${version}" =~ ^([0-9]+\.)?([0-9]+\.)?[0-9]+((a|b|rc|dev|post)([0-9]+))$ ]]; then
echo "Pre-release version detected. Continuing with the release."
else
echo "Invalid pre-release version detected. Exiting the workflow."
exit 1
fi
- name: Check Version
id: check-version
run: |
version=$(uv tree | grep 'langbuilder' | grep -v 'langbuilder-base' | awk '{print $2}' | sed 's/^v//')
last_released_version=$(curl -s "https://pypi.org/pypi/langbuilder/json" | jq -r '.releases | keys | .[]' | sort -V | tail -n 1)
if [ "$version" = "$last_released_version" ]; then
echo "Version $version is already released. Skipping release."
exit 1
else
echo version=$version >> $GITHUB_OUTPUT
fi
- name: Wait for PyPI Propagation
if: needs.build-base.outputs.skipped == 'false'
run: sleep 300 # wait for 5 minutes to ensure PyPI propagation
- name: Build project for distribution
run: make build main=true args="--no-sources --wheel"
- name: Test CLI
run: |
uv pip install dist/*.whl
uv run python -m langbuilder run --host localhost --port 7860 --backend-only &
SERVER_PID=$!
# Wait for the server to start
timeout 120 bash -c 'until curl -f http://localhost:7860/health_check; do sleep 2; done' || (echo "Server did not start in time" && kill $SERVER_PID && exit 1)
# Terminate the server
kill $SERVER_PID || (echo "Failed to terminate the server" && exit 1)
sleep 20 # give the server some time to terminate
# Check if the server is still running
if kill -0 $SERVER_PID 2>/dev/null; then
echo "Failed to terminate the server"
exit 0
else
echo "Server terminated successfully"
fi
# PyPI publishing moved to after cross-platform testing
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: dist-main
path: dist
test-cross-platform:
name: Test Cross-Platform Installation
if: inputs.release_package_base == true || inputs.release_package_main == true
needs: [build-base, build-main]
uses: ./.github/workflows/cross-platform-test.yml
with:
base-artifact-name: "dist-base"
main-artifact-name: "dist-main"
publish-base:
name: Publish LangBuilder Base to PyPI
if: inputs.release_package_base == true
needs: [build-base, test-cross-platform]
runs-on: ubuntu-latest
steps:
- name: Download base artifact
uses: actions/download-artifact@v4
with:
name: dist-base
path: src/backend/base/dist
- name: Setup Environment
uses: astral-sh/setup-uv@v6
with:
enable-cache: false
python-version: "3.13"
- name: Publish base to PyPI
if: needs.build-base.outputs.skipped == 'false'
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
cd src/backend/base && uv publish dist/*.whl
publish-main:
name: Publish LangBuilder Main to PyPI
if: inputs.release_package_main == true
needs: [build-main, test-cross-platform, publish-base]
runs-on: ubuntu-latest
steps:
- name: Download main artifact
uses: actions/download-artifact@v4
with:
name: dist-main
path: dist
- name: Setup Environment
uses: astral-sh/setup-uv@v6
with:
enable-cache: false
python-version: "3.13"
- name: Publish main to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv publish dist/*.whl
call_docker_build_base:
name: Call Docker Build Workflow for LangBuilder Base
if: inputs.build_docker_base == true
needs: [build-base, build-main, publish-base, publish-main]
uses: ./.github/workflows/docker-build.yml
with:
ref: ${{ inputs.release_branch }}
base_version: ${{ needs.build-base.outputs.version }}
main_version: ${{ needs.build-main.outputs.version }}
release_type: base
pre_release: ${{ inputs.pre_release }}
secrets: inherit
call_docker_build_main_ep:
name: Call Docker Build Workflow for LangBuilder with Entrypoint
if: inputs.build_docker_ep == true
needs: [build-main, publish-main, call_docker_build_base]
uses: ./.github/workflows/docker-build.yml
with:
ref: ${{ inputs.release_branch }}
main_version: ${{ needs.build-main.outputs.version }}
release_type: main-ep
pre_release: False
secrets: inherit
call_docker_build_main:
name: Call Docker Build Workflow for LangBuilder
if: inputs.build_docker_main == true
needs: [build-main, publish-main, call_docker_build_main_ep]
uses: ./.github/workflows/docker-build.yml
with:
ref: ${{ inputs.release_branch }}
main_version: ${{ needs.build-main.outputs.version }}
release_type: main
pre_release: ${{ inputs.pre_release }}
secrets: inherit
call_docker_build_main_all:
name: Call Docker Build Workflow for langbuilder-all
if: inputs.build_docker_main == true
needs: [build-main, publish-main]
uses: ./.github/workflows/docker-build.yml
with:
ref: ${{ inputs.release_branch }}
main_version: ${{ needs.build-main.outputs.version }}
release_type: main-all
pre_release: ${{ inputs.pre_release }}
secrets: inherit
create_release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-main, publish-main]
steps:
- uses: actions/download-artifact@v4
with:
name: dist-main
path: dist
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
generateReleaseNotes: true
prerelease: ${{ inputs.pre_release }}
tag: ${{ needs.build-main.outputs.version }}
commit: ${{ inputs.release_branch }}