semantic-release breaking-change using ! (exclamation mark)
Asked Answered
H

1

13

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

Historic answered 20/1, 2022 at 5:33 Comment(1)
This has recently stopped working for me as well. I have the following config, this used to work: const parserOpts = { noteKeywords: ['BREAKING-CHANGE', 'BREAKING CHANGE', 'BREAKING CHANGES'], headerPattern: /^(\w*)(?:(([\w\$\.\-* ]*)))?!?: (.*)$/, breakingHeaderPattern: /^(\w*)(?:((.*)))?!: (.*)$/, };Witting
D
2

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"
          }
        ]
      }
    ]
  ]
}
Determinate answered 11/7, 2022 at 12:55 Comment(1)
["@semantic-release/commit-analyzer", { "preset": "conventionalcommits" }]] should be enough as the exclamation mark is already configured in the preset, no?Boak

© 2022 - 2024 — McMap. All rights reserved.