From 8ac4edd548995018181c58b2c64c319ce6f08ed5 Mon Sep 17 00:00:00 2001 From: sumansaurabh Date: Sat, 10 Jan 2026 07:52:38 +0530 Subject: [PATCH] feat: add NPM publish workflow and update package name; implement vertex server details resolution --- .github/workflows/npm-publish.yml | 56 +++++++++++++++++++ package.json | 2 +- .../core/src/core/loggingContentGenerator.ts | 5 ++ packages/core/src/utils/baseUrlUtils.ts | 14 +++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/npm-publish.yml create mode 100644 packages/core/src/utils/baseUrlUtils.ts diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000000..e0a7de0fb1b --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,56 @@ +name: Publish CLI to NPM + +on: + release: + types: [published] + workflow_dispatch: + inputs: + npm_tag: + description: 'NPM tag to publish under (e.g., latest, beta, alpha)' + required: false + default: 'latest' + type: string + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: gateway + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build and bundle + run: | + npm run build + npm run bundle + + - name: Remove private flag from package.json + run: | + node -e " + const fs = require('fs'); + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); + delete pkg.private; + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); + " + + - name: Publish to NPM + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + NPM_TAG="${{ github.event.inputs.npm_tag || 'latest' }}" + npm publish --tag "$NPM_TAG" --access public diff --git a/package.json b/package.json index f5c10deaf55..b9eaad5b560 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@google/gemini-cli", + "name": "@anek-codes/gemini-cli", "version": "0.25.0-nightly.20260107.59a18e710", "engines": { "node": ">=20.0.0" diff --git a/packages/core/src/core/loggingContentGenerator.ts b/packages/core/src/core/loggingContentGenerator.ts index e5598463664..b190110f91d 100644 --- a/packages/core/src/core/loggingContentGenerator.ts +++ b/packages/core/src/core/loggingContentGenerator.ts @@ -33,6 +33,7 @@ import { CodeAssistServer } from '../code_assist/server.js'; import { toContents } from '../code_assist/converter.js'; import { isStructuredError } from '../utils/quotaErrorDetection.js'; import { runInDevTraceSpan, type SpanMetadata } from '../telemetry/trace.js'; +import { resolveVertexServerDetails } from '../utils/baseUrlUtils.js'; interface StructuredError { status: number; @@ -94,6 +95,10 @@ export class LoggingContentGenerator implements ContentGenerator { // Case 2: Using an API key for Vertex AI. if (genConfig?.vertexai) { + const vertexCustomServerDetails = resolveVertexServerDetails(); + if (vertexCustomServerDetails) { + return vertexCustomServerDetails; + } const location = process.env['GOOGLE_CLOUD_LOCATION']; if (location) { return { address: `${location}-aiplatform.googleapis.com`, port: 443 }; diff --git a/packages/core/src/utils/baseUrlUtils.ts b/packages/core/src/utils/baseUrlUtils.ts new file mode 100644 index 00000000000..bfda52bf58b --- /dev/null +++ b/packages/core/src/utils/baseUrlUtils.ts @@ -0,0 +1,14 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import type { ServerDetails } from '../telemetry/types.js'; + +export function resolveVertexServerDetails(): ServerDetails | undefined { + if (process.env['GEMINI_CLI_VERTEX_BASE_URL'] === undefined) { + return undefined; + } + return { address: process.env['GEMINI_CLI_VERTEX_BASE_URL'], port: 443 }; +}