diff --git a/agent_sdks/python/a2ui_core/pyproject.toml b/agent_sdks/python/a2ui_core/pyproject.toml index 1537e5ac23..dd335fe4d8 100644 --- a/agent_sdks/python/a2ui_core/pyproject.toml +++ b/agent_sdks/python/a2ui_core/pyproject.toml @@ -14,7 +14,7 @@ [project] name = "a2ui-core" -version = "0.1.0" +dynamic = ["version"] description = "A2UI Python SDK - Core Library" readme = "README.md" requires-python = ">=3.14" @@ -35,6 +35,9 @@ dev = [ requires = ["hatchling"] build-backend = "hatchling.build" +[tool.hatch.version] +path = "src/a2ui/core/version.py" + [tool.hatch.build.targets.wheel] packages = ["src/a2ui"] diff --git a/agent_sdks/python/a2ui_core/src/a2ui/core/__init__.py b/agent_sdks/python/a2ui_core/src/a2ui/core/__init__.py new file mode 100644 index 0000000000..d0d3aac386 --- /dev/null +++ b/agent_sdks/python/a2ui_core/src/a2ui/core/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from a2ui.core.version import __version__ as __version__ diff --git a/agent_sdks/python/a2ui_core/src/a2ui/core/version.py b/agent_sdks/python/a2ui_core/src/a2ui/core/version.py new file mode 100644 index 0000000000..fe518497ec --- /dev/null +++ b/agent_sdks/python/a2ui_core/src/a2ui/core/version.py @@ -0,0 +1,20 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# File-based dynamic versioning +# - The next release version +# - Version format: major.minor.patch +# - Update the version in this file before releasing +# +__version__ = "0.0.3" diff --git a/agent_sdks/python/a2ui_core/uv.lock b/agent_sdks/python/a2ui_core/uv.lock index daa296c2bf..dec8c518e3 100644 --- a/agent_sdks/python/a2ui_core/uv.lock +++ b/agent_sdks/python/a2ui_core/uv.lock @@ -4,7 +4,6 @@ requires-python = ">=3.14" [[package]] name = "a2ui-core" -version = "0.1.0" source = { editable = "." } dependencies = [ { name = "jsonschema" }, diff --git a/agent_sdks/python/a2ui_agent/release.sh b/agent_sdks/python/release.sh similarity index 60% rename from agent_sdks/python/a2ui_agent/release.sh rename to agent_sdks/python/release.sh index 8482ebcd84..66fa4adadf 100755 --- a/agent_sdks/python/a2ui_agent/release.sh +++ b/agent_sdks/python/release.sh @@ -13,11 +13,35 @@ # See the License for the specific language governing permissions and # limitations under the License. - set -e # Exit on error -#set -x # Echo commands -PACKAGE_NAME="a2ui-agent-sdk" +# Check arguments +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +TARGET_DIR="${SCRIPT_DIR}/${1}" + +if [ ! -d "$TARGET_DIR" ]; then + echo "Error: Directory '$TARGET_DIR' does not exist." + exit 1 +fi + +cd "$TARGET_DIR" + +# Read package name from pyproject.toml +if [ ! -f "pyproject.toml" ]; then + echo "Error: pyproject.toml not found in '$TARGET_DIR'." + exit 1 +fi + +PACKAGE_NAME=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])") +VERSION=$(uv run --with hatch hatch version) + +echo "Releasing package: $PACKAGE_NAME ($VERSION) from folder: $TARGET_DIR" + REPOSITORY="a2ui--pypi" PROJECT="oss-exit-gate-prod" LOCATION="us" @@ -36,29 +60,27 @@ echo "--- Uploading the package ---" twine --version twine check dist/* -version=$(uv run python -c "import a2ui; print(a2ui.__version__)") - # Authenticate with Google Cloud if ! gcloud auth application-default print-access-token --quiet > /dev/null; then gcloud auth application-default login fi # Check if the version already exists in the staging repository -if gcloud artifacts versions describe "$version" --package=$PACKAGE_NAME --repository=$REPOSITORY --location=$LOCATION --project=$PROJECT > /dev/null 2>&1; then - echo "Version $version already exists in Artifact Registry. Skip the release." - echo "Hint: If you intended to release a new version, please update 'src/a2ui/version.py'." +if gcloud artifacts versions describe "$VERSION" --package="$PACKAGE_NAME" --repository="$REPOSITORY" --location="$LOCATION" --project="$PROJECT" > /dev/null 2>&1; then + echo "Version $VERSION of $PACKAGE_NAME already exists in Artifact Registry. Skip the release." + echo "Hint: If you intended to release a new version, please update its version in pyproject.toml or version.py." exit 0 fi -twine upload --repository-url $REPOSITORY_URL dist/* -echo "Version $version uploaded to Artifact Registry." +twine upload --repository-url "$REPOSITORY_URL" dist/* +echo "Version $VERSION of $PACKAGE_NAME uploaded to Artifact Registry." echo "--- Creating manifest.json ---" MANIFEST_FILE="manifest.json" echo '{ "publish_all": true }' > $MANIFEST_FILE echo "--- Uploading manifest to GCS to trigger OSS Exit Gate ---" -MANIFEST_NAME="manifest-${version}-$(date +%Y%m%d%H%M%S).json" +MANIFEST_NAME="manifest-${VERSION}-$(date +%Y%m%d%H%M%S).json" gcloud storage cp $MANIFEST_FILE "${GCS_URI}/${MANIFEST_NAME}" rm -rf $MANIFEST_FILE