semantic-release breaking-change using ! (exclamation mark)

3.5k Views Asked by At

Can Major version changes (aka Breaking Changes) be handled in semantic-release using the exclamation mark?

git commit -m 'feat!: this is breaking, but is not recognized by semantic-release'

Conventional Commit guidelines show that breaking changes can be labeled in the footer in using an exclamation mark in the header.

enter image description here

This is the workflow that I have been testing

Setup repository ✓

git init
git remote add origin [email protected]:klueless-io/k_genesis.git
git branch -M main
git add .
git commit -am 'first commit'
# Artificial starting version number
git tag v0.0.18 -a -m 'k_genesis initialize repository'
git push -u origin main --tags
git hist

enter image description here

Remove a single file and call it a new feature ✓

rm a1
git add .
git commit -m 'feat: remove a1'
git hist

enter image description here

npx semantic-release --no-ci

enter image description here

git hist

enter image description here

Now Breaking Change using Footer Message ✓

This does not work as expected

rm a2
git add .
git commit -m 'feat: removed a2   

BREAKING CHANGE: break dancing
'
git hist

enter image description here

npx semantic-release --no-ci

enter image description here

Looking Good So Far ✓

enter image description here

Now try a breaking change using ! exclamation mark ✗ :( :( :(

rm a3
git add .
git commit -m 'feat!: removed a3 with exclamation in header'   

enter image description here

npx semantic-release --no-ci
# Analysis of 1 commits complete: no release

enter image description here

git hist

enter image description here

touch xmen
git add .
git commit -m 'feat: normal feat'
npx semantic-release --no-ci
git hist

enter image description here

Attempted custom configurations

I have used the default preset for "@semantic-release/commit-analyzer" (angular) and I have tried a custom preset (conventionalcommits)

my .releaserc

{
  "branches": [
    "main"
  ],
  "plugins": [
    "@semantic-release/commit-analyzer", {
      "preset": "conventionalcommits"
    }
  ]
}

Looking a the source code

When I looked at the source code conventional-changelog-conventionalcommits it seamed like breaking change in header should be supported.

enter image description here

1

There are 1 best solutions below

1
On

You need to manually configure it in .releaserc:

YAML

branches:
  - main
plugins:
  - - "@semantic-release/commit-analyzer"
    - preset: conventionalcommits
      releaseRules:
        - type: '*!'
          release: major

JSON

{
  "branches": [
    "main"
  ],
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "conventionalcommits",
        "releaseRules": [
          {
            "type": "*!",
            "release": "major"
          }
        ]
      }
    ]
  ]
}