mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-13 21:07:00 -07:00
feat: Unify CLI bundling and publishing process
This commit unifies the bundling and publishing process for the CLI package across both npmjs.org and GitHub Packages. - The script has been updated to only rename packages for the GitHub registry, removing the bundle copying and package.json modification logic. - The has been modified to remove the flag from the CLI publish step, ensuring the root package (which includes the bundled executable) is published. This ensures a consistent, bundled artifact is published to both registries.
This commit is contained in:
@@ -196,7 +196,6 @@ runs:
|
||||
run: |
|
||||
npm publish \
|
||||
--dry-run="${{ inputs.dry-run }}" \
|
||||
--workspace="${{ inputs.cli-package-name }}" \
|
||||
--no-tag
|
||||
npm dist-tag rm ${{ inputs.cli-package-name }} false --silent
|
||||
|
||||
|
||||
@@ -11,48 +11,21 @@ const rootDir = process.cwd();
|
||||
|
||||
function updatePackageJson(packagePath, updateFn) {
|
||||
const packageJsonPath = path.resolve(rootDir, packagePath);
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
console.error(`Error: package.json not found at ${packageJsonPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
||||
updateFn(packageJson);
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||
console.log(`Updated ${packagePath}`);
|
||||
}
|
||||
|
||||
// Copy bundle directory into packages/cli
|
||||
const sourceBundleDir = path.resolve(rootDir, 'bundle');
|
||||
const destBundleDir = path.resolve(rootDir, 'packages/cli/bundle');
|
||||
console.log('Preparing packages for GitHub release...');
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Overwrite the .npmrc in the core package to point to the GitHub registry.
|
||||
const coreNpmrcPath = path.resolve(rootDir, 'packages/core/.npmrc');
|
||||
fs.writeFileSync(
|
||||
coreNpmrcPath,
|
||||
'@google-gemini:registry=https://npm.pkg.github.com/',
|
||||
);
|
||||
console.log('Wrote .npmrc for @google-gemini scope to packages/core/');
|
||||
|
||||
// Update @google/gemini-cli
|
||||
updatePackageJson('packages/cli/package.json', (pkg) => {
|
||||
// Update root package.json
|
||||
updatePackageJson('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-a2a-server
|
||||
|
||||
Reference in New Issue
Block a user