From 0d83a9b4b79d24cc92eee9045009d73ea940c74a Mon Sep 17 00:00:00 2001 From: mkorwel Date: Fri, 24 Apr 2026 22:54:55 +0000 Subject: [PATCH] ci: publish bundled CLI and update Windows job --- .github/workflows/ci-bundling-trial.yml | 10 +++-- scripts/prepare-bundle-package.js | 55 +++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 scripts/prepare-bundle-package.js diff --git a/.github/workflows/ci-bundling-trial.yml b/.github/workflows/ci-bundling-trial.yml index 7c01baac89..d04e6bc4ba 100644 --- a/.github/workflows/ci-bundling-trial.yml +++ b/.github/workflows/ci-bundling-trial.yml @@ -32,13 +32,17 @@ jobs: - name: 'Build project' run: 'npm run build' + - name: 'Bundle' + run: 'npm run bundle' + shell: 'bash' + - name: 'Set version with SHA' run: | npm version 0.0.0-${{ github.sha }} --no-git-tag-version --workspaces shell: 'bash' - - name: 'Prepare Packages with Scope' - run: 'node scripts/prepare-package.js --scope=@google-gemini' + - name: 'Prepare Packages for Bundled Release' + run: 'node scripts/prepare-bundle-package.js' shell: 'bash' - name: 'Configure npm for GitHub Packages' @@ -433,7 +437,7 @@ jobs: shell: 'pwsh' - name: 'Install dependencies' - run: 'npm install @google-gemini/gemini-cli@0.0.0-${{ github.sha }} @google-gemini/gemini-cli-core@0.0.0-${{ github.sha }} vitest node-pty --no-save' + run: 'npm install @google-gemini/gemini-cli@0.0.0-${{ github.sha }} vitest node-pty --no-save' shell: 'pwsh' - name: 'Run Integration Tests' diff --git a/scripts/prepare-bundle-package.js b/scripts/prepare-bundle-package.js new file mode 100644 index 0000000000..2b20f59904 --- /dev/null +++ b/scripts/prepare-bundle-package.js @@ -0,0 +1,55 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import fs from 'node:fs'; +import path from 'node:path'; + +const rootDir = process.cwd(); + +function updatePackageJson(packagePath, updateFn) { + const packageJsonPath = path.resolve(rootDir, packagePath); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + updateFn(packageJson); + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); +} + +// Copy bundle directory into packages/cli +const sourceBundleDir = path.resolve(rootDir, 'bundle'); +const destBundleDir = path.resolve(rootDir, 'packages/cli/bundle'); + +if (fs.existsSync(sourceBundleDir)) { + fs.rmSync(destBundleDir, { recursive: true, force: true }); + fs.cpSync(sourceBundleDir, destBundleDir, { recursive: true }); + console.log('Copied bundle/ directory to packages/cli/'); +} else { + console.error( + 'Error: bundle/ directory not found at project root. Please run `npm run bundle` first.', + ); + process.exit(1); +} + +// Update @google/gemini-cli to be a bundled package +updatePackageJson('packages/cli/package.json', (pkg) => { + pkg.name = '@google-gemini/gemini-cli'; + pkg.files = ['bundle/']; + pkg.bin = { + gemini: 'bundle/gemini.js', + }; + + // Remove fields that are not relevant to the bundled package. + delete pkg.dependencies; + delete pkg.devDependencies; + delete pkg.scripts; + delete pkg.main; + delete pkg.config; // Deletes the sandboxImageUri +}); + +// Update @google/gemini-cli-core name for GitHub Packages +updatePackageJson('packages/core/package.json', (pkg) => { + pkg.name = '@google-gemini/gemini-cli-core'; +}); + +console.log('Successfully prepared packages for GitHub release.');