ajoberstar / reckon

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

GitInventorySupplier local and on Github differs #153

Closed marvi closed 3 years ago

marvi commented 3 years ago

I don't know if this is a bug or if I'm doing something wrong.

Example repo

I have a tag '2.0.0' both locally and in origin on GitHub.

gradle api:compile --debug -Preckon.stage=beta -Preckon.scope=patch

Debug output on local shows: [org.ajoberstar.reckon.core.GitInventorySupplier] Found tagged versions: [GitInventorySupplier.TaggedVersion[commit=commit 051d9ec1fcaf58c5e90dbea92ca593dd8307827a 1607095581 ------p,version=2.0.0]] [org.gradle.api.Project] Reckoned version: 2.0.1-beta.1

That's what I expected.

On Github however I get:

[org.ajoberstar.reckon.core.GitInventorySupplier] Found tagged versions: [] [org.gradle.api.Project] Reckoned version: 0.1.0-beta.0.1+b9fa88f

Reckon doesn't seem to find my tag when it's running on Github. Any pointers?

marvi commented 3 years ago

I see know that the GIthub workflow doesn't see any tags. So the problem is there and not in this plugin.

I hope to get it working since it's a great idea. Thanks!

marvi commented 3 years ago

The checkout action needs to be told not to do a shallow clone: fetch-depth: '0'

For reference, this is my working workflow for releasing with reckon and GitHub Actions:

name: Release a version

on: 
  workflow_dispatch:
    inputs:
      scope:
        description: 'Scope: patch, minor, major'     
        required: true
        default: 'patch'
      stage:
        description: 'Stage: beta, final'     
        required: true
        default: 'beta'
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: '0'
      - uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
      - name: Publish package
        run: ./gradlew api:publish reckonTagPush -Preckon.stage=${{ github.event.inputs.stage }} -Preckon.scope=${{ github.event.inputs.scope }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
mohanidragel commented 3 years ago

I'm having a similar issue when trying to get git information from github actions - https://stackoverflow.com/questions/65326750/can-i-determine-the-current-branch-from-gradle-in-github-actions I've gotten onto github directly about this, I'm waiting on an answer so I'll post that here when I get it if that helps.

marvi commented 3 years ago

So setting fetch-depth isn't working for you?

JavierSegoviaCordoba commented 3 years ago

It is not working for me, locally, on the same branch, I am getting 0.2.0-SNAPSHOT, in remote I get Reckoned version 0.1.0-SNAPSHOT is (and cannot be) less than base version 0.1.0-alpha.1

JavierSegoviaCordoba commented 3 years ago

@marvi I am using your approach

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

Checking the tags:

    - name: Check tags
      run: echo  "Git tags:" $(git tag -l)

GitHub logs: Git tags: 0.1.0-alpha.1

So I don't understand why the Gradle command doesn't do the same there as it does in local.

In GitHub with Debug: 2021-03-07T15:44:16.2913124Z 2021-03-07T15:44:16.052+0000 [DEBUG] [org.ajoberstar.reckon.core.GitInventorySupplier] Found tagged versions: [GitInventorySupplier.TaggedVersion[commit=commit d2dac425207b8774115d80a5992ad7704ee8880e 1615086655 ------p,version=0.1.0-alpha.1]]