├── .cz.toml ├── Dockerfile ├── .github └── workflows │ ├── update_semver.yml │ ├── bumpversion.yaml │ └── test_action.yml ├── LICENSE ├── .gitignore ├── action.yml ├── entrypoint.sh ├── CHANGELOG.md └── README.md /.cz.toml: -------------------------------------------------------------------------------- 1 | [tool.commitizen] 2 | name = "cz_conventional_commits" 3 | version = "0.26.0" 4 | format = "v$version" 5 | update_changelog_on_bump = true 6 | major_version_zero = true 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.10-alpine 2 | 3 | RUN set -eux; \ 4 | apk add --no-cache \ 5 | git \ 6 | git-lfs \ 7 | gpg \ 8 | gpg-agent \ 9 | alpine-sdk \ 10 | bash \ 11 | libffi-dev \ 12 | ; \ 13 | git lfs install; 14 | COPY entrypoint.sh /entrypoint.sh 15 | ENTRYPOINT ["/entrypoint.sh"] 16 | -------------------------------------------------------------------------------- /.github/workflows/update_semver.yml: -------------------------------------------------------------------------------- 1 | name: Update Major Minor Tags 2 | 3 | on: 4 | push: 5 | branches-ignore: 6 | - "**" 7 | tags: 8 | - "*.*.*" 9 | workflow_dispatch: 10 | 11 | jobs: 12 | update_major_minor_tags: 13 | name: Make sure major and minor tags are up to date on a patch release 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | - name: Run Update semver 19 | uses: haya14busa/action-update-semver@v1 20 | -------------------------------------------------------------------------------- /.github/workflows/bumpversion.yaml: -------------------------------------------------------------------------------- 1 | name: Bump version 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | bump_version: 10 | runs-on: ubuntu-latest 11 | name: 'Bump version and create changelog with commitizen' 12 | steps: 13 | - name: Check out 14 | uses: actions/checkout@v2 15 | with: 16 | fetch-depth: 0 17 | - name: Create bump and changelog 18 | uses: commitizen-tools/commitizen-action@master 19 | with: 20 | github_token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" 21 | changelog_increment_filename: body.md 22 | - name: Release 23 | uses: softprops/action-gh-release@v1 24 | with: 25 | body_path: "body.md" 26 | tag_name: "${{ env.REVISION }}" 27 | env: 28 | GITHUB_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Santiago 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /.github/workflows/test_action.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | types: 4 | - opened 5 | - synchronize 6 | 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v5 12 | with: 13 | ref: "${{ github.event.pull_request.head.ref }}" 14 | repository: "${{ github.event.pull_request.head.repo.full_name }}" 15 | fetch-depth: 0 # ensures that tags are fetched, seems to be needed 16 | - name: Capture commit id 17 | id: capture 18 | run: | 19 | COMMIT_ID="$(git rev-parse "${{ github.head_ref }}")" 20 | echo "The sha of the starting commit is $COMMIT_ID" 21 | echo "SHA=$COMMIT_ID" >>"$GITHUB_OUTPUT" 22 | - name: create test commit 23 | run: | 24 | touch test_file 25 | git config --global user.email "you@example.com" 26 | git config --global user.name "Your Name" 27 | git add test_file 28 | git commit -m "feat: test feature" 29 | - name: test action 30 | uses: ./ 31 | id: cz 32 | with: 33 | github_token: "${{ secrets.GITHUB_TOKEN }}" 34 | commit: false 35 | push: false 36 | - name: check outputs 37 | run: | 38 | echo "version: ${{ steps.cz.outputs.version }}" 39 | echo "next_version: ${{ steps.cz.outputs.next_version }}" 40 | echo "next_version_major: ${{ steps.cz.outputs.next_version_major }}" 41 | echo "next_version_minor: ${{ steps.cz.outputs.next_version_minor }}" 42 | echo "previous_version: ${{ steps.cz.outputs.previous_version }}" 43 | echo "previous_version_major: ${{ steps.cz.outputs.previous_version_major }}" 44 | echo "previous_version_minor: ${{ steps.cz.outputs.previous_version_minor }}" 45 | - uses: actions/checkout@v5 46 | with: 47 | ref: "${{ github.event.pull_request.head.ref }}" 48 | repository: "${{ github.event.pull_request.head.repo.full_name }}" 49 | fetch-depth: 0 # ensures that tags are fetched, seems to be needed 50 | path: new_head 51 | - name: Test push 52 | run: | 53 | cd new_head 54 | last_pushed_commit="$(git rev-parse "${{ github.head_ref }}")" 55 | echo "Commit sha on origin: $last_pushed_commit" 56 | if [[ $last_pushed_commit != ${{ steps.capture.outputs.SHA }} ]]; then 57 | echo "Something got pushed to ${{ github.head_ref }}" 58 | exit 1 59 | fi 60 | - name: Test commit 61 | run: | 62 | commit_message="$(git log -1 HEAD --pretty=format:%s)" 63 | echo "Latest commit: $commit_message" 64 | if [[ $commit_message != "feat: test feature" ]]; then 65 | echo "The latest commit message is not 'feat: test feature'" 66 | exit 1 67 | fi 68 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Bump and changelog using commitizen" 2 | description: "Create a commit bumping the version of your project and creating a changelog file" 3 | runs: 4 | using: "docker" 5 | image: "Dockerfile" 6 | branding: 7 | icon: "git-commit" 8 | color: "purple" 9 | outputs: 10 | version: # old classic next_version 11 | description: "New version" 12 | next_version: 13 | description: "Next version" 14 | next_version_major: 15 | description: "Only the major version of the next version" 16 | next_version_minor: 17 | description: "Only the minor version of the next version" 18 | previous_version: 19 | description: "Version before the bump" 20 | previous_version_major: 21 | description: "Only the major version of the previous version" 22 | previous_version_minor: 23 | description: "Only the minor version of the previous version" 24 | inputs: 25 | working_directory: 26 | description: "Change to this directory before running" 27 | required: false 28 | dry_run: 29 | description: "Run without creating commit, output to stdout" 30 | required: false 31 | commit: 32 | description: "If true a commit is created containing the bump changes" 33 | required: false 34 | default: "true" 35 | push: 36 | description: "If true the bump commit is pushed to the remote repository" 37 | required: false 38 | default: "true" 39 | merge: 40 | description: > 41 | If true, the bump commit is pushed to the remote repository even when the 42 | action is run on the pull_request event, immediately merging the pull request 43 | required: false 44 | default: "false" 45 | prerelease: 46 | description: "Set as prerelease version" 47 | required: false 48 | devrelease: 49 | description: "Non-negative integer for dev. release" 50 | required: false 51 | local_version: 52 | description: "Bump only the local version portion" 53 | required: false 54 | default: "false" 55 | changelog: 56 | description: "Create changelog when bumping the version" 57 | default: "true" 58 | required: false 59 | github_token: 60 | description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}' 61 | required: false 62 | repository: 63 | description: "Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})" 64 | default: "" 65 | required: false 66 | branch: 67 | description: "Destination branch to push changes" 68 | required: false 69 | default: "" 70 | extra_requirements: 71 | description: "Extra commitizen dependencies like your custom plugins or rules" 72 | required: false 73 | default: "" 74 | changelog_increment_filename: 75 | description: "Filename to store the incremented generated changelog. This is different to changelog as it only contains the changes for the just generated version" 76 | required: false 77 | git_redirect_stderr: 78 | description: "Redirect git output to stderr. Useful if you do not want git output in your changelog" 79 | required: false 80 | default: "false" 81 | git_name: 82 | description: "Name used to configure git (for git operations)" 83 | required: false 84 | default: "github-actions[bot]" 85 | git_email: 86 | description: "Email address used to configure git (for git operations)" 87 | required: false 88 | default: "github-actions[bot]@users.noreply.github.com" 89 | commitizen_version: 90 | description: "Specify the version to be used by commitizen" 91 | required: false 92 | default: latest 93 | no_raise: 94 | description: "Don't raise the given comma-delimited exit codes" 95 | required: false 96 | default: "21" 97 | increment: 98 | description: "Manually specify the desired increment" 99 | required: false 100 | check_consistency: 101 | default: "false" 102 | description: "check consistency among versions defined in commitizen configuration and version_files" 103 | required: false 104 | gpg_sign: 105 | description: > 106 | If true, use GPG to sign commits and tags (for git operations). Requires separate 107 | setup of GPG key and passphrase in GitHub Actions (e.g. with the action 108 | crazy-max/ghaction-import-gpg) 109 | required: false 110 | default: "false" 111 | debug: 112 | description: "If true, prints debug output to GitHub Actions stdout." 113 | required: false 114 | default: "false" 115 | actor: 116 | description: "The account that will be used to perform git operations, defaults to the GITHUB_ACTOR" 117 | required: false 118 | manual_version: 119 | description: "Manually specify the version to bump to" 120 | required: false 121 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Reporting 6 | gpg --version 7 | git --version 8 | 9 | if [[ -z $INPUT_GITHUB_TOKEN && $INPUT_PUSH == "true" ]]; then 10 | echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}" which is required to push.' >&2 11 | exit 1 12 | fi 13 | 14 | echo "Configuring Git username, email, and pull behavior..." 15 | 16 | # Fix #56 17 | git config --global --add safe.directory "*" 18 | 19 | git config --local user.name "${INPUT_GIT_NAME}" 20 | git config --local user.email "${INPUT_GIT_EMAIL}" 21 | git config --local pull.rebase true 22 | echo "Git name: $(git config --get user.name)" 23 | echo "Git email: $(git config --get user.email)" 24 | 25 | PIP_CMD=('pip' 'install') 26 | if [[ $INPUT_COMMITIZEN_VERSION == 'latest' ]]; then 27 | PIP_CMD+=('commitizen') 28 | else 29 | PIP_CMD+=("commitizen==${INPUT_COMMITIZEN_VERSION}") 30 | fi 31 | IFS=" " read -r -a INPUT_EXTRA_REQUIREMENTS <<<"$INPUT_EXTRA_REQUIREMENTS" 32 | PIP_CMD+=("${INPUT_EXTRA_REQUIREMENTS[@]}") 33 | echo "${PIP_CMD[@]}" 34 | "${PIP_CMD[@]}" 35 | echo "Commitizen version: $(cz version)" 36 | 37 | if [[ $INPUT_WORKING_DIRECTORY ]]; then 38 | cd $INPUT_WORKING_DIRECTORY 39 | fi 40 | 41 | PREV_REV="$(cz version --project)" 42 | echo "PREVIOUS_REVISION=${PREV_REV}" >>"$GITHUB_ENV" 43 | echo "previous_version=${PREV_REV}" >>"$GITHUB_OUTPUT" 44 | 45 | PREV_REV_MAJOR="$(cz version --project --major)" 46 | echo "PREVIOUS_REVISION_MAJOR=${PREV_REV_MAJOR}" >>"$GITHUB_ENV" 47 | echo "previous_version_major=${PREV_REV_MAJOR}" >>"$GITHUB_OUTPUT" 48 | PREV_REV_MINOR="$(cz version --project --minor)" 49 | echo "PREVIOUS_REVISION_MINOR=${PREV_REV_MINOR}" >>"$GITHUB_ENV" 50 | echo "previous_version_minor=${PREV_REV_MINOR}" >>"$GITHUB_OUTPUT" 51 | 52 | 53 | CZ_CMD=('cz') 54 | if [[ $INPUT_DEBUG == 'true' ]]; then 55 | CZ_CMD+=('--debug') 56 | fi 57 | if [[ $INPUT_NO_RAISE ]]; then 58 | CZ_CMD+=('--no-raise' "$INPUT_NO_RAISE") 59 | fi 60 | CZ_CMD+=('bump' '--yes') 61 | if [[ $INPUT_GPG_SIGN == 'true' ]]; then 62 | CZ_CMD+=('--gpg-sign') 63 | fi 64 | if [[ $INPUT_DRY_RUN == 'true' ]]; then 65 | CZ_CMD+=('--dry-run') 66 | fi 67 | if [[ $INPUT_CHANGELOG == 'true' ]]; then 68 | CZ_CMD+=('--changelog') 69 | fi 70 | if [[ $INPUT_PRERELEASE ]]; then 71 | CZ_CMD+=('--prerelease' "$INPUT_PRERELEASE") 72 | fi 73 | if [[ $INPUT_DEVRELEASE ]]; then 74 | CZ_CMD+=('--devrelease' "$INPUT_DEVRELEASE") 75 | fi 76 | if [[ $INPUT_LOCAL_VERSION == 'true' ]]; then 77 | CZ_CMD+=('--local-version') 78 | fi 79 | if [[ $INPUT_COMMIT == 'false' ]]; then 80 | CZ_CMD+=('--files-only') 81 | fi 82 | if [[ $INPUT_INCREMENT ]]; then 83 | CZ_CMD+=('--increment' "$INPUT_INCREMENT") 84 | fi 85 | if [[ $INPUT_CHECK_CONSISTENCY == 'true' ]]; then 86 | CZ_CMD+=('--check-consistency') 87 | fi 88 | if [[ $INPUT_GIT_REDIRECT_STDERR == 'true' ]]; then 89 | CZ_CMD+=('--git-output-to-stderr') 90 | fi 91 | if [[ $INPUT_MANUAL_VERSION ]]; then 92 | CZ_CMD+=("$INPUT_MANUAL_VERSION") 93 | fi 94 | if [[ $INPUT_CHANGELOG_INCREMENT_FILENAME ]]; then 95 | CZ_CMD+=('--changelog-to-stdout') 96 | echo "${CZ_CMD[@]}" ">$INPUT_CHANGELOG_INCREMENT_FILENAME" 97 | "${CZ_CMD[@]}" >"$INPUT_CHANGELOG_INCREMENT_FILENAME" 98 | else 99 | echo "${CZ_CMD[@]}" 100 | "${CZ_CMD[@]}" 101 | fi 102 | if [[ $INPUT_ACTOR ]]; then 103 | ACTOR=$INPUT_ACTOR 104 | else 105 | ACTOR=$GITHUB_ACTOR 106 | fi 107 | 108 | REV="$(cz version --project)" 109 | if [[ $REV == "$PREV_REV" ]]; then 110 | INPUT_PUSH='false' 111 | fi 112 | echo "REVISION=${REV}" >>"$GITHUB_ENV" 113 | echo "version=${REV}" >>"$GITHUB_OUTPUT" 114 | echo "next_version=${REV}" >>"$GITHUB_OUTPUT" 115 | 116 | NEXT_REV_MAJOR="$(cz version --project --major)" 117 | echo "NEXT_REVISION_MAJOR=${NEXT_REV_MAJOR}" >>"$GITHUB_ENV" 118 | echo "next_version_major=${REV}" >>"$GITHUB_OUTPUT" 119 | NEXT_REV_MINOR="$(cz version --project --minor)" 120 | echo "NEXT_REVISION_MINOR=${NEXT_REV_MINOR}" >>"$GITHUB_ENV" 121 | echo "next_version_minor=${REV}" >>"$GITHUB_OUTPUT" 122 | 123 | GITHUB_DOMAIN=${GITHUB_SERVER_URL#*//} 124 | CURRENT_BRANCH="$(git branch --show-current)" 125 | INPUT_BRANCH="${INPUT_BRANCH:-$CURRENT_BRANCH}" 126 | INPUT_REPOSITORY="${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}" 127 | 128 | echo "Repository: ${INPUT_REPOSITORY}" 129 | echo "Actor: ${ACTOR}" 130 | 131 | if [[ $INPUT_PUSH == 'true' ]]; then 132 | if [[ $INPUT_MERGE != 'true' && $GITHUB_EVENT_NAME == 'pull_request' ]]; then 133 | echo "Refusing to push on pull_request event since that would merge the pull request." >&2 134 | echo "You probably want to run on push to your default branch instead." >&2 135 | else 136 | echo "Pushing to branch..." 137 | REMOTE_REPO="https://${ACTOR}:${INPUT_GITHUB_TOKEN}@${GITHUB_DOMAIN}/${INPUT_REPOSITORY}.git" 138 | git pull "$REMOTE_REPO" "$INPUT_BRANCH" 139 | git push "$REMOTE_REPO" "HEAD:${INPUT_BRANCH}" --tags 140 | fi 141 | else 142 | echo "Not pushing" 143 | fi 144 | echo "Done." 145 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.26.0 (2025-11-19) 2 | 3 | ### Feat 4 | 5 | - add gpg-agent 6 | 7 | ## 0.25.0 (2025-11-16) 8 | 9 | ### BREAKING CHANGE 10 | 11 | - This update requires commitizen > 4.10 in order to use --minor and --major 12 | 13 | ### Feat 14 | 15 | - add more output information 16 | 17 | ## 0.24.0 (2025-02-25) 18 | 19 | ### Feat 20 | 21 | - add support for manual version bumping 22 | 23 | ## 0.23.1 (2024-12-21) 24 | 25 | ## 0.23.0 (2024-12-09) 26 | 27 | ### Feat 28 | 29 | - **#55**: add ACTOR input parameter 30 | 31 | ## 0.22.0 (2024-11-06) 32 | 33 | ### Feat 34 | 35 | - add working-directory input 36 | 37 | ## 0.21.0 (2024-03-05) 38 | 39 | ### Feat 40 | 41 | - add local version and devrelease as inputs (#69) 42 | - Add PREVIOUS_REVISION to environment 43 | 44 | ## 0.20.0 (2023-09-14) 45 | 46 | ### Feat 47 | 48 | - Add new option to hide git output 49 | 50 | ## 0.19.0 (2023-09-08) 51 | 52 | ## 0.18.2 (2023-05-18) 53 | 54 | ### Fix 55 | 56 | - install git-lfs into the dockerfile 57 | 58 | ## 0.18.1 (2023-03-28) 59 | 60 | ### Fix 61 | 62 | - Add support for GitHub Enterprise Server (#66) 63 | 64 | ## 0.18.0 (2023-03-03) 65 | 66 | ### BREAKING CHANGE 67 | 68 | - Remove `use_ssh`. Documentation is in place to deploy using SSH keys 69 | 70 | ### Fix 71 | 72 | - remove use_ssh flag (#65) 73 | 74 | ## 0.17.1 (2023-03-03) 75 | 76 | ### Fix 77 | 78 | - add openssh to Dockerfile 79 | 80 | ## 0.17.0 (2023-03-03) 81 | 82 | ### Feat 83 | 84 | - add support for SSH deploy keys (#64) 85 | 86 | ## 0.16.3 (2023-02-09) 87 | 88 | ### Fix 89 | 90 | - missing `libffi-dev` in `Dockerfile` which breaks third party plugins (#60) 91 | 92 | ## 0.16.2 (2023-02-06) 93 | 94 | ### Fix 95 | 96 | - change docker image version back to 3.8 (#59) 97 | 98 | ## 0.16.1 (2023-02-05) 99 | 100 | ### Fix 101 | 102 | - add safe directory to git (#57) 103 | 104 | ## 0.16.0 (2023-01-07) 105 | 106 | ### Feat 107 | 108 | - **entrypoing.sh**: add `gpg` sign 109 | - **debug**: add option for debug output 110 | 111 | ### Fix 112 | 113 | - check_consistency flag being ignored 114 | 115 | ## 0.15.1 (2022-10-18) 116 | 117 | ### Fix 118 | 119 | - Port from set-output to environment files 120 | 121 | ## 0.15.0 (2022-10-04) 122 | 123 | ### Feat 124 | 125 | - add `check-consistency` option 126 | 127 | ## 0.14.1 (2022-07-07) 128 | 129 | ### Fix 130 | 131 | - Refuse to push on pull_request event 132 | - Don't pull or push with nothing to push 133 | - Print error message to stderr 134 | 135 | ## 0.14.0 (2022-07-05) 136 | 137 | ### Fix 138 | 139 | - remove bad comma 140 | 141 | ### Feat 142 | 143 | - add increment option 144 | 145 | ## 0.13.2 (2022-05-11) 146 | 147 | ### Fix 148 | 149 | - Don't quote the > operator in entrypoint.sh 150 | - Don't quote the > operator in entrypoint.sh 151 | - Follow Bash best practices in entrypoint 152 | - Configure git pull to rebase instead of merge 153 | - Configure git pull to rebase instead of merge 154 | 155 | ### Refactor 156 | 157 | - Remove unnecessary --follow-tags 158 | - Get current Git branch more simply 159 | 160 | ## 0.13.1 (2022-05-10) 161 | 162 | ### Fix 163 | 164 | - Correct default branch from master to current 165 | 166 | ## 0.13.0 (2022-05-04) 167 | 168 | ### Feat 169 | 170 | - add no-raise option 171 | - add no-raise option 172 | 173 | ## 0.12.0 (2022-02-24) 174 | 175 | ### Feat 176 | 177 | - add commitizen version input 178 | - add commitizen version input 179 | 180 | ### Refactor 181 | 182 | - rename cz version variable 183 | 184 | ## 0.11.0 (2021-12-18) 185 | 186 | ### Feat 187 | 188 | - detect default branch 189 | - detect default branch 190 | 191 | ## 0.10.0 (2021-11-17) 192 | 193 | ### Feat 194 | 195 | - add `commit` and `push` inputs 196 | 197 | ## 0.9.0 (2021-09-14) 198 | 199 | ### Feat 200 | 201 | - add version output 202 | 203 | ## 0.8.0 (2021-08-30) 204 | 205 | ### Fix 206 | 207 | - removed id from default git_email 208 | 209 | ### Feat 210 | 211 | - support custom git config 212 | 213 | ## 0.7.0 (2021-03-08) 214 | 215 | ### Feat 216 | 217 | - add support for `--changelog-to-stdout` 218 | 219 | ### Fix 220 | 221 | - use commitizen-tool action instead of Woile's 222 | 223 | ## 0.6.0 (2021-02-06) 224 | 225 | ### Feat 226 | 227 | - add pull before pushing to avoid error with remote with new changes 228 | 229 | ## 0.5.0 (2020-12-02) 230 | 231 | ### Feat 232 | 233 | - add extra_requirements parameters instead of reading the requirements.txt file 234 | 235 | ## 0.4.0 (2020-11-24) 236 | 237 | ### Feat 238 | 239 | - add echo Commitizen version to better debug (#4) 240 | 241 | ## 0.3.0 (2020-10-05) 242 | 243 | ### Feat 244 | 245 | - add prerelease option 246 | 247 | ## 0.2.1 (2020-10-04) 248 | 249 | ### Fix 250 | 251 | - **entrypoint**: typo correction 252 | 253 | ## 0.2.0 (2020-08-13) 254 | 255 | ### Feat 256 | 257 | - change tag format 258 | 259 | ## 0.1.0 (2020-08-13) 260 | 261 | ### Feat 262 | 263 | - add parameters `github_token`, `repository` and `branch` 264 | - introduce github action 265 | 266 | ### Fix 267 | 268 | - **entrypoint**: add git user and email 269 | - add 'yes' arg to bump 270 | - remove tag format 271 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # commitizen-action 2 | 3 | Add [commitizen][cz] incredibly fast into your project! 4 | 5 | ## Features 6 | 7 | - Allow prerelease 8 | - Super easy to setup 9 | - Automatically bump version 10 | - Automatically create changelog 11 | - Update any file in your repo with the new version 12 | 13 | Are you using [conventional commits][cc] and [semver][semver]? 14 | 15 | Then you are ready to use this github action! The only thing you'll need is the 16 | `.cz.toml` file in your project. 17 | 18 | ## Usage 19 | 20 | 1. In your repository create a `.cz.toml` file (you can run `cz init` to create it) 21 | 2. Create a `.github/workflows/bumpversion.yaml` with the Sample Workflow 22 | 23 | ### Minimal configuration 24 | 25 | Your `.cz.toml` (or `pyproject.toml` if you are using python) should look like 26 | this. 27 | 28 | ```toml 29 | [tool.commitizen] 30 | version = "0.1.0" # This should be your current semver version 31 | ``` 32 | 33 | For more information visit [commitizen's configuration page][cz-conf] 34 | 35 | ## Sample Workflow 36 | 37 | ```yaml 38 | name: Bump version 39 | 40 | on: 41 | push: 42 | branches: 43 | - master 44 | 45 | jobs: 46 | bump_version: 47 | if: "!startsWith(github.event.head_commit.message, 'bump:')" 48 | runs-on: ubuntu-latest 49 | name: "Bump version and create changelog with commitizen" 50 | steps: 51 | - name: Check out 52 | uses: actions/checkout@v5 53 | with: 54 | fetch-depth: 0 55 | token: "${{ secrets.GITHUB_TOKEN }}" 56 | - id: cz 57 | name: Create bump and changelog 58 | uses: commitizen-tools/commitizen-action@master 59 | with: 60 | github_token: ${{ secrets.GITHUB_TOKEN }} 61 | - name: Print Version 62 | run: echo "Bumped to version ${{ steps.cz.outputs.version }}" 63 | ``` 64 | 65 | ## Variables 66 | 67 | | Name | Description | Default | 68 | | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | 69 | | `github_token` | Token for the repo. Can be passed in using `${{ secrets.GITHUB_TOKEN }}`. Required if `push: true` | - | 70 | | `working_directory` | Change to this directory before running | repo root directory | 71 | | `dry_run` | Run without creating commit, output to stdout | false | 72 | | `repository` | Repository name to push. Default or empty value represents current github repository | current one | 73 | | `branch` | Destination branch to push changes | Same as the one executing the action by default | 74 | | `prerelease` | Set as prerelease {alpha,beta,rc} choose type of prerelease | - | 75 | | `extra_requirements` | Custom requirements, if your project uses a custom rule or plugins, you can specify them separated by a space. E.g: `'commitizen-emoji conventional-JIRA'` | - | 76 | | `changelog_increment_filename` | Filename 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` | - | 77 | | `git_redirect_stderr` | Redirect git output to stderr. Useful if you do not want git output in your changelog | `false` | 78 | | `git_name` | Name used to configure git (for git operations) | `github-actions[bot]` | 79 | | `git_email` | Email address used to configure git (for git operations) | `github-actions[bot]@users.noreply.github.com` | 80 | | `push` | Define if the changes should be pushed to the branch. | true | 81 | | `merge` | Define if the changes should be pushed even on the pull_request event, immediately merging the pull request. | false | 82 | | `commit` | Define if the changes should be committed to the branch. | true | 83 | | `commitizen_version` | Specify the version to be used by commitizen. Eg: `4.10.0` | latest | 84 | | `changelog` | Create changelog when bumping the version | true | 85 | | `no_raise` | Don't raise the given comma-delimited exit codes (e.g., no_raise: '20,21'). Use with caution! Open an issue in [commitizen](https://github.com/commitizen-tools/commitizen/issues) if you need help thinking about your workflow. | [21](https://commitizen-tools.github.io/commitizen/exit_codes/) | 86 | | `increment` | Manually specify the desired increment {MAJOR,MINOR, PATCH} | - | 87 | | `check_consistency` | Check consistency among versions defined in commitizen configuration and version_files | `false` | 88 | | `gpg_sign` | If true, use GPG to sign commits and tags (for git operations). Requires separate setup of GPG key and passphrase in GitHub Actions (e.g. with the action `crazy-max/ghaction-import-gpg`) | `false` | 89 | | `debug` | Prints debug output to GitHub Actions stdout | `false` | 90 | 91 | ## Outputs 92 | 93 | | Name | Description | 94 | | ------------------------ | ----------------------------------------------------------------------- | 95 | | `version` | The next version (same as `next_version`, kept for historical purposes) | 96 | | `next_version` | Next version | 97 | | `next_version_major` | Only the major version of the next version | 98 | | `next_version_minor` | Only the minor version of the next version | 99 | | `previous_version` | Version before the bump | 100 | | `previous_version_major` | Only the major version of the previous version | 101 | | `previous_version_minor` | Only the minor version of the previous version | 102 | 103 | The new version is also available as an environment variable under `REVISION` or you can access using `${{ steps.cz.outputs.version }}` 104 | 105 | ## Using SSH with deploy keys 106 | 107 | 1. Create a [deploy key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys) (which is the SSH **public key**) 108 | 2. Add the **private key** as a [Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) in your repository, e.g: `COMMIT_KEY` 109 | 3. Set up your action 110 | 111 | ```yaml 112 | name: Bump version 113 | 114 | on: 115 | push: 116 | branches: 117 | - main 118 | 119 | jobs: 120 | bump-version: 121 | if: "!startsWith(github.event.head_commit.message, 'bump:')" 122 | runs-on: ubuntu-latest 123 | name: "Bump version and create changelog with commitizen" 124 | steps: 125 | - name: Check out 126 | uses: actions/checkout@v3 127 | with: 128 | fetch-depth: 0 129 | ssh-key: "${{ secrets.COMMIT_KEY }}" 130 | - name: Create bump and changelog 131 | uses: commitizen-tools/commitizen-action@master 132 | with: 133 | push: false 134 | - name: Push using ssh 135 | run: | 136 | git push origin main --tags 137 | ``` 138 | 139 | ## Creating a Github release 140 | 141 | ```yaml 142 | name: Bump version 143 | 144 | on: 145 | push: 146 | branches: 147 | - main 148 | 149 | jobs: 150 | bump-version: 151 | if: "!startsWith(github.event.head_commit.message, 'bump:')" 152 | runs-on: ubuntu-latest 153 | name: "Bump version and create changelog with commitizen" 154 | steps: 155 | - name: Check out 156 | uses: actions/checkout@v3 157 | with: 158 | fetch-depth: 0 159 | token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" 160 | - name: Create bump and changelog 161 | uses: commitizen-tools/commitizen-action@master 162 | with: 163 | github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} 164 | changelog_increment_filename: body.md 165 | - name: Release 166 | uses: softprops/action-gh-release@v1 167 | with: 168 | body_path: "body.md" 169 | tag_name: ${{ env.REVISION }} 170 | env: 171 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 172 | ``` 173 | 174 | ## Troubleshooting 175 | 176 | ### Other actions are not triggered when the tag is pushed 177 | 178 | This problem occurs because `secrets.GITHUB_TOKEN` do not trigger other 179 | actions [by design][by_design]. 180 | 181 | To solve it, you must use a personal access token in the checkout and the commitizen steps. 182 | 183 | Follow the instructions in [commitizen's documentation][cz-docs-ga]. 184 | 185 | Alternatively, you can try using the `gh` cli in your github action: 186 | 187 | ```sh 188 | gh workflow run ... 189 | ``` 190 | 191 | ## I'm not using conventional commits, I'm using my own set of rules on commits 192 | 193 | If your rules can be parsed, then you can build your own commitizen rules, 194 | create a new commitizen python package, or you can describe it on the `toml` config itself. 195 | 196 | [Read more about customization][cz-custom] 197 | 198 | [by_design]: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#example-using-multiple-events-with-activity-types-or-configuration 199 | [cz-docs-ga]: https://commitizen-tools.github.io/commitizen/tutorials/github_actions/ 200 | [cz]: https://commitizen-tools.github.io/commitizen/ 201 | [cc]: https://www.conventionalcommits.org/ 202 | [semver]: https://semver.org/ 203 | [cz-conf]: https://commitizen-tools.github.io/commitizen/config/ 204 | [cz-custom]: https://commitizen-tools.github.io/commitizen/customization/ 205 | --------------------------------------------------------------------------------