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
gitworkflow, you have to download all references and not just theHEADbranch. We do this by adding thefetch-depthparameter to the checkout action and setting it to0:- uses: actions/checkout@v4 with: fetch-depth: 0
- Set up
GitVersionin a specific version:- name: Install GitVersion uses: gittools/actions/gitversion/setup@v0.10.2 with: versionSpec: '5.x'
- Execute
GitVersionto determine the version number:- name: Determine Version...