fix(sandbox): add SHORT_SHA to image tag (#604)

This commit is contained in:
Brandon Keiji 2025-05-29 23:43:20 +00:00 committed by GitHub
parent 1c066548b4
commit 7468d3cddf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 36 deletions

View File

@ -4,22 +4,21 @@ steps:
entrypoint: 'npm'
args: ['install']
# Step 2: Update version with build suffix
# Step 2: Update version in root package.json
- name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
entrypoint: 'npm'
entrypoint: 'bash'
args:
[
'run',
'prerelease:version',
'--workspaces',
'--',
'--suffix="$SHORT_SHA.$_REVISION"',
]
- -c # Use bash -c to allow for command substitution and string manipulation
- |
current_version=$(npm pkg get version | sed 's/"//g')
new_version="$${current_version}-$SHORT_SHA.$_REVISION"
npm pkg set "version=$${new_version}"
echo "Set root package.json version to: $${new_version}"
# Step 3: Bind dependencies to the new versions
# Step 3: Run prerelease:dev to update workspace versions and dependencies
- name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'
entrypoint: 'npm'
args: ['run', 'prerelease:deps', '--workspaces']
args: ['run', 'prerelease:dev'] # This will run prerelease:version and prerelease:deps
# Step 4: Authenticate for Docker and NPM
- name: 'us-west1-docker.pkg.dev/gemini-code-dev/gemini-code-containers/gemini-code-builder'

View File

@ -6,41 +6,19 @@
import fs from 'node:fs';
import path from 'node:path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { execSync } from 'node:child_process';
// Assuming script is run from a package directory (e.g., packages/cli)
const packageDir = process.cwd();
const rootDir = path.join(packageDir, '..', '..'); // Go up two directories to find the repo root
function getBaseVersion() {
function getRepoVersion() {
// Read root package.json
const rootPackageJsonPath = path.join(rootDir, 'package.json');
const rootPackage = JSON.parse(fs.readFileSync(rootPackageJsonPath, 'utf8'));
return rootPackage.version;
return rootPackage.version; // This version is now expected to be the full version string
}
function getDefaultSuffix() {
// Get latest commit hash
const commitHash = execSync('git rev-parse --short HEAD', {
encoding: 'utf8',
}).trim();
// Append dev suffix with commit hash
return `dev-${commitHash}.0`;
}
const argv = yargs(hideBin(process.argv))
.option('suffix', {
type: 'string',
description: 'Set the package version suffix',
})
.parse();
const baseVersion = getBaseVersion();
const suffix = argv['suffix'] ?? getDefaultSuffix();
const newVersion = `${baseVersion}${suffix.length ? '-' : ''}${suffix}`;
const newVersion = getRepoVersion();
console.log(`Setting package version to: ${newVersion}`);
const packageJsonPath = path.join(packageDir, 'package.json');