Skip to content

fix: Improve release #322

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

Merged
merged 3 commits into from
Nov 9, 2024
Merged

fix: Improve release #322

merged 3 commits into from
Nov 9, 2024

Conversation

ponderingdemocritus
Copy link
Contributor

@ponderingdemocritus ponderingdemocritus commented Nov 8, 2024

  • updates yaml

Summary by CodeRabbit

  • New Features

    • Enhanced release process with automated tagging and publishing.
    • Introduced a new step for creating GitHub releases based on changelog output.
  • Improvements

    • Updated changelog generation to use a more robust tool, improving accuracy and efficiency.
    • Streamlined CI workflow by removing the specific SSH key requirement for repository access.

Copy link

coderabbitai bot commented Nov 8, 2024

Walkthrough

The pull request modifies the GitHub Actions workflow configuration for the release process. Key changes include the addition of a new step for capturing tagging and publishing outputs, the update of the changelog generation tool, and the introduction of a new step to create a GitHub release. The workflow now uses npx standard-version for changelog generation and integrates parameters for creating releases based on the tagging output. Additionally, the CI workflow has been adjusted by removing a specific SSH key from the checkout step.

Changes

File Path Change Summary
.github/workflows/release.yaml - New step added: id: tag_publish
- Step name updated to Generate Changelog with standard-version
- New step added: Create GitHub Release
.github/workflows/ci.yaml - Removed with block specifying ssh-key for actions/checkout@v4
- Commented-out lines for Codecov coverage upload remain

Possibly related PRs

  • feat: Torii upgrade #303: The changes in the CI workflow configuration in this PR involve updates to the .github/workflows/ci.yaml file, which is relevant as the main PR also modifies a workflow file, specifically .github/workflows/release.yaml. Both PRs focus on enhancing CI/CD processes.
  • fix: bump version #309: Similar to the main PR, this PR updates the CI workflow in .github/workflows/ci.yaml, indicating a focus on versioning and release processes, which aligns with the changes made in the main PR regarding release tagging and publishing steps.

🐰 In the meadow, hops a little hare,
With tags and releases, we handle with care.
A changelog now crafted with a new flair,
GitHub releases, a breeze in the air!
Through workflows we dance, with joy we declare,
Our process is smoother, oh what a rare! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c28c5dd and de13d64.

