Skip to content

chore: add post-version step to Nx Release#2418

Merged
Saadnajmi merged 2 commits intomainfrom
tido/nx-post-version
Mar 17, 2025
Merged

chore: add post-version step to Nx Release#2418
Saadnajmi merged 2 commits intomainfrom
tido/nx-post-version

Conversation

@tido64
Copy link
Copy Markdown
Member

@tido64 tido64 commented Mar 17, 2025

Summary:

Adds a post-version step to Nx Release for updating generated artifacts (e.g., RCTVersion.m).

Test Plan:

Bump the version and run nx release:

yarn nx release plan --only-touched=false patch
yarn nx release --skip-publish --verbose

Verify that generated artifacts have been updated with the latest version number.

@tido64 tido64 requested a review from a team as a code owner March 17, 2025 14:04
@Saadnajmi
Copy link
Copy Markdown
Collaborator

Saadnajmi commented Mar 17, 2025

EDIT: This is because dry-run doesn't commit the files, so the generator fails. I'll move forward with this knowing that caveat.


I did a quick test by cherry-picking this to a local branch off 0.77-stable, and added these logging statements:

  const manifest = fs.readFileSync(rnmPkgJson, { encoding: 'utf-8' });
  const { version } = JSON.parse(manifest);

  console.log('SAAD');
  console.log(version);

Which resulted in this output:

...
UPDATE packages/react-native-test-library/package.json [dry-run]

  "name": "@react-native/oss-library-example",
-   "version": "0.77.2",
+   "version": "0.77.4",
  "private": true,

    "@react-native/babel-preset": "0.77.0",
-     "react-native-macos": "0.77.0"
+     "react-native-macos": "0.77.1"
  },

SAAD
0.77.0

It seems to be picking up the old version because the new version hasn't been committed yet?

Alternatively, we could use nx's releaseVersion function (which is part of their public API) to get the new version as I do in #2417:

    const { workspaceVersion, projectsVersionData } = await releaseVersion({
       specifier: options.version,
       dryRun: options["dry-run"],
       verbose: options.verbose,
   });
   const newRNMVersion = projectsVersionData["react-native-macos"].newVersion;

Comment thread packages/nx-release-version/index.js Outdated
@Saadnajmi Saadnajmi merged commit 91bd03a into main Mar 17, 2025
12 checks passed
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Mar 17, 2025
Adds a post-version step to Nx Release for updating generated artifacts
(e.g., `RCTVersion.m`).

Bump the version and run `nx release`:

```
yarn nx release plan --only-touched=false patch
yarn nx release --skip-publish --verbose
```

Verify that generated artifacts have been updated with the latest
version number.

---------

Co-authored-by: Saad Najmi <sanajmi@microsoft.com>
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Mar 17, 2025
Adds a post-version step to Nx Release for updating generated artifacts
(e.g., `RCTVersion.m`).

Bump the version and run `nx release`:

```
yarn nx release plan --only-touched=false patch
yarn nx release --skip-publish --verbose
```

Verify that generated artifacts have been updated with the latest
version number.

---------

Co-authored-by: Saad Najmi <sanajmi@microsoft.com>
@tido64 tido64 deleted the tido/nx-post-version branch March 18, 2025 08:07
@Saadnajmi Saadnajmi mentioned this pull request May 1, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants