Skip to content

build: release script producing duplicate results #30999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions scripts/build-packages-dist.mts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const bazelCmd = process.env['BAZEL'] || `pnpm -s bazel`;

/** Command that queries Bazel for all release package targets. */
const queryPackagesCmd =
`${bazelCmd} query --output=label "attr('tags', '\\[.*${releaseTargetTag}.*\\]', //src/...) ` +
`intersect kind('.*_package', //src/...)"`;
`${bazelCmd} query --output=label "filter(':npm_package$', ` +
`attr('tags', '\\[.*${releaseTargetTag}.*\\]', //src/...))"`;

/** Path for the default distribution output directory. */
const defaultDistPath = join(projectDir, 'dist/releases');
Expand Down Expand Up @@ -93,16 +93,29 @@ function buildReleasePackages(distPath: string, isSnapshotBuild: boolean): Built
* e.g. //src/material:npm_package = material
*/
function getPackageNamesOfTargets(targets: string[]): string[] {
return targets.map(targetName => {
const matches = targetName.match(/\/\/src\/(.*):npm_package/);
if (matches === null) {
throw Error(
const seen = new Set<string>();

for (const targetName of targets) {
const match = targetName.match(/\/\/src\/(.*):npm_package/)?.[1];

if (!match) {
throw new Error(
`Found Bazel target with "${releaseTargetTag}" tag, but could not ` +
`determine release output name: ${targetName}`,
);
}
return matches[1];
});

if (seen.has(match)) {
throw new Error(
`Detected duplicate package "${match}". The duplication can cause issues when publishing ` +
`to npm and needs to be resolved.`,
);
}

seen.add(match);
}

return Array.from(seen);
}

/** Executes the given command in the project directory. */
Expand Down
Loading