cbeust / kobalt

A Kotlin-based build system for the JVM.
Apache License 2.0
428 stars 60 forks source link

Git tags are not automatically created on publishBintray #487

Open johanhaleby opened 5 years ago

johanhaleby commented 5 years ago

I have the following configuration:

autoGitTag {
    enabled = true
    annotated = true
    tag = "$version"
    message = "Released $version"
}

However when I run ./kobaltw assemble uploadBintray the git tagging step gives me the following error that I cannot understand:

Tag on repository without HEAD currently not supported

I've cloned the project from github as I do with all other projects so nothing special there. I also run the command from the root of the project and everything is in sync with the remote repository so I don't really understand why I get this error.

cbeust commented 5 years ago

Mmmh, this seems to be more of a git issue than Kobalt? Does your repo have a HEAD?

johanhaleby commented 5 years ago

@cbeust It very well might but I don't understand what the problem is.

$ git branch -r
origin/HEAD -> origin/master
origin/master
$ git remote show origin
* remote origin
  Fetch URL: git@github.com:johanhaleby/kystrix.git
  Push  URL: git@github.com:johanhaleby/kystrix.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

This seem to be the same settings I have for other projects such as Awaitility where git tagging seem to work (but they're using Maven).

So not quite sure what I'm missing.

ethauvin commented 5 years ago

Have you tried tagging manually?

git tag -a version -m "Released version"
johanhaleby commented 5 years ago

@ethauvin Tried it just now and it works fine

johanhaleby commented 5 years ago

I can also do git push --tags afterwards and it also works fine

ethauvin commented 5 years ago

@johanhaleby I cloned your project and I'm seeing the same behavior, even after re-initializing git.

Kobalt is using JGit from Eclipse. Looking around I've seen people reporting the same problem when trying to tag in a subdirectory instead of the root directory. Since you have subprojects, I wonder if that is what causing the problem.

@cbeust I haven't looked at the code, but JGit might need to have the (sub)project root set prior to being called.

johanhaleby commented 5 years ago

@ethauvin Thanks for trying it out.

Looking around I've seen people reporting the same problem when trying to tag in a subdirectory instead of the root directory

I also read up on the problem and I can confirm that I'm in the root project when I run the kobalt command. So I suppose it's likely that it's a problem with jgit or how it's used.

johanhaleby commented 5 years ago

I've not looked at the Kobalt code but I've thought about it a bit and here are some guesses on what may happen.

  1. I have a "multi-project" Kobalt build sharing the same git repository
  2. I've included autoGitTag in all projects (in my case 2)
  3. When I run ./kobaltw clean test assemble uploadBintray it seems like kobalt will issue all of these commands for each project. I.e. run clean test assemble uploadBintray first for project 1 (core in my case) and then clean test assemble uploadBintray for project 2 (spring in my case).

When it comes to autoGitTag I cannot see how this will work in my case since this ought only be performed once for the entire build process when it's completed (e.g. after uploadBintray has been completed for both projects) and this doesn't seem to be the case.

I also have another thought related to this. I want to release my to projects in one go, but given the way Kobalt seem to operate, what if I do ./kobaltw clean test assemble uploadBintray and everthing works fine for project 1 but tests fail for project 2. In this case the artifacts have already been uploaded to bintray for project 1, which is not what I want nor would expect. Is this the intended behavior or am I doing something wrong?