fix(release): Fix promotion workflow (#10261)

This commit is contained in:
Shreya Keshive
2025-09-30 19:16:53 -04:00
committed by GitHub
parent 794d92a79d
commit f2aa9d283a
2 changed files with 42 additions and 25 deletions
+33 -16
View File
@@ -68,12 +68,15 @@ jobs:
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
run: | run: |
set -e set -e
STABLE_JSON=$(node scripts/get-release-version.js --type=stable ${{ github.event.inputs.stable_version_override && format('--stable_version_override={0}', github.event.inputs.stable_version_override) || '' }}) STABLE_COMMAND="node scripts/get-release-version.js --type=stable ${{ github.event.inputs.stable_version_override && format('--stable_version_override={0}', github.event.inputs.stable_version_override) || '' }}"
PREVIEW_JSON=$(node scripts/get-release-version.js --type=preview ${{ github.event.inputs.preview_version_override && format('--preview_version_override={0}', github.event.inputs.preview_version_override) || '' }}) PREVIEW_COMMAND="node scripts/get-release-version.js --type=preview ${{ github.event.inputs.preview_version_override && format('--preview_version_override={0}', github.event.inputs.preview_version_override) || '' }}"
NIGHTLY_JSON=$(node scripts/get-release-version.js --type=promote-nightly) NIGHTLY_COMMAND="node scripts/get-release-version.js --type=promote-nightly"
echo "STABLE_JSON_COMMAND=node scripts/get-release-version.js --type=stable ${{ github.event.inputs.stable_version_override && format('--stable_version_override={0}', github.event.inputs.stable_version_override) || '' }}" STABLE_JSON=$(${STABLE_COMMAND})
echo "PREVIEW_JSON_COMMAND=node scripts/get-release-version.js --type=preview ${{ github.event.inputs.preview_version_override && format('--preview_version_override={0}', github.event.inputs.preview_version_override) || '' }}" PREVIEW_JSON=$(${PREVIEW_COMMAND})
echo "NIGHTLY_JSON_COMMAND=node scripts/get-release-version.js --type=promote-nightly" NIGHTLY_JSON=$(${NIGHTLY_COMMAND})
echo "STABLE_JSON_COMMAND=${STABLE_COMMAND}"
echo "PREVIEW_JSON_COMMAND=${PREVIEW_COMMAND}"
echo "NIGHTLY_JSON_COMMAND=${NIGHTLY_COMMAND}"
echo "STABLE_JSON: ${STABLE_JSON}" echo "STABLE_JSON: ${STABLE_JSON}"
echo "PREVIEW_JSON: ${PREVIEW_JSON}" echo "PREVIEW_JSON: ${PREVIEW_JSON}"
echo "NIGHTLY_JSON: ${NIGHTLY_JSON}" echo "NIGHTLY_JSON: ${NIGHTLY_JSON}"
@@ -83,25 +86,39 @@ jobs:
echo "PREVIOUS_STABLE_TAG=$(echo "${STABLE_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}" echo "PREVIOUS_STABLE_TAG=$(echo "${STABLE_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}"
echo "PREVIEW_VERSION=$(echo "${PREVIEW_JSON}" | jq -r .releaseVersion)" >> "${GITHUB_OUTPUT}" echo "PREVIEW_VERSION=$(echo "${PREVIEW_JSON}" | jq -r .releaseVersion)" >> "${GITHUB_OUTPUT}"
# shellcheck disable=SC1083 # shellcheck disable=SC1083
echo "PREVIEW_SHA=$(git rev-parse '${{ github.event.inputs.ref }}'^{commit})" >> "${GITHUB_OUTPUT}" REF="${{ github.event.inputs.ref }}"
SHA=$(git ls-remote origin "$REF" | awk '{print $1}')
if [ -z "$SHA" ]; then
if [[ "$REF" =~ ^[0-9a-f]{7,40}$ ]]; then
SHA="$REF"
else
echo "::error::Could not resolve ref '$REF' to a commit SHA."
exit 1
fi
fi
echo "PREVIEW_SHA=$SHA" >> "${GITHUB_OUTPUT}"
echo "PREVIOUS_PREVIEW_TAG=$(echo "${PREVIEW_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}" echo "PREVIOUS_PREVIEW_TAG=$(echo "${PREVIEW_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}"
echo "NEXT_NIGHTLY_VERSION=$(echo "${NIGHTLY_JSON}" | jq -r .releaseVersion)" >> "${GITHUB_OUTPUT}" echo "NEXT_NIGHTLY_VERSION=$(echo "${NIGHTLY_JSON}" | jq -r .releaseVersion)" >> "${GITHUB_OUTPUT}"
echo "PREVIOUS_NIGHTLY_TAG=$(echo "${NIGHTLY_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}" echo "PREVIOUS_NIGHTLY_TAG=$(echo "${NIGHTLY_JSON}" | jq -r .previousReleaseTag)" >> "${GITHUB_OUTPUT}"
CURRENT_NIGHTLY_TAG=$(git describe --tags --abbrev=0 --match="*nightly*") CURRENT_NIGHTLY_TAG=$(git describe --tags --abbrev=0 --match="*nightly*")
echo "CURRENT_NIGHTLY_TAG=${CURRENT_NIGHTLY_TAG}" >> "${GITHUB_OUTPUT}" echo "CURRENT_NIGHTLY_TAG=${CURRENT_NIGHTLY_TAG}" >> "${GITHUB_OUTPUT}"
echo "NEXT_SHA=$(git rev-parse HEAD)" >> "${GITHUB_OUTPUT}" echo "NEXT_SHA=$SHA" >> "${GITHUB_OUTPUT}"
- name: 'Display Pending Updates' - name: 'Display Pending Updates'
run: | run: |
echo "Pending Changes, Next Versions:" echo "Release Plan:"
echo " Nightly: ${{ steps.versions.outputs.NEXT_NIGHTLY_VERSION }}" echo "-----------"
echo " Preview: ${{ steps.versions.outputs.PREVIEW_VERSION }}" echo "Stable Release: ${{ steps.versions.outputs.STABLE_VERSION }}"
echo " Stable: ${{ steps.versions.outputs.STABLE_VERSION }}" echo " - Commit: ${{ steps.versions.outputs.STABLE_SHA }}"
echo " - Previous Tag: ${{ steps.versions.outputs.PREVIOUS_STABLE_TAG }}"
echo "" echo ""
echo "Relevant SHAs:" echo "Preview Release: ${{ steps.versions.outputs.PREVIEW_VERSION }}"
echo " Stable: Will be cut from: : ${{ steps.versions.outputs.STABLE_SHA }} / ${{ steps.versions.outputs.PREVIOUS_STABLE_TAG }}" echo " - Commit: ${{ steps.versions.outputs.PREVIEW_SHA }} (${{ github.event.inputs.ref }})"
echo " Preview will be cut from: : ${{ steps.versions.outputs.PREVIEW_SHA }} (${{ github.event.inputs.ref }})". Users last saw preview as: ${{ steps.versions.outputs.PREVIOUS_PREVIEW_TAG }} echo " - Previous Tag: ${{ steps.versions.outputs.PREVIOUS_PREVIEW_TAG }}"
echo " Nightly will be udpated in : ${{ steps.versions.outputs.NEXT_SHA }} (${{ github.event.inputs.ref }}). Previous nightly tag: ${{ steps.versions.outputs.PREVIOUS_NIGHTLY_TAG }}" echo ""
echo "Next Nightly Release: ${{ steps.versions.outputs.NEXT_NIGHTLY_VERSION }}"
echo " - Commit: ${{ steps.versions.outputs.NEXT_SHA }} (${{ github.event.inputs.ref }})"
echo " - Previous Tag: ${{ steps.versions.outputs.PREVIOUS_NIGHTLY_TAG }}"
test: test:
name: 'Test ${{ matrix.channel }}' name: 'Test ${{ matrix.channel }}'
+9 -9
View File
@@ -84,7 +84,7 @@ function isVersionDeprecated(version) {
return output.length > 0; return output.length > 0;
} catch (error) { } catch (error) {
// This command shouldn't fail for existing versions, but as a safeguard: // This command shouldn't fail for existing versions, but as a safeguard:
console.warn( console.error(
`Failed to check deprecation status for ${version}: ${error.message}`, `Failed to check deprecation status for ${version}: ${error.message}`,
); );
return false; // Assume not deprecated on error to avoid breaking the release. return false; // Assume not deprecated on error to avoid breaking the release.
@@ -136,7 +136,7 @@ function detectRollbackAndGetBaseline(npmDistTag) {
highestExistingVersion = version; highestExistingVersion = version;
break; // Found the one we want break; // Found the one we want
} else { } else {
console.log(`Ignoring deprecated version: ${version}`); console.error(`Ignoring deprecated version: ${version}`);
} }
} }
@@ -162,7 +162,7 @@ function doesVersionExist(version) {
const command = `npm view @google/gemini-cli@${version} version 2>/dev/null`; const command = `npm view @google/gemini-cli@${version} version 2>/dev/null`;
const output = execSync(command).toString().trim(); const output = execSync(command).toString().trim();
if (output === version) { if (output === version) {
console.warn(`Version ${version} already exists on NPM.`); console.error(`Version ${version} already exists on NPM.`);
return true; return true;
} }
} catch (_error) { } catch (_error) {
@@ -174,11 +174,11 @@ function doesVersionExist(version) {
const command = `git tag -l 'v${version}'`; const command = `git tag -l 'v${version}'`;
const tagOutput = execSync(command).toString().trim(); const tagOutput = execSync(command).toString().trim();
if (tagOutput === `v${version}`) { if (tagOutput === `v${version}`) {
console.warn(`Git tag v${version} already exists.`); console.error(`Git tag v${version} already exists.`);
return true; return true;
} }
} catch (error) { } catch (error) {
console.warn(`Failed to check git tags for conflicts: ${error.message}`); console.error(`Failed to check git tags for conflicts: ${error.message}`);
} }
// Check GitHub releases // Check GitHub releases
@@ -186,7 +186,7 @@ function doesVersionExist(version) {
const command = `gh release view "v${version}" --json tagName --jq .tagName 2>/dev/null`; const command = `gh release view "v${version}" --json tagName --jq .tagName 2>/dev/null`;
const output = execSync(command).toString().trim(); const output = execSync(command).toString().trim();
if (output === `v${version}`) { if (output === `v${version}`) {
console.warn(`GitHub release v${version} already exists.`); console.error(`GitHub release v${version} already exists.`);
return true; return true;
} }
} catch (error) { } catch (error) {
@@ -196,7 +196,7 @@ function doesVersionExist(version) {
error.message.includes('not found') || error.message.includes('not found') ||
error.status === 1; error.status === 1;
if (!isExpectedNotFound) { if (!isExpectedNotFound) {
console.warn( console.error(
`Failed to check GitHub releases for conflicts: ${error.message}`, `Failed to check GitHub releases for conflicts: ${error.message}`,
); );
} }
@@ -216,7 +216,7 @@ function getAndVerifyTags(npmDistTag, _gitTagPattern) {
if (rollbackInfo.isRollback) { if (rollbackInfo.isRollback) {
// Rollback scenario: warn about the rollback but don't fail // Rollback scenario: warn about the rollback but don't fail
console.warn( console.error(
`Rollback detected! NPM ${npmDistTag} tag is ${rollbackInfo.distTagVersion}, but using ${baselineVersion} as baseline for next version calculation (highest existing version).`, `Rollback detected! NPM ${npmDistTag} tag is ${rollbackInfo.distTagVersion}, but using ${baselineVersion} as baseline for next version calculation (highest existing version).`,
); );
} }
@@ -414,7 +414,7 @@ export function getVersion(options = {}) {
if (type === 'stable' || type === 'preview' || type === 'patch') { if (type === 'stable' || type === 'preview' || type === 'patch') {
let releaseVersion = versionData.releaseVersion; let releaseVersion = versionData.releaseVersion;
while (doesVersionExist(releaseVersion)) { while (doesVersionExist(releaseVersion)) {
console.log(`Version ${releaseVersion} exists, incrementing.`); console.error(`Version ${releaseVersion} exists, incrementing.`);
if (releaseVersion.includes('-preview.')) { if (releaseVersion.includes('-preview.')) {
// Increment preview number: 0.6.0-preview.2 -> 0.6.0-preview.3 // Increment preview number: 0.6.0-preview.2 -> 0.6.0-preview.3
const [version, prereleasePart] = releaseVersion.split('-'); const [version, prereleasePart] = releaseVersion.split('-');