Skip to content

sqaisar/commitizen-action

Repository files navigation

commitizen-action

Add commitizen incredibly fast into your project!

Features

  • Allow prerelease
  • Super easy to setup
  • Automatically bump version
  • Automatically create changelog
  • Update any file in your repo with the new version

Are you using conventional commits and semver?

Then you are ready to use this github action! The only thing you'll need is the .cz.toml file in your project.

Usage

  1. In your repository create a .cz.toml file (you can run cz init to create it)
  2. Create a .github/workflows/bumpversion.yaml with the Sample Workflow

Minimal configuration

Your .cz.toml (or pyproject.toml if you are using python) should look like this.

[tool.commitizen] version = "0.1.0"# This should be your current semver version

For more information visit commitizen's configuration page

Sample Workflow

name: Bump versionon: push: branches: - masterjobs: bump_version: if: "!startsWith(github.event.head_commit.message, 'bump:')"runs-on: ubuntu-latestname: "Bump version and create changelog with commitizen"steps: - name: Check outuses: actions/checkout@v2with: fetch-depth: 0token: "${{secrets.GITHUB_TOKEN }}" - id: czname: Create bump and changeloguses: commitizen-tools/commitizen-action@masterwith: github_token: ${{secrets.GITHUB_TOKEN }} - name: Print Versionrun: echo "Bumped to version ${{steps.cz.outputs.version }}"

Variables

NameDescriptionDefault
github_tokenToken for the repo. Can be passed in using ${{secrets.GITHUB_TOKEN }}required-
dry_runRun without creating commit, output to stdoutfalse
repositoryRepository name to push. Default or empty value represents current github repositorycurrent one
branchDestination branch to push changesSame as the one executing the action by default
prereleaseSet as prerelease{alpha,beta,rc} choose type of prerelease-
extra_requirementsCustom requirements, if your project uses a custom rule or plugins, you can specify them separated by a space. E.g: 'commitizen-emoji conventional-JIRA'-
changelog_increment_filenameFilename to store the incremented generated changelog. This is different to changelog as it only contains the changes for the just generated version. Example: body.md-
git_nameName used to configure git (for git operations)github-actions[bot]
git_emailEmail address used to configure git (for git operations)github-actions[bot]@users.noreply.github.com
pushDefine if the changes should be pushed to the branch.true
mergeDefine if the changes should be pushed even on the pull_request event, immediately merging the pull request.false
commitDefine if the changes should be committed to the branch.true
commitizen_versionSpecify the version to be used by commitizen. Eg: `2.21.latest
changelogCreate changelog when bumping the versiontrue
no_raiseDon't raise the given comma-delimited exit codes (e.g., no_raise: '20,21'). Use with caution! Open an issue in commitizen if you need help thinking about your workflow.21
incrementManually specify the desired increment{MAJOR,MINOR,PATCH}-

Outputs

NameDescription
versionThe new version

Additionally, the new version is also available as an environment variable under REVISION.

Troubleshooting

Other actions are not triggered when the tag is pushed

This problem occurs because secrets.GITHUB_TOKEN do not trigger other actions by design.

To solve it, you must use a personal access token in the checkout and the commitizen steps.

Follow the instructions in commitizen's documentation

I'm not using conventional commits, I'm using my own set of rules on commits

If your rules can be parsed, then you can build your own commitizen rules, create a new commitizen python package, or you can describe it on the toml config itself.

Read more about customization

About

Commitizen github action to bump and create changelog

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell97.0%
  • Dockerfile3.0%