-
Notifications
You must be signed in to change notification settings - Fork 57
185 lines (157 loc) · 5.44 KB
/
client_python.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
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
name: Python Client
on:
pull_request:
paths:
- "clients/python/**"
branches:
- canary
push:
paths:
- "clients/python/.bumpversion.cfg"
branches:
- canary
tags:
- "release/py_client/v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: poetry
cache-dependency-path: clients/python/poetry.lock
- name: Set Poetry environment
run: |
poetry env use 3.11
working-directory: clients/python
- name: Install dependencies
run: |
poetry install --no-root
working-directory: clients/python
- name: Build FFI
run: |
./tools/build clients/python
working-directory: ./
- name: Lint Python Client
run: |
poetry run mypy .
poetry run ruff check .
poetry run ruff format --check .
working-directory: clients/python
- name: Test Python Client
run: |
poetry run pytest baml_lib/ baml_core/
working-directory: clients/python
- name: Build Python Client
run: poetry build
working-directory: clients/python
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: python-client
path: clients/python/dist
pre-release:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/canary'
environment: nightly
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get artifact
uses: actions/download-artifact@v4
with:
name: python-client
path: clients/python/dist
- id: hash
run: |
VERSION=$(cat clients/python/.bumpversion.cfg | grep "current_version =" | cut -d '=' -f 2 | sed 's/[", ]//g')
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+$ ]]; then
echo "Version ($VERSION) is not a pre-release build"
exit 1
fi
echo "version=${VERSION%.dev*}" >> $GITHUB_OUTPUT
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
echo "tarball_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "whl_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION-py3-none-any.whl | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: Pre-release
uses: softprops/action-gh-release@v2
with:
tag_name: "unstable/py_client/v${{ steps.hash.outputs.version }}"
files: |
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}.tar.gz
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}-py3-none-any.whl
prerelease: true
body: |
## Hashes
Full Build: ${{ steps.hash.outputs.full_version }}
Tarball: ${{ steps.hash.outputs.tarball_hash }}
Wheel: ${{ steps.hash.outputs.whl_hash }}
- name: Mint token
id: mint
uses: tschm/[email protected]
- name: Install Poetry
run: |
pipx install poetry
- name: Publish the package with poetry
run: |
poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}'
working-directory: clients/python
release:
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/release/')
environment: release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get artifact
uses: actions/download-artifact@v4
with:
name: python-client
path: clients/python/dist
- id: hash
run: |
VERSION=$(cat clients/python/.bumpversion.cfg | grep "current_version =" | cut -d '=' -f 2 | sed 's/[", ]//g')
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version ($VERSION) is not a release build"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tarball_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "whl_hash=$(shasum -a 256 clients/python/dist/gloo_lib-$VERSION-py3-none-any.whl | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: "release/py_client/v${{ steps.hash.outputs.version }}"
files: |
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}.tar.gz
clients/python/dist/gloo_lib-${{ steps.hash.outputs.version }}-py3-none-any.whl
prerelease: false
body: |
## Hashes
Tarball: ${{ steps.hash.outputs.tarball_hash }}
Wheel: ${{ steps.hash.outputs.whl_hash }}
- name: Mint token
id: mint
uses: tschm/[email protected]
- name: Install Poetry
run: |
pipx install poetry
- name: Publish the package with poetry
run: |
poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}'
working-directory: clients/python