From 73d93479924f659218e75b694b07d41344cadedf Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 15 Sep 2026 20:46:42 -0400 Subject: [PATCH] Use local versions for decoupled dependency bumps --- .../azure-pipelines/npm-post-publish.yaml | 47 ++----------------- .../actions/BumpDecoupledLocalDependencies.ts | 40 +++++++++++++--- 2 files changed, 36 insertions(+), 51 deletions(-) diff --git a/common/config/azure-pipelines/npm-post-publish.yaml b/common/config/azure-pipelines/npm-post-publish.yaml index 7e4b70e5ab..877abcd1be 100644 --- a/common/config/azure-pipelines/npm-post-publish.yaml +++ b/common/config/azure-pipelines/npm-post-publish.yaml @@ -117,52 +117,11 @@ extends: --verbose DisplayName: 'Rush Build (repo-toolbox)' - # Use the versions recorded during publishing to avoid propagation latency in the package feeds. - - bash: | - set -e - - triggering_alias="$(resources.triggeringAlias)" - rushstack_pipeline_id="$(resources.pipeline.esrpPublishRushstack.pipelineID)" - rushstack_run_id="$(resources.pipeline.esrpPublishRushstack.runID)" - rush_pipeline_id="$(resources.pipeline.esrpPublishRush.pipelineID)" - rush_run_id="$(resources.pipeline.esrpPublishRush.runID)" - - if [[ "$triggering_alias" == "esrpPublishRushstack" ]]; then - pipeline_id="$rushstack_pipeline_id" - run_id="$rushstack_run_id" - elif [[ "$triggering_alias" == "esrpPublishRush" ]]; then - pipeline_id="$rush_pipeline_id" - run_id="$rush_run_id" - # If this pipeline was not resource-triggered, use whichever publishing pipeline ran latest. - elif (( rushstack_run_id > rush_run_id )); then - pipeline_id="$rushstack_pipeline_id" - run_id="$rushstack_run_id" - else - pipeline_id="$rush_pipeline_id" - run_id="$rush_run_id" - fi - - echo "Using publishing pipeline $pipeline_id, run $run_id (trigger: ${triggering_alias:-manual})" - echo "##vso[task.setvariable variable=PublishingPipelineId]$pipeline_id" - echo "##vso[task.setvariable variable=PublishingRunId]$run_id" - displayName: 'Select publishing pipeline run' - - - task: DownloadPipelineArtifact@2 - displayName: 'Download published package versions' - inputs: - source: specific - project: GitHubProjectsPublish - pipeline: $(PublishingPipelineId) - runVersion: specific - runId: $(PublishingRunId) - artifact: published-versions - path: $(Pipeline.Workspace)/published-versions - + # Resource-triggered runs check out the publishing pipeline's commit, so local package + # versions match the versions that were just published without waiting for feed propagation. - template: /common/config/azure-pipelines/templates/run-repo-toolbox.yaml@self parameters: - Arguments: > - bump-decoupled-local-dependencies - --published-versions-path "$(Pipeline.Workspace)/published-versions/published-versions.json" + Arguments: 'bump-decoupled-local-dependencies' DisplayName: 'Bump decoupled local dependencies' # If Rush itself was updated by bump-decoupled-local-dependencies, we need to bootstrap diff --git a/repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts b/repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts index f14b734644..a67da99f86 100644 --- a/repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts +++ b/repo-scripts/repo-toolbox/src/cli/actions/BumpDecoupledLocalDependencies.ts @@ -6,19 +6,40 @@ import type { ChildProcess } from 'node:child_process'; import { Async, Executable, FileSystem, type FolderItem, JsonFile } from '@rushstack/node-core-library'; import type { ITerminal } from '@rushstack/terminal'; -import { DependencyType, PackageJsonEditor, RushConfiguration, type Subspace } from '@microsoft/rush-lib'; +import { + DependencyType, + PackageJsonEditor, + RushConfiguration, + type RushConfigurationProject, + type Subspace +} from '@microsoft/rush-lib'; import type { IRushConfigurationJson } from '@microsoft/rush-lib/lib/api/RushConfiguration'; import { CommandLineAction, type CommandLineStringParameter } from '@rushstack/ts-command-line'; +function _getLocalPublishedVersions(projects: Iterable): Record { + const localPublishedVersions: Record = {}; + for (const { + shouldPublish, + packageName, + packageJson: { version } + } of projects) { + if (shouldPublish) { + localPublishedVersions[packageName] = version; + } + } + + return localPublishedVersions; +} + async function _getLatestPublishedVersionAsync( terminal: ITerminal, packageName: string, - publishedVersions: Record | undefined, + publishedVersions: Record, feedUrl: string | undefined ): Promise { - const recordedVersion: string | undefined = publishedVersions?.[packageName]; + const recordedVersion: string | undefined = publishedVersions[packageName]; if (recordedVersion) { - terminal.writeLine(`Found version "${recordedVersion}" for "${packageName}" in published versions file`); + terminal.writeLine(`Found version "${recordedVersion}" for "${packageName}"`); return recordedVersion; } @@ -86,13 +107,18 @@ export class BumpDecoupledLocalDependencies extends CommandLineAction { const terminal: ITerminal = this.#terminal; const feedUrl: string | undefined = this.#feedUrlParameter.value; const publishedVersionsPath: string | undefined = this.#publishedVersionsPathParameter.value; - const publishedVersions: Record | undefined = publishedVersionsPath - ? await JsonFile.loadAsync(path.resolve(publishedVersionsPath)) - : undefined; const rushConfiguration: RushConfiguration = RushConfiguration.loadFromDefaultLocation({ startingFolder: process.cwd() }); const { projects, rushJsonFile, commonAutoinstallersFolder } = rushConfiguration; + const localPublishedVersions: Record = _getLocalPublishedVersions(projects); + const publishedVersionsOverride: Record | undefined = publishedVersionsPath + ? await JsonFile.loadAsync(path.resolve(publishedVersionsPath)) + : undefined; + const publishedVersions: Record = { + ...localPublishedVersions, + ...publishedVersionsOverride + }; const projectsToUpdate: IProjectLike[] = [];