Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix publish step check before tagging #39

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

ctran88
Copy link
Contributor

@ctran88 ctran88 commented Jan 16, 2025

What's New?

fromJSON was unable to parse the value of steps.publish-crates.outputs.published, so this change uses an alternative value to check for publication success.

Screenshots (if appropriate):

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have manually tested my code thoroughly
  • I have added/updated inline documentation for public facing interfaces if relevant
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing integration and unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional context

if: ${{ steps.release.outputs.release_created }}
# https://github.com/googleapis/release-please-action?tab=readme-ov-file#creating-majorminor-tags
- name: Tag versions
if: ${{ steps.release.outputs.release_created && fromJSON(steps.publish-crates.outputs.published).* }}
if: ${{ steps.release.outputs.release_created && steps.publish-crates.outcome == 'success' }}
Copy link
Contributor Author

@ctran88 ctran88 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the stringified version of an empty array in JS is just an empty string (not counting however @actions/core decides to serialize the value).

given error message from the last successful release, it made it seem like the value was an empty string (Path '', line 0, position 0.) so i wasn't too confident in just checking that.

a failure on the publish step should result in a step failure based on https://github.com/katyo/publish-crates/blob/5e67639f17e8a1f221e804c2bd47f7a253e45dac/src/main.ts#L145

so i figured we could just check for the success of the publish step instead.

@ctran88 ctran88 marked this pull request as ready for review January 16, 2025 18:14
@@ -26,10 +26,11 @@ jobs:
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
id: publish-crates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you get a chance to test if this line alone fixes the error? Running actionlint on the main branch flags the missing id for this GitHub Actions step, as it’s used later but isn’t currently defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did try to check it, but the output was always an empty string, so i couldn't be sure if it would've worked or not with an actual release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test run here shows fromJSON works when the output includes the array string for a new version. However, if there’s no new version, the output is an empty string, causing fromJSON to fail.

The outcome == 'success' check should work well, but an empty string check could also suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i'll opt to leave it with `outcome == 'success' since it's a bit easier to understand without looking through the action's docs for someone else on our team to work on this in the future. but good to see the output on a successful run as well

@ctran88 ctran88 merged commit b83a119 into main Jan 16, 2025
5 checks passed
@ctran88 ctran88 deleted the fix-tagging-step-condition-check branch January 16, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants