Search code examples
gitnpmyarnpkg

How to Use Yarn Version command to update to released version from prerelease version


I have used Yarn with git in my project to create and manage pre-release versions of my package. Now that I've completed all of my build work, I'm ready to use the yarn version command to move beyond prerelease to official release.

I am expecting to use some form of the yarn version command so that my npm package version is promoted from v0.1.1-rc.8 to v0.1.1; however, I see no documentation for this. I am relying on the postversion script within package.json that is invoked when I execute yarn version to manage the git push/tagging etc.

I'm currently using the following command line tool versions on Windows 11:

  • yarn: 1.22.19
  • git: 2.39.1.windows.1
  • npm: 9.6.7

Solution

  • I think I may have the answer. It appears to me that executing yarn version --patch (since I was operating on a pre-release for a patch) is the correct comma nd line. I am hoping to get confirmation of this. If this is correct, then the documentation seems to be lacking examples that step all of the way through starting a new pre-release, patch version, bumping that pre-release version, and finally completing/releasing the official new patch version - this was not clear to me.

    In my actual case, sitting on the pre-release patch version v1.0.0-rc.12, after executing the command above, it updated to a release patch version v1.0.0 - which is what I was wanting to do.