Skip to content

[ci] Enable release-candidates and backport functionality - #841

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
ci-automatically-set-prerelease-and-latest
Apr 23, 2025
Merged

[ci] Enable release-candidates and backport functionality#841
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
ci-automatically-set-prerelease-and-latest

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Apr 22, 2025

Copy link
Copy Markdown
Member

This PR includes refactored pipeline:

  • Automatcially create long-term releasing branch release-X.Y after any tag vX.Y.* has publushed
  • Allow only tags with names vX.Y.Z or vX.Y.Z-rcN
  • Automatically set prerelease option for the release if release is candidate
  • Automatically set latest option for the release according to semver
  • Add a new workflow to backport PRs with backport label into current feature release
  • Do not requrie ok-to-test label for internal PRs

@coderabbitai

coderabbitai Bot commented Apr 22, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

Andrei Kvapil (@kvaps) has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 68401d4 and 63ebab5.

📒 Files selected for processing (4)
  • .github/workflows/backport.yaml (1 hunks)
  • .github/workflows/pull-requests-release.yaml (1 hunks)
  • .github/workflows/pull-requests.yaml (2 hunks)
  • .github/workflows/tags.yaml (3 hunks)

Walkthrough

This set of changes updates and enhances several GitHub Actions workflows. A new workflow for automatic backporting is introduced, which triggers on merged pull requests labeled "backport" and automates the creation of backport pull requests to the latest maintenance branch. The release and tag workflows are improved to handle release candidate tags, enforce stricter tag validation, perform semantic version comparisons, and manage release metadata and branches more robustly. The pull request workflow is updated to differentiate between internal and external contributors, adjusting label requirements accordingly, and simplifying build and test steps.

Changes

File(s) Change Summary
.github/workflows/backport.yaml Added a new workflow for automatic backporting of merged PRs with the "backport" label. Determines the latest maintenance branch and creates a backport PR using an external action.
.github/workflows/pull-requests-release.yaml Improved release workflow: simplified tag extraction, added steps for fetching latest release tag and semver comparison, and enhanced release publishing with dynamic prerelease and latest flags.
.github/workflows/pull-requests.yaml Modified PR workflow: now distinguishes between internal and external PRs for label requirements, and simplified build/test step naming and execution.
.github/workflows/tags.yaml Enhanced tag workflow: supports release candidate tags, stricter tag validation, improved release and branch management, consolidated asset handling, and clearer logging.

Sequence Diagram(s)

sequenceDiagram
    participant PR as Pull Request
    participant Backport Workflow
    participant Repo
    participant Backport Action

    PR->>Backport Workflow: PR closed & merged with "backport" label
    Backport Workflow->>Repo: Fetch latest release tag
    Backport Workflow->>Repo: Determine maintenance branch (release-X.Y)
    Backport Workflow->>Repo: Checkout code
    Backport Workflow->>Backport Action: Create backport PR to maintenance branch
    Backport Action->>Repo: Open backport PR
Loading

Possibly related PRs

  • [ci] Fix release branch matching #800: Introduces a new backport workflow that determines the target maintenance branch using a release tag format without a 'v' prefix, which matches the fix in this PR to the release branch matching regex.

Suggested labels

ok-to-test

Suggested reviewers

  • lllamnyp
  • NickVolynkin

Poem

A hop, a skip, a workflow new,
Backporting magic, releases too!
Tags and branches, all in line,
With semver checks, our builds now shine.
PRs from friends, or forks afar—
The rabbit keeps things up to par!
🐇✨


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.

@kvaps Andrei Kvapil (kvaps) added ok-to-test Indicates a non-member PR is safe to run CI on backport Should change be backported on previous release labels Apr 22, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/tags.yaml (1)

85-85: Remove trailing spaces and extra spacing around colons
YAMLlint flagged trailing spaces at lines 85, 110, 248 and excessive spaces after colons at lines 133–134. Cleaning these up will satisfy lint checks and avoid CI warnings.

Also applies to: 110-110, 133-134, 248-248

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 85-85: too many spaces after colon

(colons)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b9112a3 and 68401d4.

