Skip to content

Commit 85d780d

Browse files
authored
ci: add GCB configuration yaml for pypi releases (#35)
Google's OSS Exit Gate for publishing to public registries requires using certain trusted builders, one of which is GCB. This configures a GCB pipeline that is specifically for publishing to PyPi from release tags.
1 parent 150d52c commit 85d780d

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

cloudbuild.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
steps:
16+
# 1. Build the distribution (sdist and wheel).
17+
# This uses scikit-build-core as defined in pyproject.toml to compile C++ extensions.
18+
# We set BUILD_TESTING=OFF to ignore tests during the artifact build.
19+
- name: 'python:3.10'
20+
id: 'build'
21+
entrypoint: 'bash'
22+
args:
23+
- '-c'
24+
- |
25+
if [ -z "$TAG_NAME" ]; then
26+
echo "Error: TAG_NAME is not set. This pipeline is only for tag-based releases."
27+
exit 1
28+
fi
29+
pip install build
30+
31+
echo "Building C++ extensions with editable install..."
32+
# Note: pip install -e . will also respect the build-system requirements
33+
SKBUILD_CMAKE_ARGS="-DBUILD_TESTING=OFF" pip install -e .
34+
35+
echo "Building sdist and wheel..."
36+
SKBUILD_CMAKE_ARGS="-DBUILD_TESTING=OFF" python -m build
37+
38+
# 2. Upload to internal Artifact Registry (AR) for OSS Exit Gate.
39+
# OSS Exit Gate fetches artifacts from this repository.
40+
- name: 'python:3.10'
41+
id: 'upload-to-ar'
42+
entrypoint: 'bash'
43+
args:
44+
- '-c'
45+
- |
46+
pip install -U twine keyring keyrings.google-artifactregistry-auth
47+
twine upload --repository-url https://us-python.pkg.dev/oss-exit-gate-prod/${_PROJECT_NAME}--pypi dist/*
48+
waitFor: ['build']
49+
50+
# 3. Create and upload the manifest to GCS to trigger the Exit Gate publication.
51+
# The presence of this file in the specific GCS bucket triggers the verification and publishing process.
52+
- name: 'gcr.io/cloud-builders/gcloud'
53+
id: 'trigger-exit-gate'
54+
entrypoint: 'bash'
55+
args:
56+
- '-c'
57+
- |
58+
# Use a simple manifest that publishes all artifacts currently in the AR repository.
59+
echo '{"publish_all": true}' > manifest.json
60+
gcloud storage cp manifest.json gs://oss-exit-gate-prod-projects-bucket/${_PROJECT_NAME}/pypi/manifests/release-${TAG_NAME}.json
61+
waitFor: ['upload-to-ar']
62+
63+
options:
64+
logging: CLOUD_LOGGING_ONLY
65+
# Ensure we have enough resources for building C++ extensions.
66+
machineType: 'E2_HIGHCPU_8'
67+
68+
substitutions:
69+
_PROJECT_NAME: 'ml-flashpoint'

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ dev = [
9999
requires = [
100100
"pybind11==3.0.1",
101101
"scikit-build-core==0.11.6",
102+
"cmake==3.31.10",
103+
"ninja==1.11.1.3",
102104
]
103105

104106
# The Python object that `pip` will call to execute the build.

0 commit comments

Comments
 (0)