Skip to content

lightweight tags create no "create event" in github actions #271

Closed

Description

@diefans

Description

Commitizen creates only lightweight tags, which are not creating a "create event" in github actions.

Steps to reproduce

https://github.com/commitizen-tools/commitizen/blob/master/commitizen/git.py#L49

Current behavior

A lightweight tag created by commitizen does not lead to a usefull event in github actions.

Desired behavior

Create an annotated tag, e.g. git tag -a <version> -m <version>. This should be at least a configurable option IMHO.

Environment

  • commitizen version: master

Activity

  1. added 4 commits that reference this issue on Sep 22, 2020
  2. woile commented on Sep 23, 2020

    @woile
    Member

    thanks for the finding! some questions, how did you find this problem? could you point the GA documentation where they mention lightweight tag don't create events? I couldn't find it.

    I'll run some tests in to verify it as well 💪

  3. diefans commented on Sep 23, 2020

    @diefans
    ContributorAuthor

    I have no documentation at hand. But as far as I know, lightweight tags are not "real" objects in git and have also no creation date. You can see this via git for-each-ref where the objecttype of a lightweight tag is commit and for an annotated tag it is tag (also find this in my unit test).
    So basically I found this by trying github actions to do something after tag creation (see https://docs.github.com/en/actions/reference/events-that-trigger-workflows#create), but there was no event triggered after commitizen created the "tag". So I just created a dummy annotated tag and my workflow was running - so I came to that conclusion....

  4. Lee-W commented on Sep 23, 2020

    @Lee-W
    Member

    We use the following syntax to detect release which might be the reason why we did not encounter such problem.

    on:
      push:
        tags:
          - 'v*'

    But I think it's a feature we could have. Thanks for great work 🙂 I'll also run some test to verify it.

  5. diefans commented on Sep 23, 2020

    @diefans
    ContributorAuthor

    @Lee-W I do not really understand how this is working for you:
    I have a job running basically the example in your docs:

      bump-version:
        if: github.ref == 'refs/heads/master'
        runs-on: ubuntu-latest
        name: "Bump version and create changelog with commitizen"
        needs:
          - build
        steps:
          - name: Check out
            uses: actions/checkout@v2
            with:
              token: '${{ secrets.GITHUB_TOKEN }}'
              fetch-depth: 0
          - name: Create bump and changelog
            uses: commitizen-tools/commitizen-action@master
            with:
              github_token: ${{ secrets.GITHUB_TOKEN }}
    

    The job appears to work fine:

    Configuring git user and email...
    Runnung cz...
    bump: version 0.2.1 → 0.2.2
    tag to create: 0.2.2
    increment detected: PATCH
    
    Done!
    Pushing to branch...
    To https://github.com/*/*.git
       f76d488..8bdc82d  HEAD -> master
     * [new tag]         0.2.2 -> 0.2.2
    Done.
    

    I also have a debug workflow:

    name: debug
    on:
      push:
        tags:
          - "*"
      create:
    
    jobs:
      debug:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - run: echo ${{ github.ref }}
          - run: echo ${{ toJSON(github.event) }}
    

    but this gets never triggered after the "tag" is "pushed" via the bump-version job.

  6. woile commented on Sep 23, 2020

    @woile
    Member

    secrets.GITHUB_TOKEN won't trigger another workflow. It's like using [skip ci] in other CI's.

    You have to use a personal token like here: https://github.com/commitizen-tools/commitizen/blob/master/.github/workflows/bumpversion.yml

    I asked the same in the github action discussion board:
    https://git.xywcc.community/t/action-does-not-trigger-another-on-push-tag-action/17148/2

    Note: for some reason your PERSONAL_TOKEN must be provided to the checkout step 🤷‍♂️

    I think in our case (commitizen) that's why it was failing. Now we are waiting for next release 🤞 hahahha

  7. added a commit that references this issue on Sep 23, 2020
  8. diefans commented on Sep 23, 2020

    @diefans
    ContributorAuthor

    @woile this explains a lot...

  9. woile commented on Sep 23, 2020

    @woile
    Member

    Yeah I lost a few hairs dealing with it.

    The documentation explains how to add a PERSONAL TOKEN, I think we should mention why though.

    https://commitizen-tools.github.io/commitizen/tutorials/github_actions/

  10. added a commit that references this issue on Nov 21, 2020
    58c5a92
  11. added 4 commits that reference this issue on Jan 15, 2021
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions