Skip to content

Commit 205e71c

Browse files
committed
ci: add workflow to publish python sdk
1 parent de351b1 commit 205e71c

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright 2025 Alibaba Group Holding Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Publish Python SDKs
16+
17+
on:
18+
push:
19+
tags:
20+
- 'python/sandbox/v*'
21+
- 'python/code-interpreter/v*'
22+
23+
jobs:
24+
publish-sandbox:
25+
if: startsWith(github.ref, 'refs/tags/python/sandbox/v')
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: '3.10'
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v5
40+
with:
41+
version: "latest"
42+
43+
- name: Generate API
44+
working-directory: sdks/sandbox/python
45+
run: |
46+
uv run python scripts/generate_api.py
47+
48+
- name: Build package
49+
working-directory: sdks/sandbox/python
50+
run: |
51+
uv build
52+
53+
- name: Publish to PyPI
54+
working-directory: sdks/sandbox/python
55+
env:
56+
UV_PUBLISH_URL: https://test.pypi.org/legacy/
57+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
58+
run: |
59+
uv publish
60+
61+
publish-code-interpreter:
62+
if: startsWith(github.ref, 'refs/tags/python/code-interpreter/v')
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
70+
- name: Set up Python
71+
uses: actions/setup-python@v5
72+
with:
73+
python-version: '3.10'
74+
75+
- name: Install uv
76+
uses: astral-sh/setup-uv@v5
77+
with:
78+
version: "latest"
79+
80+
- name: Build package
81+
working-directory: sdks/code-interpreter/python
82+
run: |
83+
uv build
84+
85+
- name: Publish to PyPI
86+
working-directory: sdks/code-interpreter/python
87+
env:
88+
UV_PUBLISH_URL: https://test.pypi.org/legacy/
89+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
90+
run: |
91+
uv publish

sdks/code-interpreter/python/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ source = "vcs"
5858
[tool.hatch.version.raw-options]
5959
# This package is in a subdirectory; explicitly point setuptools-scm at the git root.
6060
root = "../../.."
61-
tag_regex = "^python-code-interpreter-v(?P<version>\\d+\\.\\d+\\.\\d+(?:[\\.\\w\\+\\-]*)?)$"
62-
git_describe_command = 'git describe --dirty --tags --long --match "python-code-interpreter-v*"'
61+
tag_regex = "^python/code-interpreter/v(?P<version>\\d+\\.\\d+\\.\\d+(?:[\\.\\w\\+\\-]*)?)$"
62+
git_describe_command = 'git describe --dirty --tags --long --match "python/code-interpreter/v*"'
6363
fallback_version = "0.1.0"
6464

6565
[tool.hatch.build]

sdks/sandbox/python/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ source = "vcs"
6060
[tool.hatch.version.raw-options]
6161
# This package is in a subdirectory; explicitly point setuptools-scm at the git root.
6262
root = "../../.."
63-
tag_regex = "^python-sandbox-v(?P<version>\\d+\\.\\d+\\.\\d+(?:[\\.\\w\\+\\-]*)?)$"
64-
git_describe_command = 'git describe --dirty --tags --long --match "python-sandbox-v*"'
63+
tag_regex = "^python/sandbox/v(?P<version>\\d+\\.\\d+\\.\\d+(?:[\\.\\w\\+\\-]*)?)$"
64+
git_describe_command = 'git describe --dirty --tags --long --match "python/sandbox/v*"'
6565
fallback_version = "0.1.0"
6666

6767
[tool.hatch.build]

0 commit comments

Comments
 (0)