go-semantic-release / semantic-release

📦🚀 semantic-release written in Go
https://go-semantic-release.xyz
MIT License
409 stars 43 forks source link

A new calculated version in dry mode returns error #84

Closed ido-namely closed 3 years ago

ido-namely commented 3 years ago

Hi, The command exits with exit code 65 when using dry run mode to test a new calculated release, see here.

I'm using this mode in the CI to verify a new release is calculated (but not released yet) as part of a PR.

I was wondering if I'm using the tool wrong or if we can change it to exit with exit code 0.

The command I am executing is: /usr/local/bin/semantic-release --provider-opt "slug=<repo-name>" --no-ci -f --allow-no-changes --dry

Using Jenkins for CI.

Thanks!

christophwitzko commented 3 years ago

Hi @ido-namely, thanks for using semantic-release. This is actually a bug, when using the --allow-no-changes flag the dry run should also exit with 0.

ido-namely commented 3 years ago

Hi @christophwitzko , thanks for the quick response. I had thought allow-no-change was meant to let the tool exit with 0 in case there is no new version found, so it would make sense it would get to the line in question.

In my case there was a new found version, here is the full output:

[go-semantic-release]: version: 2.6.0
[go-semantic-release]: ci-condition plugin: default@1.2.0
[go-semantic-release]: provider plugin: GitHub@1.4.0
[go-semantic-release]: getting default branch...
[go-semantic-release]: found default branch: master
[go-semantic-release]: repo is private
[go-semantic-release]: found current branch: 9b6ef0ebff3a49da0047b867aebf27e64cb59294
[go-semantic-release]: found current sha: 9b6ef0ebff3a49da0047b867aebf27e64cb59294
[go-semantic-release]: getting latest release...
[go-semantic-release]: found version: 1.5.6
[go-semantic-release]: getting commits...
[go-semantic-release]: commit-analyzer plugin: default@1.3.0
[go-semantic-release]: calculating new version...
[go-semantic-release]: new version: 1.6.0
[go-semantic-release]: DRY RUN: no release was created

I thought everything worked fine except the exit code.

Either way, I'd be happy to contribute on whatever you think is the right solution.

christophwitzko commented 3 years ago

Hi @ido-namely, you are right, my mistake. The --allow-no-changes flag is if no release was created. The main idea why --dry errors, was that no release was created, so if you use semantic-release in a bash script the following commands are not executed. Maybe we want something like a --check flag to detect changes? 🤔

ido-namely commented 3 years ago

Thanks @christophwitzko, the way I view it, --dry should simulate the behavior as much as possible, and return with 0 in this case. In my scenario I want to be able to confirm release would have worked (while cutting a new version) if my pr was merged to master.

Maybe there is room to let the script continue further without actually making changes in dry mode?

I understand the need to ensure a new release was in fact created but I wonder if that protection is actually needed or if it's otherwise just a matter for the user to avoid using --dry if they actually want the version to get created.

christophwitzko commented 3 years ago

Hey @ido-namely,

--dry should simulate the behavior as much as possible, and return with 0 in this case

This is a good point, I will change semantic-release to exit with 0 after a dry run 👍

ido-namely commented 3 years ago

Thanks for the quick turnaround on this issue @christophwitzko !