Skip to content

Conversation

@sstefdev
Copy link
Contributor

@sstefdev sstefdev commented Jun 13, 2024

Fixes #29

  • updated the npm-publish workflow
    • now it checks if the shared package has a new version; if it does, it updates all other packages
    • then it goes through a workflow of:
      • installing dependencies
      • checking if the version is updated
      • publishing to npmjs

Summary by CodeRabbit

  • Chores
    • Improved npm publish workflow by rearranging steps and refining version check and publish conditions.
    • Updated script to determine if a release is needed based on package version presence.

@sstefdev sstefdev linked an issue Jun 13, 2024 that may be closed by this pull request
2 tasks
@sstefdev sstefdev requested a review from MantisClone June 18, 2024 18:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

The changes aim to fix and improve the GitHub workflow for publishing packages to NPM. Key updates include rearranging workflow steps, adding a script to set file permissions, configuring .npmrc authentication, refining the version check command, and adjusting the publish step condition based on the version check result. Additionally, the scripts/is-release-needed.sh script now accurately determines the necessity of a release based on package version presence.

Changes

File Change Summary
.github/workflows/npm-publish.yaml Rearranged steps, added a script to set file permissions, configured authentication in .npmrc, refined version check, adjusted publish step condition based on version check result.
scripts/is-release-needed.sh Updated logic to output true for release needed and false for release not needed based on the presence of a specific package version.

Sequence Diagram(s)

No sequence diagrams are necessary for these changes as they involve straightforward modifications to workflow logic and script updates.

Assessment against linked issues

