Files
gemini-cli/scripts/prepare-github-release.js
T
mkorwel 9856a67b4c fix(ci): Create .npmrc file for GitHub Packages publishing
Updates the 'prepare-github-release.js' script to create an '.npmrc' file in the root directory.

This ensures that the 'npm publish' command is properly authenticated with the GitHub Packages registry, preventing the 'ENEEDAUTH' error during the publish step.
2025-10-22 00:34:01 -07:00

47 lines
1.4 KiB
JavaScript

/**
* @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);
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}`);
}
console.log('Preparing packages for GitHub release...');
// Update root package.json
updatePackageJson('package.json', (pkg) => {
pkg.name = '@google-gemini/gemini-cli';
});
// Update @google/gemini-cli-a2a-server
updatePackageJson('packages/a2a-server/package.json', (pkg) => {
pkg.name = '@google-gemini/gemini-cli-a2a-server';
});
// Update @google/gemini-cli-core
updatePackageJson('packages/core/package.json', (pkg) => {
pkg.name = '@google-gemini/gemini-cli-core';
});
// Create .npmrc for publishing to GitHub Packages
const npmrcContent = `@google-gemini:registry=https://npm.pkg.github.com/`;
fs.writeFileSync(path.resolve(rootDir, '.npmrc'), npmrcContent);
console.log('Created .npmrc for @google-gemini scope.');
console.log('Successfully prepared packages for GitHub release.');