Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .kokoro/release.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Format: //devtools/kokoro/config/proto/build.proto

build_file: "github/data-manager-node/.kokoro/release.sh"

# Default to DRY_RUN=true for safety; can be overridden via Stubby/Kokoro API
env_vars: {
key: "DRY_RUN"
value: "true"
}

container_properties {
docker_image: "us-central1-docker.pkg.dev/kokoro-container-bakery/kokoro/ubuntu/ubuntu2204/full:current"
}
108 changes: 108 additions & 0 deletions .kokoro/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash
set -euo pipefail

# -----------------------------------------------------------------------------
# 1. Workspace & Directory Resolution
# -----------------------------------------------------------------------------
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_DIR}"

echo "=== Building and Releasing from: ${REPO_DIR} ==="

# -----------------------------------------------------------------------------
# 2. Environment & Tooling Setup
# -----------------------------------------------------------------------------
echo "=== Environment Info ==="
echo "Node version: $(node -v)"
echo "NPM version: $(npm -v)"

# -----------------------------------------------------------------------------
# 3. Clean and Build Distribution Packages
# -----------------------------------------------------------------------------
echo "=== Installing dependencies ==="
npm ci

echo "=== Building packages ==="
npm run build

echo "=== Running tests ==="
npm test

# -----------------------------------------------------------------------------
# 4. Upload to Internal Exit Gate Artifact Registry
# -----------------------------------------------------------------------------
cd "${REPO_DIR}/util"

EXIT_GATE_PROJECT="oss-exit-gate-prod"
EXIT_GATE_LOCATION="us"
EXIT_GATE_REPOSITORY="measurement-devrel--npm"
PACKAGE_NAME="@google-ads/data-manager-util"

# Delete existing package from the Exit Gate staging repository if present.
# This prevents upload failures on retries or re-releases of the same version.
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}" \
--project="${EXIT_GATE_PROJECT}" \
--location="${EXIT_GATE_LOCATION}" \
--repository="${EXIT_GATE_REPOSITORY}" \
--quiet
else
echo "=== Skipping deletion. Package '${PACKAGE_NAME}' not found in staging repository. 🙂 ==="
fi

# Configure .npmrc for Artifact Registry according to go/oss-exit-gate-release-npm
cat <<EOF > .npmrc
@google-ads:registry=https://${EXIT_GATE_LOCATION}-npm.pkg.dev/${EXIT_GATE_PROJECT}/${EXIT_GATE_REPOSITORY}/
//${EXIT_GATE_LOCATION}-npm.pkg.dev/${EXIT_GATE_PROJECT}/${EXIT_GATE_REPOSITORY}/:always-auth=true
EOF
# Clean up .npmrc and manifest.json on exit. google-artifactregistry-auth writes
# a live GCP OAuth bearer token into .npmrc, so removing it prevents credential
# leakage into Kokoro logs/artifacts and keeps the local workspace clean.
trap 'rm -f .npmrc manifest.json 2>/dev/null || true' EXIT

# Authenticate with Artifact Registry
npx google-artifactregistry-auth

echo "=== Publishing package to Exit Gate staging repository ==="
npm publish

# -----------------------------------------------------------------------------
# 5. Trigger Exit Gate Release via GCS Manifest
# -----------------------------------------------------------------------------
# If DRY_RUN is set to "true", stop here so you can verify AR staging
# without publishing to public npm.
if [[ "${DRY_RUN:-false}" == "true" ]]; then
echo "=== DRY_RUN is enabled. Skipping manifest upload to Exit Gate. ==="
echo "Artifacts are staged in Artifact Registry."
exit 0
fi

echo "=== Creating targeted release manifest for ${PACKAGE_NAME} ==="
cat <<EOF > manifest.json
{
"publish_all": false,
"publishing_groups": [
{
"packages": [
{
"name": "${PACKAGE_NAME}"
}
]
}
]
}
EOF

EXIT_GATE_BUCKET="gs://oss-exit-gate-prod-projects-bucket/measurement-devrel/npm/manifests"
MANIFEST_NAME="manifest-$(date +%Y%m%d%H%M%S).json"

echo "=== Uploading manifest to ${EXIT_GATE_BUCKET}/${MANIFEST_NAME} ==="
gcloud storage cp manifest.json "${EXIT_GATE_BUCKET}/${MANIFEST_NAME}"

echo "========================================================================="
echo "Release successfully triggered! Exit Gate will now verify BCID and publish to npm."
echo "========================================================================="
180 changes: 178 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"gts": "^6.0.2",
"mocha": "^12.0.1",
"typescript": "^5.6.3",
"@types/node": "^22.7.5"
"@types/node": "^22.7.5",
"google-artifactregistry-auth": "^3.5.0"
}
}
2 changes: 1 addition & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@google-ads/datamanager": "^1.0.0",
"@google-ads/data-manager-util": "^0.4.0",
"@google-ads/data-manager-util": "^0.4.0-rc1",
"csv-parser": "^3.0.0",
"yargs": "^17.7.2"
},
Expand Down
5 changes: 4 additions & 1 deletion util/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "@google-ads/data-manager-util",
"version": "0.4.0",
"version": "0.4.0-rc1",
"description": "A utility library for the Data Manager API for Node.js.",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"license": "Apache-2.0",
"author": "Google LLC",
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=22"
},
Expand Down
Loading