Repository navigation
chore: add Kokoro release config and script for OSS Exit Gate #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Format: //devtools/kokoro/config/proto/build.proto | ||
|
|
||
| build_file: "github/google-ads-ruby/.kokoro/release.sh" | ||
|
|
||
| # Default to DRY_RUN=true for safety; can be overridden via API or UI | ||
| env_vars: { | ||
| key: "DRY_RUN" | ||
| value: "true" | ||
| } | ||
|
|
||
| container_properties { | ||
| docker_image: "us-central1-docker.pkg.dev/kokoro-container-bakery/kokoro/ubuntu/ubuntu2204/full:current" | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,93 @@ | ||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||
| set +x | ||||||||||||||||||
|
|
||||||||||||||||||
| # Default to dry-run for safety unless DRY_RUN=false is explicitly passed. | ||||||||||||||||||
| DRY_RUN="${DRY_RUN:-true}" | ||||||||||||||||||
| if [[ "${DRY_RUN}" != "true" && "${DRY_RUN}" != "false" ]]; then | ||||||||||||||||||
| echo "ERROR: DRY_RUN must be 'true' or 'false' (got '${DRY_RUN}')." >&2 | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||||||||||||||||||
| cd "${REPO_DIR}" | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "=== Building and Releasing from: ${REPO_DIR} (DRY_RUN=${DRY_RUN}) ===" | ||||||||||||||||||
|
|
||||||||||||||||||
| # ----------------------------------------------------------------------------- | ||||||||||||||||||
| # 1. Build RubyGem Artifact | ||||||||||||||||||
| # ----------------------------------------------------------------------------- | ||||||||||||||||||
| rm -f *.gem | ||||||||||||||||||
| if [[ -f "third_party/rspec/caller_filter.rb" ]]; then | ||||||||||||||||||
| cp third_party/rspec/caller_filter.rb lib/google/ads/google_ads/deprecation.rb | ||||||||||||||||||
| fi | ||||||||||||||||||
| gem build google-ads-googleads.gemspec | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggest either calling the Rake tasks ( |
||||||||||||||||||
|
|
||||||||||||||||||
| GEM_FILE="$(ls google-ads-googleads-*.gem | head -n 1)" | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
(and drop lines 31-33). This also guarantees the manifest version matches what the gemspec stamped into the artifact rather than whatever |
||||||||||||||||||
| if [[ -z "${GEM_FILE}" ]]; then | ||||||||||||||||||
| echo "ERROR: Built .gem file not found." >&2 | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
| PACKAGE_NAME="google-ads-googleads" | ||||||||||||||||||
| PACKAGE_VERSION="${GEM_FILE#google-ads-googleads-}" | ||||||||||||||||||
| PACKAGE_VERSION="${PACKAGE_VERSION%.gem}" | ||||||||||||||||||
| echo "Built ${GEM_FILE} (package=${PACKAGE_NAME}, version=${PACKAGE_VERSION})" | ||||||||||||||||||
|
|
||||||||||||||||||
| # ----------------------------------------------------------------------------- | ||||||||||||||||||
| # 2. Stage to OSS Exit Gate Ruby Artifact Registry | ||||||||||||||||||
| # ----------------------------------------------------------------------------- | ||||||||||||||||||
| EXIT_GATE_PROJECT="oss-exit-gate-prod" | ||||||||||||||||||
| EXIT_GATE_LOCATION="us" | ||||||||||||||||||
| EXIT_GATE_REPOSITORY="google-ads-ruby--rubygems" | ||||||||||||||||||
|
|
||||||||||||||||||
| if gcloud artifacts packages describe "${PACKAGE_NAME}" \ | ||||||||||||||||||
| --project="${EXIT_GATE_PROJECT}" \ | ||||||||||||||||||
| --location="${EXIT_GATE_LOCATION}" \ | ||||||||||||||||||
| --repository="${EXIT_GATE_REPOSITORY}" &>/dev/null; then | ||||||||||||||||||
| echo "=== Deleting existing package '${PACKAGE_NAME}' from Exit Gate staging repository ===" | ||||||||||||||||||
| gcloud artifacts packages delete "${PACKAGE_NAME}" \ | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This deletes every staged version of if gcloud artifacts versions describe "${PACKAGE_VERSION}" --package="${PACKAGE_NAME}" ... &>/dev/null; then
gcloud artifacts versions delete "${PACKAGE_VERSION}" --package="${PACKAGE_NAME}" ... --quiet
fiand keep the manifest at |
||||||||||||||||||
| --project="${EXIT_GATE_PROJECT}" \ | ||||||||||||||||||
| --location="${EXIT_GATE_LOCATION}" \ | ||||||||||||||||||
| --repository="${EXIT_GATE_REPOSITORY}" \ | ||||||||||||||||||
| --quiet | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| echo "=== Uploading ${GEM_FILE} to Exit Gate Ruby Artifact Registry ===" | ||||||||||||||||||
| set +x | ||||||||||||||||||
| ACCESS_TOKEN="$(gcloud auth print-access-token)" | ||||||||||||||||||
| curl -fsSL -X POST \ | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things here:
GEM_HOST_API_KEY="Bearer $(gcloud auth print-access-token)" \
gem push "${GEM_FILE}" --host "https://us-ruby.pkg.dev/${EXIT_GATE_PROJECT}/${EXIT_GATE_REPOSITORY}"(see go/oss-exit-gate-release-rubygems "Update Your Build Script to Publish to AR"). That also removes the hand-built
|
||||||||||||||||||
| -H "Authorization: Bearer ${ACCESS_TOKEN}" \ | ||||||||||||||||||
| -H "Content-Type: application/octet-stream" \ | ||||||||||||||||||
| --data-binary @"${GEM_FILE}" \ | ||||||||||||||||||
| "https://us-ruby.pkg.dev/${EXIT_GATE_PROJECT}/${EXIT_GATE_REPOSITORY}/api/v1/gems" | ||||||||||||||||||
| unset ACCESS_TOKEN | ||||||||||||||||||
|
|
||||||||||||||||||
| # ----------------------------------------------------------------------------- | ||||||||||||||||||
| # 3. Trigger Exit Gate Release via GCS Manifest | ||||||||||||||||||
| # ----------------------------------------------------------------------------- | ||||||||||||||||||
| if [[ "${DRY_RUN}" == "true" ]]; then | ||||||||||||||||||
| echo "=== DRY_RUN is enabled. Skipping manifest upload to Exit Gate. ===" | ||||||||||||||||||
| exit 0 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| cat <<EOF > manifest.json | ||||||||||||||||||
| { | ||||||||||||||||||
| "publish_all": false, | ||||||||||||||||||
| "publishing_groups": [ | ||||||||||||||||||
| { | ||||||||||||||||||
| "packages": [ | ||||||||||||||||||
| { | ||||||||||||||||||
| "name": "${PACKAGE_NAME}", | ||||||||||||||||||
| "version": "${PACKAGE_VERSION}" | ||||||||||||||||||
| } | ||||||||||||||||||
| ] | ||||||||||||||||||
| } | ||||||||||||||||||
| ] | ||||||||||||||||||
| } | ||||||||||||||||||
| EOF | ||||||||||||||||||
|
|
||||||||||||||||||
| EXIT_GATE_BUCKET="gs://oss-exit-gate-prod-projects-bucket/google-ads-ruby/rubygems/manifests" | ||||||||||||||||||
| MANIFEST_NAME="manifest-$(date +%Y%m%d%H%M%S).json" | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: include the version in the manifest object name ( |
||||||||||||||||||
|
|
||||||||||||||||||
| echo "=== Uploading manifest to ${EXIT_GATE_BUCKET}/${MANIFEST_NAME} ===" | ||||||||||||||||||
| gcloud storage cp manifest.json "${EXIT_GATE_BUCKET}/${MANIFEST_NAME}" | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider retaining the release inputs as Kokoro artifacts so a published gem can be matched back to the exact build that produced it:
Also worth an explicit
timeout_minsso a hung upload fails fast rather than holding a pool slot.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this PR, we are not ready to do this migration.
Pls reach out to anash@ to discuss the specifics.