📒 Files selected for processing (1)
  • .github/workflows/ci.yaml (0 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/ci.yaml

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>, 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 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.

@ponderingdemocritus ponderingdemocritus changed the title Improve release fix: Improve release Nov 8, 2024
Copy link

@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

🧹 Outside diff range and nitpick comments (2)
.github/workflows/release.yaml (2)

48-50: Configure standard-version with a configuration file

Using command-line flags makes the configuration harder to maintain and version control. Consider moving the configuration to a .versionrc.json file.

Create a .versionrc.json file:

{
  "tagPrefix": "v",
  "skip": {
    "bump": true,
    "commit": true,
    "tag": true
  },
  "types": [
    {"type": "feat", "section": "Features"},
    {"type": "fix", "section": "Bug Fixes"},
    {"type": "chore", "section": "Maintenance"},
    {"type": "docs", "section": "Documentation"},
    {"type": "style", "section": "Styling"},
    {"type": "refactor", "section": "Refactors"},
    {"type": "perf", "section": "Performance"},
    {"type": "test", "section": "Tests"}
  ]
}

Then modify the step:

- npx standard-version --tag-prefix v --commit-all
+ npx standard-version

Line range hint 1-69: Consider adding error handling and conditional steps

The workflow could benefit from some reliability improvements:

  1. Add condition checks between critical steps
  2. Include error handling for npm publish failures
  3. Add cleanup steps for failed runs

Consider these modifications:

  1. Add conditions to prevent subsequent steps from running if a critical step fails:
- name: Build packages
  id: build
  run: pnpm run build

- name: Tag and Publish Packages
  if: success() && steps.build.outcome == 'success'
  id: tag_publish
  ...

- name: Generate Changelog
  if: success() && steps.tag_publish.outcome == 'success'
  ...
  1. Add a cleanup step:
- name: Cleanup on failure
  if: failure()
  run: |
    git tag -d ${{ steps.tag_publish.outputs.TAG }} || true
    git reset --hard HEAD~1 || true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c6d2a17 and c28c5dd.

📒 Files selected for processing (1)
  • .github/workflows/release.yaml (2 hunks)

Comment on lines +60 to +69
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_publish.outputs.TAG }}
release_name: Release ${{ steps.tag_publish.outputs.TAG }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace deprecated action and improve release content

The actions/create-release@v1 action is deprecated. Additionally, using the entire CHANGELOG.md file might include historical entries irrelevant to this release.

Replace with the newer softprops/action-gh-release action:

- name: Create GitHub Release
- uses: actions/create-release@v1
- env:
-   GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
-   tag_name: ${{ steps.tag_publish.outputs.TAG }}
-   release_name: Release ${{ steps.tag_publish.outputs.TAG }}
-   body_path: CHANGELOG.md
-   draft: false
-   prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
+ name: Create GitHub Release
+ uses: softprops/action-gh-release@v1
+ with:
+   tag_name: ${{ steps.tag_publish.outputs.TAG }}
+   name: Release ${{ steps.tag_publish.outputs.TAG }}
+   body: |
+     # Release Notes
+     $(cat CHANGELOG.md | sed -n "/^## \[${{ steps.tag_publish.outputs.TAG }}/,/^## \[/p" | sed '$d')
+   draft: false
+   prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
+   token: ${{ secrets.GITHUB_TOKEN }}

This change:

  1. Uses a maintained action
  2. Extracts only the relevant section from CHANGELOG.md
  3. Adds a better formatted release body
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_publish.outputs.TAG }}
release_name: Release ${{ steps.tag_publish.outputs.TAG }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_publish.outputs.TAG }}
name: Release ${{ steps.tag_publish.outputs.TAG }}
body: |
# Release Notes
$(cat CHANGELOG.md | sed -n "/^## \[${{ steps.tag_publish.outputs.TAG }}/,/^## \[/p" | sed '$d')
draft: false
prerelease: ${{ contains(github.event.inputs.release_type, 'pre') }}
token: ${{ secrets.GITHUB_TOKEN }}

Comment on lines +43 to 47
id: tag_publish
run: |
npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish
npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }}

Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Keep --force-publish flag and add explicit output capture

The --force-publish flag is necessary due to the extensive interdependencies between packages. The packages form a complex dependency graph where:

  • sdk depends on core, create-burner, and torii-client
  • react depends on state, torii-client, and utils
  • state depends on torii-client
  • Multiple packages depend on torii-client

Only add the output capture modification:

  id: tag_publish
  run: |
+     echo "TAG=$(npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish | tail -n 1)" >> $GITHUB_OUTPUT
-     npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish
      npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }}
🔗 Analysis chain

Add explicit output capture for the tag version

The step ID tag_publish suggests this step should output the tag version, but there's no explicit output capture. This could cause the subsequent GitHub Release step to fail.

Apply this modification:

  id: tag_publish
  run: |
+     echo "TAG=$(npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish | tail -n 1)" >> $GITHUB_OUTPUT
-     npx lerna version ${{ github.event.inputs.release_type }} --conventional-commits --yes --no-private --force-publish
      npx lerna publish from-git --yes --dist-tag ${{ github.event.inputs.release_type == 'preminor' && 'next' || 'latest' }}

Also, consider removing the --force-publish flag unless absolutely necessary, as it bypasses version checks and could lead to unintended publications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if force-publish is really needed by looking for dependencies between packages
rg -l "workspace:.*" packages/*/package.json

Length of output: 510


Script:

#!/bin/bash
# Let's check the actual workspace dependencies in these packages
for file in packages/torii-client/package.json packages/state/package.json packages/sdk/package.json packages/create-burner/package.json packages/react/package.json packages/core/package.json; do
    echo "=== $file ==="
    cat "$file" | jq '.dependencies,.devDependencies' | grep -A1 "workspace:"
done

Length of output: 2793

@ponderingdemocritus ponderingdemocritus merged commit 52cca8a into main Nov 9, 2024
3 checks passed
@ponderingdemocritus ponderingdemocritus deleted the improve-release branch November 9, 2024 00:42
This was referenced Nov 11, 2024
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.

1 participant