0.0.0-development • Published 1 year ago

@sofair-official/semantic-release-squash v0.0.0-development

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Semantic-release running with squashed commits

Original semantic-release is a very powerful tool to operate semantic release. It automates the whole package release workflow including: determining the next version number, generating the release notes, and publishing the package. This fork is largely based on the original project.

As we are using squash-and-merge strategy to keep a clean and lean history, we have to develop a tweak to read the message of squashed commits. Our strategy is as follows :

  • Creating a new branch to operate change. The branch name will be the message of the squashed commits.
  • Do some commits on this branch (named inner commit) with valid conventionnal commit message.
  • Create a pull request (PR) with a valid name like: Issue to solve (#3) where the number 3 is the number of the PR.
  • Squash-and-merge the PR with the valid name.

How it works

The GitHub API is used to retrieve the inner commit message and to proceed the versioning on.

The table below shows which commit message gets you which release type when semantic-release-squash runs (using our configuration):

Commit messageRelease type
fix(pencil): stop graphite breaking when too much pressure appliedPatch
feat(pencil): add 'graphiteWidth' optionMinor
break(pencil): remove graphiteWidth optionMajor

View of a squashed PR with inner commits

Alt text

What has been modified

Some changes have been done in order to analyze inner commit's message. Here are the files that have been modified :

  • Create the new file lib/github.js to introduce getInnerSquashedCommits and getPullRequestNumber.
  • Modify the lib/get-commit.js to introduce an option in order to use getInnerSquashedCommits on demand.
  • Modify the cli.js to introduce the option with the flag -s or --squashMerge.
  • Create the new file test/github.test.js to proceed the test on the new part.
  • Create the new file test/helpers/github-utils.js to introduce cloneRemoteSquashMergeRepo.
  • update the package.json file.

How to use

The analyze of inner commit's message is done by passing the option -s or --squashMerge to semantic-release-squash :

for example ./semantic-release-squash --squashMerge --debug

The message of the squashed commits must be formed as :

Issue to solve (#3) with 3 the number of the PR.

And inner commit's message must be formed as :

feat(scope): inner commit's message or feat: inner commit's message To learn more about commit's message, the contributo's bible is here to help you.

If the message is malformed, even on the squashed or inner commit, the tool will ignored them.

Feel free to fork this repository and to submit issue.