fix semantic-release always push a new major version

Symptom: semantic-release always bump a new major version

The way semantic-release determines a new version is basing on analyzeCommits

But it is based on the commits between last release to this release.

To locate last release, it relies on getLastRelease.

And getLastRelease relies on gitHead

So if gitHead is not set properly in package.json, semantic-release will determine the version base on commits between the very first one to the current one. And most likely, it would find a commit with Breaking Changes, which will trigger a new major version.

There are several situations will lead to missing gitHead in package.json.

The case I have is deploy a package that is not directly under project root.

1
npm publish ./dist

The above code will confuse npm.

Therefore, use npmignore or files field to trim your project instead of copying files to dist folder.