ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
191 stars 28 forks source link

GitHub Actions setting wrong version even with `fetch-depth` #157

Closed JavierSegoviaCordoba closed 2 years ago

JavierSegoviaCordoba commented 3 years ago

Using this + debugging Gradle

name: "Checkout repo"
uses: "actions/checkout@v2"
  with:
    fetch-depth: 0

Let me know that Reckon knows that there is a tag, but for some reason, it is not setting the same version as in local.

JavierSegoviaCordoba commented 3 years ago

The current workaround I have to use is creating a tag without pushing it in Actions

./gradlew reckonTagCreate -P"reckon.stage"="final"

And later to release it as Snapshot.

./gradlew build -P"reckon.stage"="snapshot"
Sollace commented 3 years ago

@JavierSegoviaCordoba We ran into the same issue on our repositories after switching to Reckon. The only thing that seemed to work is adding git fetch --unshallow --tags to the actions after checkout.

Something like this:

      - name: Checkout Commit
        uses: actions/checkout@v2
      - name: Fetch Tags
        run: git fetch --unshallow --tags

The way I landed on this solution is by observing that git describe --tags was also failing. After a bit of searching, I landed on the above flag as a solution to that, which subsequently also fixed reckon.

Checkout seems to do a shallow checkout by default, which excludes tags and the commit history, and without either of those Reckon just... doesn't work. I assume for the same reason that describe failed. Appending --unshadow just ensures we get those commits in addition to the tags.

ajoberstar commented 2 years ago

Closing under the assumption this is resolved. If that's not true and you want to discuss further, please reopen.