yoichiro / gh-action-increment-value

This is a Github Action to increment a value and to commit it automatically.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails to read current version number in some scenarios

JakeSteam opened this issue · comments

Hey!

Thanks for the library, I initially encountered an issue but found a workaround. Raising it here for visibility.

The problem

My project has a dependencies.gradle file that includes this:

ext.app_versions = [
    versionMajor:4,
    versionMinor:1,
    versionPatch:0,
]

Using this config in my workflow:

      - name: Increment patch version
        uses: yoichiro/gh-action-increment-value@v5
        with:
          target_directory: ''
          target_file: 'dependencies.gradle'
          prefix: 'versionPatch:'
          suffix: ','
          commit_message: 'Increments the patch version to'

I unexpectedly get this output:

ext.app_versions = [
    versionMajor:4,
    versionMinor:1,
    versionPatch:NaN,
]

And the logs:

Target file: /github/workspace/dependencies.gradle
prefix: versionPatch:
suffix: ,
Incremented the value from NaN to NaN.

The fix

I fixed this by replacing my code with:

ext.app_versions = [versionMajor:4, versionMinor:1, versionPatch:1]

I had a quick look at index.js and couldn't see why this was happening, maybe something around how spaces are handled?