📒 Files selected for processing (4)
  • .github/workflows/backport.yaml (1 hunks)
  • .github/workflows/pull-requests-release.yaml (1 hunks)
  • .github/workflows/pull-requests.yaml (2 hunks)
  • .github/workflows/tags.yaml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-requests-release.yaml

77-77: property "check_release" is not defined in object type {get_tag: {conclusion: string; outcome: string; outputs: object}}

(expression)

🪛 YAMLlint (1.35.1)
.github/workflows/tags.yaml

[warning] 85-85: too many spaces after colon

(colons)


[error] 110-110: trailing spaces

(trailing-spaces)


[warning] 133-133: too many spaces after colon

(colons)


[warning] 134-134: too many spaces after colon

(colons)


[error] 248-248: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (25)
.github/workflows/pull-requests.yaml (3)

15-19: Clear CI execution comments
The new comments concisely explain the intent of the condition: internal PRs run automatically, forks need “ok-to-test”, and any PR with a “release” label is skipped. This enhances readability and maintainability.


21-28: Differentiate internal vs external contributors in if condition
The updated if: expression correctly allows runs for same‑repo PRs and gates forked PRs behind the ok-to-test label, while always skipping on release. This aligns with best practices for contributor workflows.


44-49: Simplify build and test steps
Renaming the steps to “Build” and “Test” with single-line make commands improves clarity and reduces boilerplate.

.github/workflows/backport.yaml (4)

3-5: Use pull_request_target to grant write permissions
Triggering on pull_request_target is intentional here to allow the workflow to push backport PRs using the base‑repo’s token. Ensure this is documented and desired.

Please confirm that exposing the workflow to pull_request_target does not conflict with any security policies for untrusted code.


13-16: Gate backport job on merge and label
The if: condition correctly fires only when a PR is merged and labeled backport. This prevents unintended runs and aligns with the PR objective.


34-37: Standard checkout for backport
Using actions/checkout@v4 without depth limits is correct to ensure the backport action can create branches and PRs.


38-44: Invoke backport-action with explicit target branch
Supplying target_branches from your computed output is the right approach. Setting label_pattern: '' avoids unintended label inheritances.

.github/workflows/pull-requests-release.yaml (4)

42-46: Restrict finalize job to merged “release” PRs
The if: now ensures the finalize job only runs after a PR with the release label is merged. This prevents premature tagging and release operations.


55-63: Enhanced tag extraction supports suffixes
The regex /^release-(\d+\.\d+\.\d+(?:[-\w\.]+)?)$/ now handles RC and other suffixes, improving flexibility for prereleases.


69-74: Force-update annotated tag on merge
Using -f for git tag and git push guarantees that the tag points to the merge commit. This is appropriate for override scenarios.


118-139: Publish draft release with dynamic flags
Using prerelease and make_latest parameters provides full control over the release metadata, supporting RC and legacy behaviors. The logging is clear and actionable.

.github/workflows/tags.yaml (14)

6-6: Support RC tags in workflow trigger
Changing the push filter to v*.*.* allows both standard and -rcN tags, enabling prerelease flows.


19-31: Check existing non-draft release before proceeding
Detecting if a release exists and skipping the rest of the workflow prevents duplicate publishes. The logic using some() is efficient.


38-58: Parse tag metadata for semantic versioning
Extracting tag, version, is_rc, and line via a single regex and outputs streamlines downstream steps.


69-76: Validate base branch origin
Ensuring tags are pushed from main or release-X.Y with clear failure messages guards against misdirected tag pushes.


85-88: Fetch full history and tags
Adding fetch-tags: true ensures annotations for existing tags are present in the runner, which is crucial for tag-based workflows.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 85-85: too many spaces after colon

(colons)


95-99: Build project artifacts before release
The consolidated make build step remains appropriately gated and clear.


101-109: Commit built artifacts with sign-off
Including -s in git commit signs off the actions bot, following DCO requirements and capturing attribution.


111-127: Retrieve latest published release for comparison
Wrapping getLatestRelease in a try/catch captures the absence of prior releases gracefully and outputs a blank tag for semver comparison.


