Skip to content

Commit 1d0c636

Browse files
authored
ci: only publish if there are changes to push (#2447)
## Summary: Only publish packages if there are changes to push ## Test Plan: n/a
1 parent 2b400fe commit 1d0c636

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.ado/templates/npm-publish-steps.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ steps:
4141
condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
4242
4343
- script: |
44-
yarn nx release publish --excludeTaskDependencies
44+
if [[ -f .rnm-publish ]]; then
45+
yarn nx release publish --excludeTaskDependencies
46+
fi
4547
displayName: Publish packages
4648
condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))
4749

packages/nx-release-version/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ const { releaseVersionGenerator } = require('@nx/js/src/generators/release-versi
44
const fs = require('node:fs');
55
const path = require('node:path');
66
const { spawnSync } = require('node:child_process');
7+
const { REPO_ROOT } = require('../../scripts/consts');
78

9+
/**
10+
* @returns {Promise<string[]>}
11+
*/
812
async function runSetVersion() {
913
const rnmPkgJson = require.resolve('react-native-macos/package.json');
10-
const { REPO_ROOT } = require('../../scripts/consts');
1114
const { updateReactNativeArtifacts } = require('../../scripts/releases/set-rn-artifacts-version');
1215

1316
const manifest = fs.readFileSync(rnmPkgJson, { encoding: 'utf-8' });
@@ -78,9 +81,11 @@ module.exports = async function(tree, options) {
7881
callback: async (tree, options) => {
7982
const result = await callback(tree, options);
8083

81-
const versionedFiles = await runSetVersion();
82-
if (versionedFiles) {
83-
const changedFiles = Array.isArray(result) ? result : result.changedFiles;
84+
// Only update artifacts if there were changes
85+
const changedFiles = Array.isArray(result) ? result : result.changedFiles;
86+
if (changedFiles.length > 0) {
87+
fs.writeFile(path.join(REPO_ROOT, '.rnm-publish'), '', () => null);
88+
const versionedFiles = await runSetVersion();
8489
changedFiles.push(...versionedFiles);
8590
}
8691

0 commit comments

Comments
 (0)