Skip to content

Commit d188194

Browse files
Merge pull request #248 from acsoto/python-cli-publish-workflow
Add Python CLI publish workflow
2 parents 46b07f7 + 548bf3c commit d188194

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Python CLI Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "cmd/cli/**"
9+
- ".github/workflows/python-cli-publish.yml"
10+
workflow_dispatch:
11+
12+
jobs:
13+
publish-python-cli:
14+
runs-on: ubuntu-latest
15+
environment: pypi
16+
permissions:
17+
contents: read
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
29+
- name: Install build dependency
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install build
33+
34+
- name: Build package
35+
run: make build-python-cli
36+
37+
- name: Read package version
38+
id: package
39+
working-directory: cmd/cli
40+
run: |
41+
version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
42+
echo "version=$version" >> "$GITHUB_OUTPUT"
43+
44+
- name: Check whether version already exists on PyPI
45+
id: pypi
46+
env:
47+
PACKAGE_NAME: agentcube-cli
48+
PACKAGE_VERSION: ${{ steps.package.outputs.version }}
49+
run: |
50+
status="$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/${PACKAGE_NAME}/${PACKAGE_VERSION}/json")"
51+
if [ "$status" = "200" ]; then
52+
echo "exists=true" >> "$GITHUB_OUTPUT"
53+
echo "Version ${PACKAGE_VERSION} already exists on PyPI, skipping publish."
54+
else
55+
echo "exists=false" >> "$GITHUB_OUTPUT"
56+
echo "Version ${PACKAGE_VERSION} is not published yet."
57+
fi
58+
59+
- name: Publish package to PyPI
60+
if: steps.pypi.outputs.exists != 'true'
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
with:
63+
packages-dir: cmd/cli/dist/

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,12 @@ build-python-sdk: ## Build Python SDK
324324
cp LICENSE "$$tmp_file"; \
325325
cd sdk-python && python3 -m build
326326
@echo "Build complete. Artifacts are in sdk-python/dist/"
327+
328+
.PHONY: build-python-cli
329+
build-python-cli: ## Build Python CLI
330+
@echo "Building Python CLI..."
331+
@tmp_file="$(PROJECT_DIR)/cmd/cli/LICENSE"; \
332+
trap 'rm -f "$$tmp_file"' EXIT; \
333+
cp LICENSE "$$tmp_file"; \
334+
cd cmd/cli && python3 -m build
335+
@echo "Build complete. Artifacts are in cmd/cli/dist/"

cmd/cli/MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include LICENSE
2+
include README.md
3+
recursive-include examples *
4+
global-exclude __pycache__ *.py[cod]

cmd/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AgentCube CLI is a developer tool that streamlines the development, packaging, b
66

77
### Prerequisites
88

9-
- Python 3.8+
9+
- Python 3.10+
1010
- Git
1111
- Docker (optional, for container builds)
1212

@@ -69,7 +69,7 @@ pip install -e .
6969
### From PyPI (Recommended)
7070

7171
```bash
72-
pip install agentcube
72+
pip install agentcube-cli
7373
```
7474

7575
### From Source

cmd/cli/pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ name = "agentcube-cli"
77
version = "0.1.0"
88
description = "AgentCube CLI - A developer tool for packaging, building, and deploying AI agents to AgentCube"
99
readme = "README.md"
10-
license = { text = "Apache-2.0" }
10+
license = "Apache-2.0"
1111
keywords = ["ai", "agent", "kubernetes", "volcano", "agentcube", "cli"]
1212
classifiers = [
1313
"Development Status :: 3 - Alpha",
1414
"Intended Audience :: Developers",
15-
"License :: OSI Approved :: Apache Software License",
1615
"Programming Language :: Python :: 3",
1716
"Programming Language :: Python :: 3.10",
1817
"Programming Language :: Python :: 3.11",
@@ -66,4 +65,4 @@ Issues = "https://github.com/volcano-sh/agentcube/issues"
6665
kubectl-agentcube = "agentcube.cli.main:app"
6766

6867
[tool.setuptools]
69-
packages = ["agentcube", "agentcube.cli", "agentcube.runtime", "agentcube.operations", "agentcube.services"]
68+
packages = ["agentcube", "agentcube.cli", "agentcube.runtime", "agentcube.operations", "agentcube.services"]

0 commit comments

Comments
 (0)