amannn / action-semantic-pull-request

A GitHub Action that ensures that your PR title matches the Conventional Commits spec
MIT License
945 stars 120 forks source link

Can't add a custom prefix that has space in it e.g `BREAKING CHANGE` #257

Open pof-jhansilva opened 7 months ago

pof-jhansilva commented 7 months ago

Is your feature request related to a problem? Please describe.

Hey, so we are using semantic-release to create our Github Releases using the following prefix table

image

I wanted to add BREAKING CHANGE: as a valid prefix because semantic-release uses it to create major/breaking releases but when I try it it just errors out.

Example of configuration:

- name: Validate semantic title 🔡
        uses: amannn/action-semantic-pull-request@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          types: |
            fix
            feat
            perf
            BREAKING CHANGE

But even after adding that it still errors out with:

Error: No release type found in pull request title "BREAKING CHANGE". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - fix
 - feat
 - perf
 - BREAKING CHANGE

Describe the solution you'd like

Be able to add BREAKING CHANGE as an acceptable prefix so we can use it together with this action

Describe alternatives you've considered

Using perf prefix that is accepted by the conventionalcommits but sometimes this doesn't reflect the type of change that we are introducing.

amannn commented 7 months ago

Hmm, interesting. If you'd be interested in analyzing this and potentially setting up a PR, I'd be happy to review it. The only thing we document is that the types need to be newline-delimited:

          # Configure which types are allowed (newline-delimited).
          # Default: https://github.com/commitizen/conventional-commit-types
          types: |
            fix
            feat

This is the corresponding parsing logic:

https://github.com/amannn/action-semantic-pull-request/blob/67cbd7a15a6eeea0c3a0dffff4768fa5653de05c/src/ConfigParser.js#L1-L9

As an alternative, you can use the exclamation mark syntax that is used by Conventional Commits to indicate breaking changes (see the readme).

lwhiteley commented 2 weeks ago

isnt the BREAKING CHANGE prefix suppose to be in the body/description of the PR?

according to conventional commits, a subject line specifies a breaking change by using !

for eg:

chore!: change behaviour of xyz

OR

feat(api)!: send an email to the customer when a product is shipped

Ref:

BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.

https://www.conventionalcommits.org/en/v1.0.0/#summary

pof-jhansilva commented 2 weeks ago

Yes, @lwhiteley I think the issue is still valid because this tool won't accept anything that have space as a valid semantic PR title (Even if you customize them to be what you want).

At the end we where able to workaround this issue by doing a feat: but adding BREAKING CHANGE to the commit footer