Warning! Prereleases are very complicated! Using them requires a thorough understanding of all parts of npm publishes. Mistakes can lead to repository and publish states that are very hard to fix.
To fix that problem we use changeset and GitHub Actions.
A prerelease workflow might look something like this:
Checkout to the beta
branch and merge your branch to beta
to include your changes in the prerelease.
git checkout beta
git merge <your branch> // recomended to use develep branch
Enter the prerelease versioning mode:
# this will add a `beta` tag so your versions will look like `5.1.0-beta.0`
yarn changeset pre enter beta
Generate an .md
file that describes the changes:
yarn changeset
Update package.json
files with the new prerelease version:
yarn changeset version
Commit the changes:
git add .
git commit -m "Version packages"
git push
This will trigger a GitHub Action that will publish the prerelease packages to npm.
Warning! After you have finished with publishing, delete the
pre.json
file and all the.md
files in the.changeset
directory generated by theyarn changeset
command.
Warning! The difference in Changesets configuration between the
beta
&master
branches is that thebeta
branch has apre.json
file in the.changeset
directory which stores information about the state of the prerelease is in.
So it is essential to not delete or make any manual modification to thepre.json
file so the release does not end in production by mistake.
Open PR with destination to master
branch and run:
Generate an .md
file that describes the changes. These files will be used to create a PR by the changeset github action hook:
yarn changeset
Commit the changes:
git add .
git commit -m "Version packages"
git push