researchgate / gradle-release

gradle-release is a plugin for providing a Maven-like release process for projects using Gradle
MIT License
867 stars 221 forks source link

Build from the tag #225

Open glucazeau opened 7 years ago

glucazeau commented 7 years ago

Would it be possible to actually build from the tag, not the branch? Basically like what the Maven plugin does if I'm right:

(prepare)

  1. checkout branch
  2. commit release version
  3. tag
  4. commit new development version

(perform)

  1. checkout tag
  2. build

We include the Git SHA-1 in our build info and we would like it to match the tag commit, and we'd prefer to build from the tag.

I would be glad to send a PR for Git, but I don't know Mercurial, and I think Subversion requires more work (like a checkout in a subdirectory).

Any thoughts on this?

Hillkorn commented 7 years ago

I see no reason to explicitly checkout the tag as the release version commit hash is the same. The tag just points to that commit hash. If the release build is performed you should be able to set the git commit hash of the latest commit and that should match the one from the hash. Or am I wrong?

glucazeau commented 7 years ago

Hello Hillkorn,

We actually put the Git hash into some properties file in our build, so it's injected in some code and shown on startup. Currently, we get the hash of the commit just before the release version commit.

That's why I suggested to build from the tag as I know it's how the Maven plugin works, but maybe it's just a change in our Gradle build file?

Hillkorn commented 7 years ago

You're right that at build time of your project the commit is not done and therefore you can't know the hash. I don't have an idea for an easy way to achieve that. The easiest i can think of is to create another plugin that connects the tasks in a different order.