128-135: Semver comparison determines “outdated” status
Using madhead/semver-utils to compare the pushed tag against the latest published release is an effective way to drive “make_latest” logic.

🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 133-133: too many spaces after colon

(colons)


[warning] 134-134: too many spaces after colon

(colons)


137-161: Create or reuse draft release dynamically
This block correctly handles idempotent draft release creation, setting prerelease for RCs and a legacy make_latest flag for monolithic releases.


178-183: Ensure maintenance branch exists for new line
Auto-creating release-X.Y when tagging from main maintains your maintenance workflow without manual intervention.


204-210: Force-update release branch to tag SHA
Creating and force-pushing the release-X.Y.Z branch guarantees consistency between the tag and the branch, simplifying backport and release PR flows.


212-219: Auto-generate release PR if missing
Checking for an existing PR and only creating one when absent prevents duplicate PR chatter and streamlines the release process.


247-251: Standardize final test step name
Renaming to “Test” for consistency with other workflows improves the uniformity of CI logs.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 248-248: trailing spaces

(trailing-spaces)

Comment thread .github/workflows/backport.yaml Outdated
Comment thread .github/workflows/pull-requests-release.yaml Outdated
Comment thread .github/workflows/pull-requests-release.yaml
@kvaps
Andrei Kvapil (kvaps) force-pushed the ci-automatically-set-prerelease-and-latest branch from 68401d4 to 5295a18 Compare April 22, 2025 15:46
Comment on lines +3 to +5
on:
pull_request_target:
types: [closed] # fires when PR is closed (merged)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why pull_request_target and not just pull_request? If we need the merge commit, we should probably use the latter

pull_request_target: This event runs in the context of the base of the pull request, rather than in the context of the merge commit, as the pull_request event does.

Suggested change
on:
pull_request_target:
types: [closed] # fires when PR is closed (merged)
on:
pull_request_target:
types: [closed] # fires when PR is closed (merged)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see, it's what https://github.com/korthout/backport-action readme suggests.

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
label_pattern: '' # don't read labels for targets
target_branches: ${{ steps.target.outputs.branch }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request titles become commit titles, so let's make it shorter.

The default title was [Backport ${target_branch}] ${pull_title}

Suggested change
target_branches: ${{ steps.target.outputs.branch }}
target_branches: ${{ steps.target.outputs.branch }}
pull_title: "[backport] ${pull_title}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it is better to keep PR title as is, because the next step would be to enable backports to other branches as well

Comment thread .github/workflows/pull-requests-release.yaml Outdated
@kvaps
Andrei Kvapil (kvaps) force-pushed the ci-automatically-set-prerelease-and-latest branch from 77a9adc to c093477 Compare April 22, 2025 16:49
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps
Andrei Kvapil (kvaps) force-pushed the ci-automatically-set-prerelease-and-latest branch from c093477 to 63ebab5 Compare April 22, 2025 16:49
@kvaps Andrei Kvapil (kvaps) removed the ok-to-test Indicates a non-member PR is safe to run CI on label Apr 22, 2025
@kvaps
Andrei Kvapil (kvaps) merged commit e81cbf7 into main Apr 23, 2025
@kvaps
Andrei Kvapil (kvaps) deleted the ci-automatically-set-prerelease-and-latest branch April 23, 2025 10:06
@github-actions

Copy link
Copy Markdown

Successfully created backport PR for release-0.30:

Andrei Kvapil (kvaps) added a commit that referenced this pull request Apr 23, 2025
…unctionality (#853)

# Description
Backport of #841 to `release-0.30`.
Nick Volynkin (NickVolynkin) added a commit that referenced this pull request Apr 23, 2025
Cherry-picking patches that came before
#841
was merged. 

* Used `git cherry-pick -x -m1 <sha1>` on merge commits of respective
pull requests.
* Added `Co-authored-by` where the author of the changes was not the one
who merged the PR (and authored the merge commit).

Signed-off-by: Nick Volynkin <nick.volynkin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Should change be backported on previous release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants