From 2b00a752bcd9f3c53fd5f4da67b35905408e9aa7 Mon Sep 17 00:00:00 2001 From: Tyler Pirtle Date: Mon, 18 May 2026 22:51:13 +0000 Subject: [PATCH 1/2] Add Cloud Build pipeline for tag-triggered AR uploads Builds sdist + wheel via 'uv build' against the tagged commit and publishes both to the colab-cli Python repo in Artifact Registry (us-central1-python.pkg.dev/colab-cli-external/colab-cli). Hatch-vcs derives the version from the tag, so the build unshallows the GitHub checkout to make 'git describe' return the clean tag name. --- cloudbuild.yaml | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 cloudbuild.yaml diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..58dea7f --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,69 @@ +# Cloud Build pipeline triggered on git tag push. +# +# Builds an sdist + wheel for colab-cli using `uv build`, then publishes both +# to the Artifact Registry Python repository at +# us-central1-python.pkg.dev/colab-cli-external/colab-cli/ +# +# The build runs against the tagged commit (TAG_NAME is set by the trigger). +# Version is derived from the git tag by hatch-vcs, so the checkout must have +# tags available (Cloud Build's default GitHub checkout includes them). +# +# Trigger: GitHub push to refs/tags/v* on googlecolab/google-colab-cli (main). +substitutions: + _AR_LOCATION: us-central1 + _AR_REPOSITORY: colab-cli + _AR_PROJECT: colab-cli-external + +steps: + # 1. Ensure hatch-vcs sees the tag. Cloud Build's default GitHub checkout + # is shallow and may omit tag refs; unshallow + force-fetch tags so + # `git describe` returns the clean tag (e.g. v0.4.0 -> 0.4.0) rather + # than a dev-suffixed pseudo-version. + - id: show-version + name: gcr.io/cloud-builders/git + entrypoint: bash + args: + - -c + - | + set -euo pipefail + git fetch --tags --force --unshallow 2>/dev/null || git fetch --tags --force + echo "TAG_NAME=${TAG_NAME}" + echo "git describe: $(git describe --tags --always)" + + # 2. Build sdist + wheel into dist/ using uv. + - id: build + name: ghcr.io/astral-sh/uv:python3.13-bookworm-slim + entrypoint: bash + args: + - -c + - | + set -euo pipefail + uv build --out-dir dist + ls -la dist/ + + # 3. Publish artifacts to Artifact Registry via twine + the + # google-artifactregistry-auth keyring plugin (uses ADC from the + # Cloud Build service account). + - id: publish + name: python:3.13-slim + entrypoint: bash + args: + - -c + - | + set -euo pipefail + pip install --quiet --root-user-action=ignore \ + twine keyrings.google-artifactregistry-auth + twine upload \ + --repository-url "https://${_AR_LOCATION}-python.pkg.dev/${_AR_PROJECT}/${_AR_REPOSITORY}/" \ + --verbose \ + dist/* + +# Surface the built artifacts in the Cloud Build UI / logs. +artifacts: + objects: + location: gs://${PROJECT_ID}_cloudbuild/colab-cli/${TAG_NAME} + paths: + - dist/* + +options: + logging: CLOUD_LOGGING_ONLY From 22a13922942bb39c456904c16d34d5f7c047c8d3 Mon Sep 17 00:00:00 2001 From: Tyler Pirtle Date: Mon, 18 May 2026 23:51:55 +0000 Subject: [PATCH 2/2] Fix Cloud Build pipeline: use git-equipped uv image, trim shell flags The uv:python3.13-bookworm-slim image lacks a git binary, which causes hatch-vcs to fail with 'not a git repository' during 'uv build'. Switch to the non-slim bookworm variant so git is available for the version derivation. Also simplify the shell prologue in each step to 'set -e' (the existing 'set -euo pipefail' was overkill: no pipelines are used, and Cloud Build expands substitutions before bash sees them so '-u' adds no coverage). --- cloudbuild.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 58dea7f..b4fe090 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -25,20 +25,24 @@ steps: args: - -c - | - set -euo pipefail + set -e git fetch --tags --force --unshallow 2>/dev/null || git fetch --tags --force echo "TAG_NAME=${TAG_NAME}" echo "git describe: $(git describe --tags --always)" # 2. Build sdist + wheel into dist/ using uv. + # Use the non-slim bookworm variant: hatch-vcs derives the version + # by shelling out to `git describe`, which requires a git binary + # in the build container. The -slim variant omits git and breaks + # the build with a setuptools-scm "not a git repository" error. - id: build - name: ghcr.io/astral-sh/uv:python3.13-bookworm-slim + name: ghcr.io/astral-sh/uv:python3.13-bookworm entrypoint: bash args: - -c - | - set -euo pipefail - uv build --out-dir dist + set -e + uv build ls -la dist/ # 3. Publish artifacts to Artifact Registry via twine + the @@ -50,7 +54,7 @@ steps: args: - -c - | - set -euo pipefail + set -e pip install --quiet --root-user-action=ignore \ twine keyrings.google-artifactregistry-auth twine upload \