absolute-version / commit-and-tag-version

Fork of the excellent standard-version. Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org :trophy:
ISC License
360 stars 33 forks source link

bump version not working on gradle #164

Closed DevLomoSE closed 2 weeks ago

DevLomoSE commented 2 weeks ago

Describe the bug I've installed with:

npm install commit-and-tag-version

I've a package.json (to use other cli tools) and i've also created the script like

"release": "commit-and-tag-version"

and im using it like:

npm run release --packageFiles build.gradle --bumpFiles build.gradle

Current behavior after run the command i can see changelog.md has been updated, the package.json has been updated with new version but build.gradle remains

version = '0.0.1-SNAPSHOT'

Expected behavior build.gradle updated to

version = '1.2.1' (example)

Environment

Possible Solution

Additional context

TimothyJones commented 2 weeks ago

I wonder if this is because of -SNAPSHOT?

DevLomoSE commented 2 weeks ago

Make sense, i'll try I think is better if some exception is thrown and process of commit tag and that stuff is aborted.

TimothyJones commented 2 weeks ago

I agree. I think my instinct was right- looks like the regex only matches digits and dots. It should be updated so that it matches full semver versions: https://github.com/absolute-version/commit-and-tag-version/blob/master/lib/updaters/types/gradle.jsAs you can see, the gradle implementation isn’t especially advanced- it’s just looking for a regular expression match. Definitely lots of opportunities for improvement there.On 7 Jul 2024, at 4:35 PM, Jonathan Guzman Guadarrama @.***> wrote: Make sense, i'll try I think is better if some exception is thrown and process of commit tag and that stuff is aborted.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

DevLomoSE commented 2 weeks ago

I just tried and even with version:

version = '1.0.0'

there is no update in build.gradle

the command shows this output

 commit-and-tag-version build.gradle build.gradle src/resources/application.yml

✔ bumping version in package.json from 1.2.3 to 1.3.0
✔ bumping version in package-lock.json from 1.2.3 to 1.3.0
✔ outputting changes to CHANGELOG.md
✔ committing package-lock.json and package.json and CHANGELOG.md
✔ tagging release v1.3.0

so im wonder if there is something else that is failing. how can i help by getting more info about this issue?

DevLomoSE commented 2 weeks ago

i've created a new empty git repo with package.json build.gradle

if i install the cli tool in global with: npm install -g commit-and-tag-version then run commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle the output is

✔ bumping version in build.gradle from 1.0.2 to 1.0.3
✔ outputting changes to CHANGELOG.md
✔ committing build.gradle and CHANGELOG.md
✔ tagging release v1.0.3
ℹ Run `git push --follow-tags origin main` to publish

here the version in the gradle file is updated and the package.json is ignored.

if i run the npm script like npm run release --packageFiles build.gradle --bumpFiles build.gradle the output is

> commit-and-tag-version build.gradle build.gradle

✔ bumping version in package.json from 1.2.0 to 1.2.1
✔ outputting changes to CHANGELOG.md
✔ committing package.json and CHANGELOG.md
✔ tagging release v1.2.1
ℹ Run `git push --follow-tags origin main && npm publish` to publish

here the build.gradle is ignored and the version is updated in the package.json

if i run the cli with npx like npx commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle the output is

✔ bumping version in build.gradle from 1.0.3 to 1.0.4
✔ outputting changes to CHANGELOG.md
✔ committing build.gradle and CHANGELOG.md
✔ tagging release v1.0.4
ℹ Run `git push --follow-tags origin main` to publish

here the version in the gradle file is updated and the package.json is ignored.

so there should be something that cause a "conflict" when you run the command with the npm script

TimothyJones commented 2 weeks ago

Aha! Thanks for the extensive testing.

# This won't work
npm run release --packageFiles build.gradle --bumpFiles build.gradle

^ this isn't the right way to pass arguments prefixed with -- through npm to the script. You'll need to add -- before the arguments (docs here). It should work when you do this.

# This should work
npm run release -- --packageFiles build.gradle --bumpFiles build.gradle

Alternatively, you can just add the arguments to the scripts stanza in your package json:

"scripts": {
   ...
   "release": "commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle"
}
TimothyJones commented 2 weeks ago

Also, sorry I didn't notice this in the first post!

DevLomoSE commented 2 weeks ago

no worries, i just noticed that too. then we can close this. sorry for the false alarm :/