Skip to content

Commit 1211612

Browse files
authored
ci: only create .rnm-publish sentinel file if versioning happened (#2682)
## Summary: We run `npm publish` if a `.rnm-publish` sentinel file exists, which is created as part of nx release. We were unconditionally creating it, which meant that we would attempt to publish every run, leading to failed publish runs that try to publish over an existing package. This change adds a check to only create the sentinel file if publish detects a change. ## Test Plan: CI should pass
1 parent 66f8fbe commit 1211612

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

packages/nx-release-version/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,25 @@ const afterAllProjectsVersioned = async (cwd, opts) => {
7979
const changedFiles = [...baseResult.changedFiles];
8080
const deletedFiles = [...baseResult.deletedFiles];
8181

82-
try {
83-
// Create the .rnm-publish file to indicate versioning has occurred
84-
fs.writeFileSync(path.join(REPO_ROOT, '.rnm-publish'), '');
82+
// Only update React Native artifacts if versioning actually happened
83+
if (changedFiles.length > 0) {
84+
try {
85+
// Create the .rnm-publish file to indicate versioning has occurred
86+
fs.writeFileSync(path.join(REPO_ROOT, '.rnm-publish'), '');
8587

86-
// Update React Native artifacts
87-
const versionedFiles = await runSetVersion();
88+
// Update React Native artifacts
89+
const versionedFiles = await runSetVersion();
8890

89-
// Add the versioned files to changed files
90-
changedFiles.push(...versionedFiles);
91+
// Add the versioned files to changed files
92+
changedFiles.push(...versionedFiles);
9193

92-
console.log('✅ Updated React Native artifacts');
93-
console.table(versionedFiles.map(file => path.relative(REPO_ROOT, file)));
94-
} catch (error) {
95-
const errorMessage = error instanceof Error ? error.message : String(error);
96-
console.error(`❌ Failed to update React Native artifacts: ${errorMessage}`);
97-
throw error;
94+
console.log('✅ Updated React Native artifacts');
95+
console.table(versionedFiles.map(file => path.relative(REPO_ROOT, file)));
96+
} catch (error) {
97+
const errorMessage = error instanceof Error ? error.message : String(error);
98+
console.error(`❌ Failed to update React Native artifacts: ${errorMessage}`);
99+
throw error;
100+
}
98101
}
99102

100103
return {

0 commit comments

Comments
 (0)