ci: publish bundled CLI and update Windows job

This commit is contained in:
mkorwel
2026-04-24 22:54:55 +00:00
parent c09dc461f9
commit 0d83a9b4b7
2 changed files with 62 additions and 3 deletions
+55
View File
@@ -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.');