Skip to content

Commit 00d64e0

Browse files
authored
[0.81] Fix NPM tagging and stop releasing Debug Nugets (#15409)
* Attempt to fix the tgz file grouping * Stop creating Nuget packages for Debug code (#15374)
1 parent 6e59a48 commit 00d64e0

File tree

3 files changed

+52
-55
lines changed

3 files changed

+52
-55
lines changed

.ado/publish.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,6 @@ extends:
479479
configuration: Release
480480
- platform: ARM64
481481
configuration: Release
482-
- platform: x64
483-
configuration: Debug
484-
- platform: x86
485-
configuration: Debug
486-
- platform: ARM64
487-
configuration: Debug
488482

489483
- template: .ado/templates/prep-and-pack-nuget.yml@self
490484
parameters:

.ado/scripts/npmGroupByTag.js

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,15 @@ function setPipelineVariable(name, value) {
117117
(function main() {
118118
const {packRootArg, customRootArg, latestRootArg} = ensureArgs();
119119

120-
const repoRoot = process.env.BUILD_SOURCESDIRECTORY || process.cwd();
120+
const repoRoot = path.resolve(__dirname, '..', '..');
121+
const vnextPackageJsonPath = path.join(repoRoot, 'vnext', 'package.json');
122+
123+
if (!fs.existsSync(vnextPackageJsonPath)) {
124+
console.error(`[npmGroupByTag] vnext package.json not found at ${vnextPackageJsonPath}`);
125+
process.exit(1);
126+
}
127+
128+
console.log(`[npmGroupByTag] Using repo root ${repoRoot}`);
121129
const packRoot = path.resolve(packRootArg);
122130
const customRoot = path.resolve(customRootArg);
123131
const latestRoot = path.resolve(latestRootArg);
@@ -128,15 +136,19 @@ function setPipelineVariable(name, value) {
128136
/** @type {string | null} */
129137
let customTag = null;
130138
try {
131-
const vnextPackageJson = /** @type {PackageJson} */ (
132-
readJson(path.join(repoRoot, 'vnext', 'package.json'))
133-
);
139+
const vnextPackageJson = /** @type {PackageJson} */ (readJson(vnextPackageJsonPath));
134140
const tagFromVnext = vnextPackageJson?.beachball?.defaultNpmTag;
135141
if (tagFromVnext && tagFromVnext !== 'latest') {
136142
customTag = tagFromVnext;
137143
}
144+
console.log(
145+
`[npmGroupByTag] vnext defaultNpmTag is ${tagFromVnext || 'latest'}${
146+
customTag ? ` (custom tag '${customTag}' will be used)` : ' (no custom tag)'
147+
}`,
148+
);
138149
} catch (e) {
139-
console.warn('Unable to read vnext/package.json to determine custom tag.');
150+
console.error(`[npmGroupByTag] Failed to read ${vnextPackageJsonPath}: ${e}`);
151+
process.exit(1);
140152
}
141153

142154
/** @type {string[]} */
@@ -153,28 +165,31 @@ function setPipelineVariable(name, value) {
153165
return;
154166
}
155167

156-
/** @type {Set<string>} */
157-
const customTarballs = new Set();
168+
/** @type {Map<string, {packageJsonPath: string, name: string, version: string, tag: string, isPrivate: boolean}>} */
169+
const packageMetadata = new Map();
170+
for (const packageJsonPath of findPackageJsons(repoRoot)) {
171+
/** @type {PackageJson | undefined} */
172+
let pkg;
173+
try {
174+
pkg = /** @type {PackageJson} */ (readJson(packageJsonPath));
175+
} catch (e) {
176+
console.warn(`[npmGroupByTag] Skipping unreadable package.json ${packageJsonPath}: ${e}`);
177+
continue;
178+
}
158179

159-
if (customTag) {
160-
for (const packageJsonPath of findPackageJsons(repoRoot)) {
161-
/** @type {PackageJson | undefined} */
162-
let pkg;
163-
try {
164-
pkg = /** @type {PackageJson} */ (readJson(packageJsonPath));
165-
} catch (e) {
166-
continue;
167-
}
180+
if (!pkg?.name || !pkg?.version) {
181+
continue;
182+
}
168183

169-
if (!pkg?.name || !pkg?.version) {
170-
continue;
171-
}
184+
const metadata = {
185+
packageJsonPath,
186+
name: pkg.name,
187+
version: pkg.version,
188+
tag: pkg?.beachball?.defaultNpmTag || 'latest',
189+
isPrivate: pkg.private === true,
190+
};
172191

173-
const pkgTag = pkg?.beachball?.defaultNpmTag;
174-
if (pkgTag === customTag && pkg.private !== true) {
175-
customTarballs.add(sanitizedTarballName(pkg.name, pkg.version));
176-
}
177-
}
192+
packageMetadata.set(sanitizedTarballName(pkg.name, pkg.version), metadata);
178193
}
179194

180195
let customCount = 0;
@@ -183,10 +198,22 @@ function setPipelineVariable(name, value) {
183198
for (const tarball of tarballs) {
184199
const sourcePath = path.join(packRoot, tarball);
185200
const normalizedName = normalizePackedTarballName(tarball);
186-
const destinationRoot = customTag && customTarballs.has(normalizedName) ? customRoot : latestRoot;
201+
const metadata = packageMetadata.get(normalizedName);
202+
const destinationRoot = customTag && metadata && !metadata.isPrivate && metadata.tag === customTag ? customRoot : latestRoot;
187203
const destinationPath = path.join(destinationRoot, tarball);
188204
fs.mkdirSync(path.dirname(destinationPath), {recursive: true});
189205
fs.renameSync(sourcePath, destinationPath);
206+
207+
if (metadata) {
208+
const destinationLabel = destinationRoot === customRoot ? 'custom' : 'latest';
209+
console.log(
210+
`[npmGroupByTag] ${tarball}: ${metadata.name}@${metadata.version} (${metadata.packageJsonPath}) tag=${metadata.tag} ` +
211+
`private=${metadata.isPrivate} -> ${destinationLabel}`,
212+
);
213+
} else {
214+
console.warn(`[npmGroupByTag] ${tarball}: no package.json metadata found. Defaulting to latest.`);
215+
}
216+
190217
if (destinationRoot === customRoot) {
191218
customCount++;
192219
} else {

.ado/templates/prep-and-pack-nuget.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,15 @@ parameters:
4242
steps:
4343
- pwsh: |
4444
$slices = ConvertFrom-Json -NoEnumerate '${{ convertToJson(parameters.slices) }}'
45-
$debugSlices = @($slices.where{$_.configuration -match 'Debug'});
4645
$releaseSlices = @($slices.where{$_.configuration -match 'Release'});
4746
4847
$sliceTags = $slices | % {$_.platform + "." + $_.configuration} | ConvertTo-Json -AsArray -Compress
49-
$debugSliceTags = $debugSlices | % {$_.platform + "." + $_.configuration} | ConvertTo-Json -AsArray -Compress
5048
$releaseSliceTags = $releaseSlices | % {$_.platform + "." + $_.configuration} | ConvertTo-Json -AsArray -Compress
5149
5250
Write-Host "##vso[task.setvariable variable=allSlices]$sliceTags"
53-
Write-Host "##vso[task.setvariable variable=debugSlices]$debugSliceTags"
5451
Write-Host "##vso[task.setvariable variable=releaseSlices]$releaseSliceTags"
5552
5653
Write-Host "##vso[task.setvariable variable=basePlatform]$($slices[0].platform)"
57-
Write-Host "##vso[task.setvariable variable=debugBasePlatform]$($debugSlices[0].platform)"
5854
Write-Host "##vso[task.setvariable variable=releaseBasePlatform]$($releaseSlices[0].platform)"
5955
6056
Write-Host "##vso[task.setvariable variable=baseConfiguration]$($slices[0].configuration)"
@@ -100,16 +96,6 @@ steps:
10096
buildProperties: 'CommitId=${{parameters.publishCommitId}};nugetroot=${{parameters.nugetroot}}'
10197

10298
- ${{ if eq(parameters.packMicrosoftReactNative, true) }}:
103-
- ${{ if containsValue(parameters.slices.*.configuration, 'Debug') }}:
104-
- template: prep-and-pack-single.yml
105-
parameters:
106-
outputPackage: Microsoft.ReactNative.Debug
107-
nuspec: Microsoft.ReactNative
108-
slices: $(debugSlices)
109-
packageVersion: ${{parameters.npmVersion}}
110-
codesignBinaries: ${{ parameters.signMicrosoft }}
111-
codesignNuget: ${{ parameters.signMicrosoft }}
112-
buildProperties: CommitId=${{parameters.publishCommitId}};nugetroot=${{parameters.nugetroot}};baseconfiguration=Debug;baseplatform=$(debugBasePlatform)
11399
- ${{ if containsValue(parameters.slices.*.configuration, 'Release') }}:
114100
- template: prep-and-pack-single.yml
115101
parameters:
@@ -130,16 +116,6 @@ steps:
130116
codesignNuget: ${{ parameters.signMicrosoft }}
131117

132118
- ${{ if eq(parameters.packMicrosoftReactNativeManaged, true) }}:
133-
- ${{ if containsValue(parameters.slices.*.configuration, 'Debug') }}:
134-
- template: prep-and-pack-single.yml
135-
parameters:
136-
outputPackage: Microsoft.ReactNative.Managed.Debug
137-
nuspec: Microsoft.ReactNative.Managed
138-
slices: $(debugSlices)
139-
packageVersion: ${{parameters.npmVersion}}
140-
codesignBinaries: ${{ parameters.signMicrosoft }}
141-
codesignNuget: ${{ parameters.signMicrosoft }}
142-
buildProperties: CommitId=${{parameters.publishCommitId}};nugetroot=${{parameters.nugetroot}};baseconfiguration=Debug;baseplatform=$(debugBasePlatform)
143119
- ${{ if containsValue(parameters.slices.*.configuration, 'Release') }}:
144120
- template: prep-and-pack-single.yml
145121
parameters:

0 commit comments

Comments
 (0)