googleapis / release-please-action

automated releases based on conventional commits
Apache License 2.0
1.7k stars 209 forks source link

fix: undo breaking change in releases_created output #915

Closed rowanmanning closed 1 week ago

rowanmanning commented 10 months ago

The issue this fixes

An undocumented breaking change slipped into the v4 release which causes the conditional in actions to stop working as documented. I encountered it when migrating some of my projects and an issue has already been opened (#912).

In v3 the following step would only run if releases were created. In v4 the action will always run:

- run: echo "releases happened"
  if: ${{ steps.release.outputs.releases_created }}

This is because the @actions/core npm package core.setOutput method always casts values to a string, so when we call the following:

core.setOutput('releases_created', releases.length > 0);

The output of the action will always either be "true" or "false" as a string. This is a problem because our if statement above will always evaluate this to true and run the conditional step.

The only reason this worked in v3 is because the core.setOutput was called only if releases.length was greater than zero rather than being passed the condition.

So in v3 the possible values for releases_created was actually "true" or undefined. This was never an issue because "true" is truthy and undefined is falsy so the conditions in our actions worked as expected.

Approach

I've moved the releases_created output back inside the conditional to switch the behaviour to match v3.

Alternatives

If you're not happy with this change then I think the documentation should be updated to highlight this gotcha and the changelog for v4 should include it.

Potential additional work

core.setOutput casting to a string has been noted in issues in the @actions/core repo before, but all the documentation on this action indicates that outputs are set to true or false. It might be worth changing this documentation to explain that the values are all strings rather than booleans.

google-cla[bot] commented 10 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

psYifanChen commented 9 months ago

@chingor13 @bcoe Could anyone review this PR please?

toddbaert commented 6 months ago

@chingor13 is there any hope of a release with this fix?

toddbaert commented 4 months ago

@chingor13 is there any hope of this being merged?

jimeh commented 1 week ago

Any movement on this at all? Or has this been broken so long now that fixing it will break just as many workflows as this PR fixes?

rowanmanning commented 1 week ago

I'm not sure if the maintainers are aware of this bug, we've had no response for almost a year and I think this PR probably can't be merged now – too many people have switched to the new behaviour.

I'm going to close this PR and have commented again on the issue to say that ideally this would be documented as a breaking change. Not gonna hold my breath though.