I'm using semantic-release to auto find out the next version based on the git commit. It's working fine with creating new version, upload to npm and create new git tag. And semantic-release is executed whenever code is merged to master.
However, in Node.js or front-end project, usually we have a file named package.json. In this file, there is also a version number. My problem is that the version in package.json is not updated, which may conflicts with the latest version number on npm. This is said to be done using semantic-relase/git plugin, however, I'm still confused.
So I wonder what is the best practice?
After code is merged to master, run
semantic-release/gitto push a version update commit. However, GitLab stopped me because master is a protected branch and it forbids all direct pushes. I also think that it's not right to direct push.When merged to master, run
semantic-releaseto find out next version. Then checkout another branch (maybe called feat_version), update the version and push to feat_version branch, then trigger merge request to master (without approval need). However, this method is a bit complicated and I'm not sure if it can be done in GitLab CI/CD pipeline.