-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Flag to avoid creating a new commit for the bump #753
Comments
Can you explain a bit more? Would Commitizen creates a commit because it can update files depending on the version type used, the changelog and files that need to be updated, and all of that end up in the version commit. I wonder how all of that would work if no commit is created. |
No --files-only wouldn't work, I do need the tag, but I don't want the extra commit. My particular use case is a CI workflow that runs on every commit to main. I want to create a tag and do the release but I don't want to push a new commit back to main (and thus retrigger CI. I want the tag to be on the commit that triggered the pipeline. I know that bump can change files, but if no file changes are actually needed, there should be an option to not create the commit but still create a tag. I guess for my use case another option would be to do a dry run and get the next version from the output, then create the tag myself, but is there a way to print just the new version of the dry run without anything else so I don't need to parse it? Maybe like a --quiet or --porcelain flag or something |
I think you could achieve something like that using the version provider
with changelog off the version in I'll label this as bug |
@Lee-W @noirbizarre do you have any thoughts on this? how should commitizen behave under this circumstance? the circumstance:
Under those circumstances, running I can only think of 2 possibilities at the moment:
|
I prefer option 1. Just to clarify, does using "bump" add a tag to the most recent commit in this scenario? |
That is (my) the expected behavior. But it's not working atm. If you update the readme or version files, it's creating the bump commit and everything works fine. If you don't modify anything and you try to bump... it fails. |
I am currently in the process of deploying this kind of solution on enterprise projects, and it's working damn well. The solution I chose is the following (using I have the following in my [tool.pdm.version]
source = "scm"
write_to = "<package name>/_version.py"
write_template = '__version__ = "{}"'
[tool.commitizen]
version_provider = "scm" and the content of from __future__ import annotations
try:
import importlib.metadata as importlib_metadata
__version__ = importlib_metadata.version("<distrib name>")
except (importlib_metadata.PackageNotFoundError, ImportError):
__version__ = "0.0.0.dev" Release is fully automated using a GitHub action workflow like this: name: Release
on:
workflow_dispatch:
inputs:
prerelease:
type: choice
description: Pre-release type (optional)
options:
- ''
- alpha
- beta
- rc
default: ''
required: false
increment:
type: choice
description: Kind of increment (optional)
options:
- ''
- MAJOR
- MINOR
- PATCH
default: ''
required: false
jobs:
release:
name: Bump version and create changelog with commitizen
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Bump using commitizen
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.RELEASE_TOKEN }}
changelog_increment_filename: body.md
extra_requirements: <commitizen plugins>
prerelease: ${{ github.event.inputs.prerelease }}
increment: ${{ github.event.inputs.increment }}
- name: Github Release
uses: softprops/action-gh-release@v1
with:
body_path: "body.md"
tag_name: ${{ env.REVISION }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} This will trigger a Adding a tag on the last commit is not enough to me because I will have at least a bump commit. The only exception that I know of is when you don't commit versioned files, including changelog. However, I have one use-case that may require a For @abrahammurciano case (you seem to use commitizen only for version detection and tag bump, no file change), the NEXT_VERSION=`cz next`
git tag $NEXT_VERSION
git push $NEXT_VERSION Where TLDR: (Those are on the fly thinking, I might take some more time to study this case a bit more) |
I'm also looking for a I'm happy to implement this feature if we can agree on the behavior. Some thoughts:
|
I did some testing with the scm provider, trying to use a gitflow branching structure with commitizen and the scm provider. There's a pretty serious bug with the SCM provider which makes it pretty useless as is, but I've made a PR to address that here: #975 For now I'm just parsing the version using
With my PR and #799 to fix prereelase behavior I have a good POC. |
Mark it as wait-for-implementation as it is mentioned in #1073 |
Description
Since I use git tags to control the version there's no need to create a commit for the new tag when calling bump. Adding the tag to the latest commit would do just fine.
Possible Solution
Adding a flag like --no-commit to not create a commit during the bump, causing the tag to point to the latest existing commit.
Additional context
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: