|
| 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' |
0 commit comments