Skip to content

Commit 1436259

Browse files
ci(packaging): publish only the tagged pypi package (#450)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent dac8cf7 commit 1436259

2 files changed

Lines changed: 57 additions & 5 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
name: Publish PyPI
55
on:
66
workflow_dispatch:
7+
inputs:
8+
package:
9+
description: Package to publish
10+
required: true
11+
default: all
12+
type: choice
13+
options:
14+
- all
15+
- agentex-client
16+
- agentex-sdk
717

818
release:
919
types: [published]
@@ -33,3 +43,5 @@ jobs:
3343
# Back-compat fallback — used by bin/publish-pypi when the
3444
# dedicated tokens above are unset.
3545
PYPI_TOKEN: ${{ secrets.AGENTEX_PYPI_TOKEN || secrets.PYPI_TOKEN }}
46+
# Manual dispatches can override tag-derived package selection.
47+
PYPI_PACKAGE: ${{ inputs.package }}

bin/publish-pypi

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
11
#!/usr/bin/env bash
22

3-
# Publish slim (root) before heavy (adk/): heavy pins slim, so a slim-first
4-
# failure aborts before shipping a heavy that needs an unreleased client.
3+
# Publish only the package requested by the component tag. Manual dispatches can
4+
# set PYPI_PACKAGE=all to publish both packages; in that case publish slim
5+
# before heavy because the heavy package depends on the slim package.
56

67
set -eux
78

89
rm -rf dist
910
# --wheel: the heavy's cross-dir force-include can't build via sdist.
1011
uv build --all-packages --wheel
1112

12-
# --check-url makes the per-component-tag double-trigger idempotent.
13-
uv publish --check-url https://pypi.org/simple/ --token="${AGENTEX_CLIENT_PYPI_TOKEN:-$PYPI_TOKEN}" dist/agentex_client-*.whl
14-
uv publish --check-url https://pypi.org/simple/ --token="${AGENTEX_PYPI_TOKEN:-$PYPI_TOKEN}" dist/agentex_sdk-*.whl
13+
publish_client() {
14+
uv publish --check-url https://pypi.org/simple/ --token="${AGENTEX_CLIENT_PYPI_TOKEN:-${PYPI_TOKEN:-}}" dist/agentex_client-*.whl
15+
}
16+
17+
publish_sdk() {
18+
uv publish --check-url https://pypi.org/simple/ --token="${AGENTEX_PYPI_TOKEN:-${PYPI_TOKEN:-}}" dist/agentex_sdk-*.whl
19+
}
20+
21+
package="${PYPI_PACKAGE:-}"
22+
23+
if [ -z "$package" ]; then
24+
tag_name="${GITHUB_REF_NAME:-}"
25+
if [ -z "$tag_name" ] && [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
26+
tag_name="${GITHUB_REF#refs/tags/}"
27+
fi
28+
29+
case "$tag_name" in
30+
agentex-client-v*) package="agentex-client" ;;
31+
agentex-sdk-v*) package="agentex-sdk" ;;
32+
*)
33+
echo "Unable to infer package from tag '$tag_name'. Set PYPI_PACKAGE to one of: all, agentex-client, agentex-sdk." >&2
34+
exit 1
35+
;;
36+
esac
37+
fi
38+
39+
case "$package" in
40+
all)
41+
publish_client
42+
publish_sdk
43+
;;
44+
agentex-client)
45+
publish_client
46+
;;
47+
agentex-sdk)
48+
publish_sdk
49+
;;
50+
*)
51+
echo "Unknown PYPI_PACKAGE '$package'. Expected one of: all, agentex-client, agentex-sdk." >&2
52+
exit 1
53+
;;
54+
esac

0 commit comments

Comments
 (0)