-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(GitHub workflow): add changelog.md file generation and automatic v…
…ersion bumping Add changelog.md file generation and automatic version bumping on push to GitHub.
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[tool.commitizen] | ||
version = "0.0.1" | ||
template = ".github/templates/CHANGELOG.md.j2" | ||
name = "cz_customize" | ||
|
||
[tool.commitizen.customize] | ||
message_template = "{{change_type}}{% if scope %}({{scope}}){% endif %}: {{subject}}{% if ticket_no %} ({{ticket_no}}){% endif %}{% if body %}\n\n{{body}}{% endif %}" | ||
bump_pattern = "^((BREAKING[\\-\\ ]CHANGE|\\w+)(\\(.+\\))?!?):" | ||
bump_map = { "^.+!$" = "MAJOR", "^BREAKING[\\- ]CHANGE" = "MAJOR", "^feat" = "MINOR", "^fix" = "PATCH", ci = "PATCH", build = "PATCH", "^refactor" = "PATCH", "^perf" = "PATCH" } | ||
|
||
schema = "<type>: <body>" | ||
schema_pattern = "^(build|ci|docs|feat|fix|perf|refactor|style|test|revert)(\\(\\w+\\))?: [\\w -.]+(\\((#)-[0-9]+\\))?(\\[skip ci\\](.|\\n)*)?$" | ||
|
||
commit_parser = "^(?P<change_type>build|ci|docs|feat|fix|perf|refactor|style|test|revert|BREAKING CHANGE)(?:\\((?P<scope>[^)]+)\\))?:?\\s(?P<message>.*)?" | ||
|
||
changelog_pattern = "^(build|ci|docs|feat|fix|perf|refactor|style|test|revert)?(!)?" | ||
change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf", "style", "test", "build", "ci"] | ||
change_type_map = {"build" = "Build process", "ci" = "Continuous integration/delivery", "feat" = "New Features", "fix" = "Bug fixes", "style" = "Code style changes", "refactor" = "Refactored", "test" = "Tests" } | ||
|
||
[[tool.commitizen.customize.questions]] | ||
type = "list" | ||
name = "change_type" | ||
choices = [ | ||
{value = "fix", name = "fix: A bug fix. Correlates with PATCH in SemVer"}, | ||
{value = "feat", name = "feat: A new feature. Correlates with MINOR in SemVer"}, | ||
{value = "docs", name = "docs: Documentation only changes"}, | ||
{value = "style", name = "style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)"}, | ||
{value = "refactor", name = "refactor: A code change that neither fixes a bug nor adds a feature"}, | ||
{value = "perf", name = "perf: A code change that improves performance"}, | ||
{value = "test", name = "test: Adding missing or correcting existing tests"}, | ||
{value = "build", name = "build: Changes that affect the build system or external dependencies (example scopes: pip, docker, npm)"}, | ||
{value = "ci", name = "ci: Changes to our CI configuration files and scripts (example scopes: Jenkins, Docker)"}, | ||
{value = "BREAKING CHANGE", name = "BREAKING: A major change."} | ||
] | ||
message = "Select the type of change you are committing" | ||
|
||
[[tool.commitizen.customize.questions]] | ||
type = "input" | ||
name = "scope" | ||
message = "What is the scope of this change? (class or file name): (press [enter] to skip)\n" | ||
|
||
[[tool.commitizen.customize.questions]] | ||
type = "input" | ||
name = "subject" | ||
message = "Write a short and imperative summary of the code changes: (lower case and no period)\n" | ||
|
||
[[tool.commitizen.customize.questions]] | ||
type = "input" | ||
name = "body" | ||
message = "Provide additional contextual information about the code changes: (press [enter] to skip)\n" | ||
|
||
[[tool.commitizen.customize.questions]] | ||
type = "input" | ||
name = "ticket_no" | ||
message = "Ticket number i.e: #7 (Keep empty if no ticket)\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% for entry in tree %} | ||
|
||
## {{ entry.version }}{% if entry.date %} ({{ entry.date }}){% endif %} | ||
|
||
{% for change_key, changes in entry.changes.items() %} | ||
|
||
{% if change_key %} | ||
### {{ change_key }} | ||
{% endif %} | ||
|
||
{% for change in changes %} | ||
{% set message_parts = change.message.split('#') %} | ||
{% set issue = message_parts[1] %} | ||
{% set subject = message_parts[0] %} | ||
{% set issue_link = "[#" + issue + "](https://github.com/renedekat/salary-match/issues/" + issue + ") " if issue else "" %} | ||
{% set commit_link = "[" + change.sha1[:7] + "](" + change.sha1 + ")" %} | ||
{% set scope = "**" + change.scope + "**: " if change.scope else "" %} | ||
- {{ commit_link }} - {{ scope }} {{subject }} (*by [{{ change.author }}](mailto:{{ change.author_email }}))* | ||
{% if issue_link %} | ||
- Fixes issue {{ issue_link }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Bump version | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
bump-version: | ||
if: "!startsWith(github.event.head_commit.message, 'bump:')" | ||
runs-on: ubuntu-latest | ||
name: "Bump version and generate changelog with commitizen" | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" | ||
- name: Create bump and changelog | ||
uses: commitizen-tools/commitizen-action@master | ||
with: | ||
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
changelog_increment_filename: body.md | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
body_path: "body.md" | ||
tag_name: ${{ env.REVISION }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |