Skip to content

Is there a way of knowing if bump detected an increment? #18

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

Closed
m0wer opened this issue Jan 16, 2022 · 5 comments
Closed

Is there a way of knowing if bump detected an increment? #18

m0wer opened this issue Jan 16, 2022 · 5 comments

Comments

@m0wer
Copy link

m0wer commented Jan 16, 2022

I would like to programatically disable subsequent steps in a workflow if no increment is detected in this action (If cz bump detects no increment).

Does it make sense to add an output variable that states whether or not an increment was detected or is there a simpler way of approaching this?

@woile
Copy link
Member

woile commented Jan 16, 2022

cz bump throws an error code different than 0, this means that most pipelines will be interrupted.

If you are writing a POSIX shell script, you can do something like:

#!/bin/sh -e

if cz bump; then
    echo 'it was bumped correctly'
else
    echo "there was an error, whose error code is $?"
    exit 3  # 3 is the error code thrown by no commits found
fi

@m0wer
Copy link
Author

m0wer commented Jan 16, 2022

Thanks for your answer @woile. Unfortunately, it looks like cz bump returns 0 even if no increment is detected. Example:

$ cz bump --changelog
bump: version 1.3.0 → 1.3.0
tag to create: 1.3.0
increment detected: None
$ echo $?
0

And the same result happens when using this action in a workflow: https://github.com/now8-org/app/runs/4832942786?check_suite_focus=true (check the commitizen step output).

@woile
Copy link
Member

woile commented Jan 16, 2022

Nice catch, it is actually a bug on commitizen, not on this github action, I've submitted a PR to cz.
An error code should be returned instead (I think). (If) Once merged, it should solve this issue.

commitizen-tools/commitizen#473

Thanks for reporting

@woile
Copy link
Member

woile commented Jan 17, 2022

Can you test with the latest version?
Thanks

@m0wer
Copy link
Author

m0wer commented Jan 17, 2022

It's working now. Thanks.

In case it helps anyone what I did to condition the execution of subsequent steps was:

      - name: commitizen
        id: commitizen
        continue-on-error: true
        uses: commitizen-tools/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

     - name: Some other task
        if: steps.commitizen.outcome == 'success'
        run: something

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

No branches or pull requests

2 participants