fix version release for Dockerfile build (#1080)

This commit is contained in:
Zach Sais 2025-06-16 01:13:39 -05:00 committed by GitHub
parent 40fbb61a1b
commit cc7459e403
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 4 deletions

View File

@ -1,7 +1,9 @@
FROM docker.io/library/node:20-slim FROM docker.io/library/node:20-slim
ARG SANDBOX_NAME="gemini-cli-sandbox" ARG SANDBOX_NAME="gemini-cli-sandbox"
ARG CLI_VERSION_ARG
ENV SANDBOX="$SANDBOX_NAME" ENV SANDBOX="$SANDBOX_NAME"
ENV CLI_VERSION=$CLI_VERSION_ARG
# install minimal set of packages, then clean up # install minimal set of packages, then clean up
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \

View File

@ -5,9 +5,14 @@
*/ */
import esbuild from 'esbuild'; import esbuild from 'esbuild';
import { readFileSync } from 'fs'; import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'module';
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8')); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const require = createRequire(import.meta.url);
const pkg = require(path.resolve(__dirname, 'package.json'));
esbuild esbuild
.build({ .build({

View File

@ -23,6 +23,7 @@ import {
import { Settings } from './settings.js'; import { Settings } from './settings.js';
import { getEffectiveModel } from '../utils/modelCheck.js'; import { getEffectiveModel } from '../utils/modelCheck.js';
import { Extension } from './extension.js'; import { Extension } from './extension.js';
import { getCliVersion } from '../utils/version.js';
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv';
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
@ -122,7 +123,8 @@ async function parseArguments(): Promise<CliArgs> {
description: 'Enables checkpointing of file edits', description: 'Enables checkpointing of file edits',
default: false, default: false,
}) })
.version(process.env.CLI_VERSION || '0.0.0') // This will enable the --version flag based on package.json .version(getCliVersion()) // This will enable the --version flag based on package.json
.alias('v', 'version')
.help() .help()
.alias('h', 'help') .alias('h', 'help')
.strict().argv; .strict().argv;

View File

@ -109,8 +109,14 @@ function buildImage(imageName, dockerfile) {
? `${sandboxCommand} build --authfile=<(echo '{}')` ? `${sandboxCommand} build --authfile=<(echo '{}')`
: `${sandboxCommand} --config=".docker" buildx build`; : `${sandboxCommand} --config=".docker" buildx build`;
const npmPackageVersion = JSON.parse(
readFileSync(join(process.cwd(), 'package.json'), 'utf-8'),
).version;
execSync( execSync(
`${buildCommand} ${process.env.BUILD_SANDBOX_FLAGS || ''} -f "${dockerfile}" -t "${imageName}" .`, `${buildCommand} ${
process.env.BUILD_SANDBOX_FLAGS || ''
} --build-arg CLI_VERSION_ARG=${npmPackageVersion} -f "${dockerfile}" -t "${imageName}" .`,
{ stdio: buildStdout, shell: '/bin/bash' }, { stdio: buildStdout, shell: '/bin/bash' },
); );
console.log(`built ${imageName}`); console.log(`built ${imageName}`);