Skip to content

Conversation

@alexandre-abrioux
Copy link
Contributor

@alexandre-abrioux alexandre-abrioux commented Mar 4, 2025

This is a fixup for #1576
It is related to #1503 and #1442

Issue

In #1576, I introduced the --canary option, which appends the Git hash to prerelease tags to prevent duplicate versions.

This worked well on my local setup (when testing the yarn run publish-prerelease command), but unfortunately, something goes wrong when it runs in the CI, and I have not been able to find out why.

For some reason, the version created on the CI is wrong. For instance, the @requestnetwork/data-access package was published with version 0.23.1-next.783+2b7c9697 (see here in the CI) instead of 0.44.1-next.2132+2b7c9697 (see previous PR description where the command was run on my local env). The version number is completely off and shows the same behavior we suffered in #1442.

It seems related to lerna/lerna#2622. Unfortunately, browsing this issue does not disclose any viable solution for now. Perhaps updating Lerna could work (not tested), but that's for another time. I have found another workaround for now.

Workaround

The workaround is to revert #1576 and instead use the git command to append the Git hash to the version tag.

I have tested the command in the CI (see the first commit of this PR), and it works properly.

The output version will be slightly different: 0.44.1-next.21e95031.0, but I find it acceptable.

Let me know what you think.

Summary by CodeRabbit

  • Chores
    • Enhanced the pre-release process by dynamically appending a unique identifier to each version. This change improves release traceability, ensuring that pre-release versions clearly reflect the current state of the codebase.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2025

Walkthrough

This PR updates the publishing scripts in package.json by removing the --canary flag and incorporating a dynamic identifier based on the current Git commit's short hash. Both the publish-manual-prerelease and publish-prerelease scripts now use --preid next.$(git rev-parse --short HEAD) and --dist-tag next.$(git rev-parse --short HEAD) instead of the static "next", enabling more precise traceability of pre-release versions.

Changes

File(s) Change Summary
package.json Modified the publish-manual-prerelease and publish-prerelease scripts: removed the --canary flag and updated the --preid and --dist-tag options to append $(git rev-parse --short HEAD) to the static identifier "next".

Possibly related PRs

Suggested reviewers

  • rodrigopavezi
  • kevindavee
  • leoslr
  • aimensahnoun
  • MantisClone
  • yomarion

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@alexandre-abrioux alexandre-abrioux marked this pull request as ready for review March 5, 2025 00:17
@alexandre-abrioux alexandre-abrioux changed the title ci: fix next-release ci: fix next-release with git tag Mar 5, 2025
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

🧹 Nitpick comments (2)
package.json (2)

28-28: Refactor: Optimize repeated command substitution for Git hash.
The updated "publish-manual-prerelease" script correctly appends the Git commit's short hash for dynamic pre-release versioning. As a refinement, consider storing the result of $(git rev-parse --short HEAD) in an environment variable to avoid invoking the command twice. This change would improve readability and execution efficiency, especially if the command’s output needs to be consistent across multiple options.

For example, you could refactor as follows:

-"lerna publish prerelease --no-git-tag-version --no-push --preid next.$(git rev-parse --short HEAD) --dist-tag next.$(git rev-parse --short HEAD)"
+"GIT_HASH=$(git rev-parse --short HEAD) && lerna publish prerelease --no-git-tag-version --no-push --preid next.$GIT_HASH --dist-tag next.$GIT_HASH"

29-29: Review: Validate FORCE_PUBLISH usage and dynamic Git hash integration.
The "publish-prerelease" script correctly calculates FORCE_PUBLISH and integrates the dynamic pre-release identifier using the Git hash. Similar to the previous script, consider reusing the computed Git hash by storing it in an environment variable to avoid redundant command calls. Additionally, ensure that echoing the FORCE_PUBLISH variable is intended for logging purposes and does not expose sensitive information.

A possible refactor option could be:

-FORCE_PUBLISH=$(lerna changed --json | jq '. | map(.name) | join (\",\")' -r) && echo $FORCE_PUBLISH && lerna publish prerelease --no-git-tag-version --no-push --preid next.$(git rev-parse --short HEAD) --dist-tag next.$(git rev-parse --short HEAD) --yes --force-publish=${FORCE_PUBLISH}
+GIT_HASH=$(git rev-parse --short HEAD) && \
+FORCE_PUBLISH=$(lerna changed --json | jq '. | map(.name) | join (\",\")' -r) && \
+echo $FORCE_PUBLISH && \
+lerna publish prerelease --no-git-tag-version --no-push --preid next.$GIT_HASH --dist-tag next.$GIT_HASH --yes --force-publish=${FORCE_PUBLISH}

This approach minimizes redundant git calls and improves maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b7c969 and 3d857c1.

📒 Files selected for processing (1)
  • package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test

@alexandre-abrioux alexandre-abrioux enabled auto-merge (squash) March 10, 2025 13:17
@alexandre-abrioux alexandre-abrioux merged commit a312eb9 into master Mar 10, 2025
10 checks passed
@alexandre-abrioux alexandre-abrioux deleted the fix-prerelease branch March 10, 2025 13:40
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.

5 participants