Skip to content

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

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
diefans opened this issue Sep 22, 2020 · 7 comments · Fixed by #310
Closed

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

diefans opened this issue Sep 22, 2020 · 7 comments · Fixed by #310

Comments

@diefans
Copy link
Contributor

diefans commented Sep 22, 2020

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
diefans added a commit to bettermarks/commitizen that referenced this issue Sep 22, 2020
    Enable creation of annotated tags when bumping.
diefans added a commit to bettermarks/commitizen that referenced this issue Sep 22, 2020
    Enable creation of annotated tags when bumping.
diefans added a commit to bettermarks/commitizen that referenced this issue Sep 22, 2020
    Enable creation of annotated tags when bumping.
diefans added a commit to bettermarks/commitizen that referenced this issue Sep 22, 2020
    Enable creation of annotated tags when bumping.
@woile
Copy link
Member

woile commented Sep 23, 2020

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 💪

@diefans
Copy link
Contributor Author

diefans commented Sep 23, 2020

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

@Lee-W
Copy link
Member

Lee-W commented Sep 23, 2020

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.

@diefans
Copy link
Contributor Author

diefans commented Sep 23, 2020

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

@woile
Copy link
Member

woile commented Sep 23, 2020

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://github.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

diefans added a commit to bettermarks/commitizen that referenced this issue Sep 23, 2020
    Enable creation of annotated tags when bumping.
@diefans
Copy link
Contributor Author

diefans commented Sep 23, 2020

@woile this explains a lot...

@woile
Copy link
Member

woile commented Sep 23, 2020

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/

woile added a commit that referenced this issue Nov 21, 2020
@woile woile mentioned this issue Nov 21, 2020
@cliles cliles mentioned this issue Jan 15, 2021
4 tasks
cliles pushed a commit to cliles/commitizen that referenced this issue Jan 15, 2021
    Enable creation of annotated tags when bumping.
cliles pushed a commit to cliles/commitizen that referenced this issue Jan 15, 2021
    Enable creation of annotated tags when bumping.
cliles pushed a commit to cliles/commitizen that referenced this issue Jan 18, 2021
    Enable creation of annotated tags when bumping.
cliles pushed a commit to cliles/commitizen that referenced this issue Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants