Sometimes you're not quite ready to release a full on version of your open source library to npm. In this lesson, learn how to publish a beta version so people can try it out without tampering with anyone else using your library.
[00:00] Now let's say we want to publish a beta version of our library. The way that we accomplish this is pretty much the same as if we were publishing anything. Let's go ahead and make the change. I'm going to go ahead and add "Kent C. Dodds" here.
[00:15] I want to push this out as a beta, because I'm not sure if people would be happy to have my name in here. I'd like to have people test it out, but not have it be the default version that's installed.
[00:26] We'll go into our packaged JSON, and on the version, we're going to bump it just as if it were a normal release. This is a new feature. We'll bump the minor version. Then, we're going to add "-beta.0to the end of this. We can increment that zero as much as we like. This "beta" in the version, indicates that this is a beta version, so user beware.
[00:51] Now, let's go ahead and check out the diff. These are the only things that we want to change. We'll add all the changes, and we'll commit those. Adding "Kent C. Dodds." Then, we're going to GetTag that commit with 1.4.0beta.0We'll push those commits out to GitHub, then we'll push the tags.
[01:16] Then we'll still do an npm publish, but we'll add the tag "beta." We push that up, and when that's finished, if we run npm info, we can see all the information about the versions here. We have our beta version there.
[01:34] Our latest is still pointing to the solid version of 1.3.0but our beta version, or our beta tag, is pointing to 1.4.0Now, if we change our directory to the desktop, and if I run npm install Star Wars-names, then we'll see that we install 1.3.0If I'm living on the edge and I say, "npm install Star Wars names at beta," then this will give me the 1.4.0beta. Then, obviously, I can also install the specific version 1.4.0beta.0That will allow me to install that specific version. By using the beta, we'll install the latest beta tagged version.
[02:28] That is how you release a beta version. When we're ready to go with the next version, we simply remove this beta, and we publish the new version without the tag, and we're good to go.
[02:41] In review, to publish a beta version, you simply make all the changes that you would for a regular release, whatever it is that you want to release in the beta version.
[02:49] Then instead of a simple version bump, you do the normal version bump that you would, in our case, we bumped the minor version, because it's a new feature. Then you add the -beta.0This is what you will increment as you iterate on your beta versions.
[03:08] Then, you commit your changes, you add a tag with the same version, and then you push those up to GitHub, and then you run npm publish--tag, and then beta. That will push it with the beta tag.
[03:25] Then, when users install, if they aren't aware of your beta versions, or they don't want it, they simply get the latest stable version. Then, users can install the beta version if they so desire.