Objective Addressed Explanation
Fix the release-if-necessary GitHub Workflow (#29)
Automate upgrading inter-package dependencies (#29) Unnecessary after #41.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 8e7aa07 and 144dc4c.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (4)
  • .github/workflows/npm-publish.yaml (1 hunks)
  • package.json (1 hunks)
  • packages/shared/package.json (1 hunks)
  • scripts/is-release-needed.sh (1 hunks)
Additional comments not posted (3)
packages/shared/package.json (1)

10-11: LGTM!

The addition of the is-release-needed script is appropriate.

.github/workflows/npm-publish.yaml (2)

31-32: Clarify the purpose of making the script executable.

Ensure that the script needs to be made executable within the workflow.


47-49: Fix the condition for the publish step.

Ensure that the condition for the publish step checks the correct output variable.

- if: ${{ steps.is-release-needed.outputs.is-release-needed-${{ matrix.package }} == 'true' }}
+ if: ${{ steps.is-release-needed.outputs.is-release-needed-${{ matrix.package }} == '0' }}

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 144dc4c and 67ef721.

Files selected for processing (1)
  • .github/workflows/npm-publish.yaml (1 hunks)
Additional comments not posted (4)
.github/workflows/npm-publish.yaml (4)

31-32: LGTM!

Making the is-release-needed.sh script executable is necessary for it to run.


34-39: LGTM!

Printing package information is useful for debugging purposes.


47-48: LGTM!

Setting up the .npmrc file is necessary for authentication to publish to npm.


40-45: Fix the usage of echo for output.

Use $GITHUB_OUTPUT to set the output variable properly.

- echo "is-release-needed=$IS_RELEASE_NEEDED" >> $GITHUB_OUTPUT
+ echo "is-release-needed=$IS_RELEASE_NEEDED" >> $GITHUB_ENV

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 67ef721 and 0ddc773.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (1)
  • .github/workflows/npm-publish.yaml (1 hunks)
Additional comments not posted (6)
.github/workflows/npm-publish.yaml (6)

19-21: LGTM!

The step to checkout the repository is correctly implemented.


22-27: LGTM!

The step to set up Node.js environment is correctly implemented.


28-30: LGTM!

The step to install dependencies using npm ci is correctly implemented.


31-33: LGTM!

The step to make the is-release-needed.sh script executable is correctly implemented.


41-43: LGTM!

The step to set up the .npmrc file for npm authentication is correctly implemented.


44-48: Uncomment the npm publish command.

The npm publish command is commented out, which will prevent the package from being published.

- # npm publish --workspace=${{ matrix.package }}
+ npm publish --workspace=${{ matrix.package }}

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 0ddc773 and ce303f4.

Files selected for processing (2)
  • .github/workflows/npm-publish.yaml (1 hunks)
  • scripts/is-release-needed.sh (1 hunks)
Additional comments not posted (7)
scripts/is-release-needed.sh (1)

14-15: Add explanatory message before exiting.

Adding a message before exiting improves clarity.

-    exit 0 # release needed
+    echo "Release needed for $PACKAGE_NAME@$PACKAGE_VERSION"
+    exit 0

Likely invalid or redundant comment.

.github/workflows/npm-publish.yaml (6)

19-21: LGTM!

The repository checkout step is correctly implemented.


22-27: LGTM!

The Node.js setup step is correctly implemented.


31-33: LGTM!

The step to make the script executable is correctly implemented.


42-43: Ensure proper authentication setup.

The step to set up the .npmrc file is necessary for authentication.


45-49: Uncomment the npm publish command.

The npm publish command is commented out, which will prevent the package from being published.

- # npm publish --workspace=${{ matrix.package }}
+ npm publish --workspace=${{ matrix.package }}

Likely invalid or redundant comment.


34-41: Fix the usage of echo for output.

Use $GITHUB_OUTPUT to set the output variable properly.

- run: echo "is-release-needed=$IS_RELEASE_NEEDED" >> $GITHUB_OUTPUT
+ run: echo "is-release-needed=$IS_RELEASE_NEEDED" >> $GITHUB_OUTPUT

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between ce303f4 and f26a549.

Files selected for processing (1)
  • .github/workflows/npm-publish.yaml (1 hunks)
Additional comments not posted (4)
.github/workflows/npm-publish.yaml (4)

28-29: LGTM!

The step to install dependencies using npm ci is correct and necessary for the workflow.


31-32: LGTM!

The step to make the is-release-needed.sh script executable is correct and necessary.


42-43: LGTM!

The step to set up the .npmrc file with the npm token is correct and necessary for authentication.


45-49: Uncomment the npm publish command.

The npm publish command is commented out, which will prevent the package from being published.

- # npm publish --workspace=${{ matrix.package }}
+ npm publish --workspace=${{ matrix.package }}

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between f26a549 and 2beb7b3.

Files selected for processing (2)
  • .github/workflows/npm-publish.yaml (1 hunks)
  • scripts/is-release-needed.sh (1 hunks)
Additional comments not posted (4)
scripts/is-release-needed.sh (1)

10-12: Use exit codes instead of echo.

Using exit codes (exit 0 for success and exit 1 for failure) makes the script logic clearer and more conventional.

-    echo 'true' # release needed
+    echo "Release needed for $PACKAGE_NAME@$PACKAGE_VERSION"
+    exit 0
-    echo 'false' # release not needed
+    echo "Release not needed for $PACKAGE_NAME@$PACKAGE_VERSION"
+    exit 1
.github/workflows/npm-publish.yaml (3)

38-40: Fix the usage of echo for output.

Use $GITHUB_OUTPUT to set the output variable properly and remove the redundant command.

- echo "is-release-needed=$IS_RELEASE_NEEDED"
- echo "is-release-needed=$IS_RELEASE_NEEDED" >> $GITHUB_OUTPUT
+ echo "is-release-needed=${{ matrix.package }}=$IS_RELEASE_NEEDED" >> $GITHUB_OUTPUT

42-44: Fix the condition for setting up .npmrc.

Ensure the condition checks the correct output variable.

- if: steps.is-release-needed.outputs.is-release-needed == 'true'
+ if: steps.is-release-needed.outputs["is-release-needed-${{ matrix.package }}"] == 'true'

47-49: Fix the condition for publishing the package.

Ensure the condition checks the correct output variable.

- if: steps.is-release-needed.outputs.is-release-needed == 'true'
+ if: steps.is-release-needed.outputs["is-release-needed-${{ matrix.package }}"] == 'true'

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.

Fix the automated release process

4 participants