|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
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. |
5 | 6 |
|
6 | 7 | set -eux |
7 | 8 |
|
8 | 9 | rm -rf dist |
9 | 10 | # --wheel: the heavy's cross-dir force-include can't build via sdist. |
10 | 11 | uv build --all-packages --wheel |
11 | 12 |
|
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