ci: use correct scope and registry for publishing

This commit is contained in:
mkorwel
2026-04-24 21:29:38 +00:00
parent f660d37f24
commit c7fce4d6c9
2 changed files with 51 additions and 36 deletions
+7 -2
View File
@@ -32,6 +32,10 @@ jobs:
- name: 'Build project'
run: 'npm run build'
- name: 'Prepare Packages with Scope'
run: 'node scripts/prepare-package.js --scope=@google-gemini'
shell: 'bash'
- name: 'Set version with SHA'
run: |
npm version 0.0.0-${{ github.sha }} --no-git-tag-version --workspaces
@@ -39,14 +43,15 @@ jobs:
- name: 'Configure npm for GitHub Packages'
run: |
rm -f .npmrc
echo "//npm.pkg.github.com/:_authToken=\${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
echo "@google-gemini:registry=https://npm.pkg.github.com" >> ~/.npmrc
shell: 'bash'
- name: 'Publish Packages'
run: |
npm publish --workspace @google/gemini-cli-core
npm publish --workspace @google/gemini-cli
npm publish --workspace @google-gemini/gemini-cli-core --registry=https://npm.pkg.github.com
npm publish --workspace @google-gemini/gemini-cli --registry=https://npm.pkg.github.com
shell: 'bash'
test_ui_messages:
+44 -34
View File
@@ -6,46 +6,56 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
// ES module equivalent of __dirname
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootDir = process.cwd();
const rootDir = path.resolve(__dirname, '..');
function copyFiles(packageName, filesToCopy) {
const packageDir = path.resolve(rootDir, 'packages', packageName);
if (!fs.existsSync(packageDir)) {
console.error(`Error: Package directory not found at ${packageDir}`);
process.exit(1);
}
console.log(`Preparing package: ${packageName}`);
for (const [source, dest] of Object.entries(filesToCopy)) {
const sourcePath = path.resolve(rootDir, source);
const destPath = path.resolve(packageDir, dest);
try {
fs.copyFileSync(sourcePath, destPath);
console.log(`Copied ${source} to packages/${packageName}/`);
} catch (err) {
console.error(`Error copying ${source}:`, err);
process.exit(1);
}
function getArg(name) {
const arg = process.argv.find((arg) => arg.startsWith(name));
if (!arg) {
return null;
}
return arg.split('=')[1];
}
// Prepare 'core' package
copyFiles('core', {
'README.md': 'README.md',
LICENSE: 'LICENSE',
'.npmrc': '.npmrc',
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}`);
}
const scope = getArg('--scope');
if (!scope) {
console.error('Error: --scope argument is required.');
process.exit(1);
}
console.log(`Preparing packages with scope: ${scope}...`);
// Update root package.json
updatePackageJson('package.json', (pkg) => {
pkg.name = `${scope}/gemini-cli`;
});
// Prepare 'cli' package
copyFiles('cli', {
'README.md': 'README.md',
LICENSE: 'LICENSE',
// Update @google/gemini-cli-core
updatePackageJson('packages/core/package.json', (pkg) => {
pkg.name = `${scope}/gemini-cli-core`;
});
console.log('Successfully prepared all packages.');
// Update @google/gemini-cli
updatePackageJson('packages/cli/package.json', (pkg) => {
pkg.name = `${scope}/gemini-cli`;
// Update dependency to point to the new scoped core package
if (pkg.dependencies && pkg.dependencies['@google/gemini-cli-core']) {
pkg.dependencies[`${scope}/gemini-cli-core`] =
`npm:${scope}/gemini-cli-core@^0.0.0`;
delete pkg.dependencies['@google/gemini-cli-core'];
}
});
console.log('Successfully prepared packages.');