Versioning your packages
If you now created a new release, the workflow would fail as it would try to publish version 1.0.0 again to the package registry. You would manually have to set the version number in the package.json
file. In this recipe, we will use GitVersion to automate this process.
Getting ready
Switch to a new branch:
$ git switch -c add-gitversion
How to do it…
- For GitVersion to automatically determine the version of your
git
workflow, you have to download all references and not just theHEAD
branch. We do this by adding thefetch-depth
parameter to the checkout action and setting it to0
:- uses: actions/checkout@v4 with: fetch-depth: 0
- Set up
GitVersion
in a specific version:- name: Install GitVersion uses: gittools/actions/gitversion/setup@v0.10.2 with: versionSpec: '5.x'
- Execute
GitVersion
to determine the version number:- name: Determine Version...