Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support conventional commits #31

Merged
merged 8 commits into from
Apr 23, 2024
Merged

Conversation

DanielAtanasovski
Copy link
Contributor

Adds a new action input conventional_commits, that when enabled, will parse the HEAD commit for keywords that will influence the increment type (patch, minor, major).

Only supports the keywords feat: and fix: as well as their scoped (feat(some-scope):) and breaking change (feat!:) variations.

Also supports BREAKING CHANGE: in the body of the commit for a major increment.

These are defaults outlined in the spec. Adding further commit types is a simple as adding another regular expression into the regex array.

Resolves #28

action.yml Outdated
@@ -30,13 +30,23 @@ inputs:
description: 'Use the GitHub API to discover current tags, which avoids the need for a git checkout, but requires `curl` and `jq`'
required: false
default: false
conventional_commits:
description: |
Will parse the last commit message to determine the increment type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be noted that it can't be used in conjunction with calver

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to have this as part of the scheme? so that the scheme options become: semver, calver, conventional_commits

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or potentially as part of the increment input? so that its options become major, minor, patch, commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of it being a different scheme.

Avoids it being in conflict calver for free.

shared.sh Outdated
echo "🛑 Value of 'conventional_commits' is not valid, choose from 'false' or 'true'" 1>&2
input_errors='true'
fi


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional safety check for calver + conventional_commits = true ?

@DanielAtanasovski DanielAtanasovski force-pushed the feature/support-conventional-commits branch from 680fdb0 to a449b75 Compare March 20, 2024 04:41
action.yml Outdated
Comment on lines 14 to 18
`conventional_commits` Will parse the last commit message to determine the increment type.
Supports the following increment types:
- patch (build, chore, ci, docs, fix, perf, refactor, revert, style, test)
- minor (feat)
- Major (any of the above types with an '!' or 'BREAKING CHANGE:' in commit body)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting ... it only parses the last commit 🤔

This means the consumer of this action have to ensure to remember to have to correct keyword in the merge commit (if using merge commits)

I wonder how other tooling does this? e.g. https://semantic-release.gitbook.io/semantic-release

I wonder if this action should parse every commit between "this" commit, and the "current version" tag commit ?

--

I realised the above, because I wanted to rewrite this description to be:

Suggested change
`conventional_commits` Will parse the last commit message to determine the increment type.
Supports the following increment types:
- patch (build, chore, ci, docs, fix, perf, refactor, revert, style, test)
- minor (feat)
- Major (any of the above types with an '!' or 'BREAKING CHANGE:' in commit body)
`conventional_commits` will parse the commit messages to determine the increment digit for a `semver` version (and implies `semver` scheme)
Supports the following increment types:
- patch (build, chore, ci, docs, fix, perf, refactor, revert, style, test)
- minor (feat)
- major (any of the above types with an '!' or 'BREAKING CHANGE:' in commit body)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... guess this isn't as straight forward 😅

Either this would imply that merge commits would have to follow the same convention to correctly increment the version.

Or like you said, parse every commit since the last version and work out what increment type the version to jump to. That sounds more 'right' to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harder to do in bash though 😞

ps-jay
ps-jay previously approved these changes Apr 23, 2024
Copy link
Member

@ps-jay ps-jay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the idea @XenoSnowFox
Thanks for the inplementation @DanielAtanasovski

@ps-jay ps-jay enabled auto-merge April 23, 2024 07:37
@ps-jay ps-jay merged commit ae1ae19 into main Apr 23, 2024
5 checks passed
@ps-jay ps-jay deleted the feature/support-conventional-commits branch April 23, 2024 07:41
cgrindel-self-hosted-renovate bot referenced this pull request in cgrindel/renovate-bot Apr 23, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[reecetech/version-increment](https://togithub.com/reecetech/version-increment)
| action | major | `2023.10.2` -> `2024.4.1` |

---

### Release Notes

<details>
<summary>reecetech/version-increment
(reecetech/version-increment)</summary>

###
[`v2024.4.1`](https://togithub.com/reecetech/version-increment/releases/tag/2024.4.1)

[Compare
Source](https://togithub.com/reecetech/version-increment/compare/2023.10.2...2024.4.1)

#### What's Changed

- Support conventional commits by
[@&#8203;DanielAtanasovski](https://togithub.com/DanielAtanasovski) in
[https://github.com/reecetech/version-increment/pull/31](https://togithub.com/reecetech/version-increment/pull/31)

#### New Contributors

- [@&#8203;DanielAtanasovski](https://togithub.com/DanielAtanasovski)
made their first contribution in
[https://github.com/reecetech/version-increment/pull/31](https://togithub.com/reecetech/version-increment/pull/31)

**Full Changelog**:
reecetech/version-increment@2023.10.2...2024.4.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDkuNCIsInVwZGF0ZWRJblZlciI6IjM2LjEwOS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement "Conventional Commits" support
4 participants