Skip to content

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

Closed

Description

@m0wer

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?

Activity

  1. woile commented on Jan 16, 2022

    @woile
    Member

    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
  2. m0wer commented on Jan 16, 2022

    @m0wer
    Author

    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).

  3. woile commented on Jan 16, 2022

    @woile
    Member

    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

  4. woile commented on Jan 17, 2022

    @woile
    Member

    Can you test with the latest version?
    Thanks

  5. m0wer commented on Jan 17, 2022

    @m0wer
    Author

    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/commitizen-action@0.11.0
            with:
              github_token: ${{ secrets.GITHUB_TOKEN }}
    
         - name: Some other task
            if: steps.commitizen.outcome == 'success'
            run: something
  6. added a commit that references this issue on Jul 25, 2022
  7. added a commit that references this issue on Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions