-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
92 lines (82 loc) · 3.36 KB
/
cloudbuild.yaml
File metadata and controls
92 lines (82 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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.
steps:
# 1. Build the source distribution (sdist).
- name: 'python:3.10'
id: 'build-sdist'
entrypoint: 'bash'
args:
- '-c'
- |
if [ -z "$TAG_NAME" ]; then
echo "Error: TAG_NAME is not set. This pipeline is only for tag-based releases."
exit 1
fi
pip install build
python -m build --sdist
# 2. Build the manylinux wheels using cibuildwheel.
# This builds for both x86_64 and ARM64.
# ARM64 is emulated using QEMU on the x86_64 host.
- name: 'python:3.10'
id: 'build-wheels'
entrypoint: 'bash'
args:
- '-c'
- |
# 1. Faster Docker CLI setup: Download static binary for the host architecture
echo "Fetching Docker binary statically (faster than apt-get)..."
curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz" | \
tar xzC /usr/local/bin --strip-components=1 docker/docker
# 2. Register QEMU for ARM emulation
echo "Registering QEMU for ARM emulation..."
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# 3. Setup cibuildwheel
pip install cibuildwheel
echo "Building C++ extensions with editable install (local test - cibuildwheel will do this itself)..."
SKBUILD_CMAKE_ARGS="-DBUILD_TESTING=OFF" pip install -e .
echo "Running cibuildwheel for configured architectures..."
# cibuildwheel will use the configuration from pyproject.toml
cibuildwheel --output-dir dist
volumes:
- name: 'docker-socket'
path: '/var/run/docker.sock'
waitFor: ['build-sdist']
# 3. Upload to internal Artifact Registry (AR) for OSS Exit Gate.
- name: 'python:3.10'
id: 'upload-to-ar'
entrypoint: 'bash'
args:
- '-c'
- |
pip install -U twine keyring keyrings.google-artifactregistry-auth
twine upload --repository-url https://us-python.pkg.dev/oss-exit-gate-prod/${_PROJECT_NAME}--pypi dist/*
waitFor: ['build-wheels']
# 4. Create and upload the manifest to GCS to trigger the Exit Gate publication.
# The presence of this file in the specific GCS bucket triggers the verification and publishing process.
- name: 'gcr.io/cloud-builders/gcloud'
id: 'trigger-exit-gate'
entrypoint: 'bash'
args:
- '-c'
- |
# Use a simple manifest that publishes all artifacts currently in the AR repository.
echo '{"publish_all": true}' > manifest.json
gcloud storage cp manifest.json gs://oss-exit-gate-prod-projects-bucket/${_PROJECT_NAME}/pypi/manifests/release-${TAG_NAME}.json
waitFor: ['upload-to-ar']
options:
logging: CLOUD_LOGGING_ONLY
# Ensure we have enough resources for building C++ extensions.
machineType: 'E2_HIGHCPU_8'
substitutions:
_PROJECT_NAME: 'ml-flashpoint'