Skip to content

fix: correct Homebrew formula URL generation in release workflow#22

Merged
utkarsh232005 merged 1 commit into
KDM-cli:mainfrom
utkarsh232005:fix/homebrew-formula-heredoc-interpolation
Jun 1, 2026
Merged

fix: correct Homebrew formula URL generation in release workflow#22
utkarsh232005 merged 1 commit into
KDM-cli:mainfrom
utkarsh232005:fix/homebrew-formula-heredoc-interpolation

Conversation

@utkarsh232005
Copy link
Copy Markdown
Member

@utkarsh232005 utkarsh232005 commented Jun 1, 2026

Problem

The Generate Homebrew Formula step in release.yml used an unquoted heredoc (<<EOF). This caused the shell to interpret Ruby's #{version} interpolation syntax as a shell comment (# starts a comment in bash), stripping {version} and leaving literal ${version} unexpanded in the generated formula URLs.

This is what the broken formula looked like:

url "https://github.com/KDM-cli/kdc-cli/releases/download/v${version}/kdc-v${version}-aarch64-apple-darwin.tar.gz"

Which caused brew install KDM-cli/tap/kdc to fail with a bad URI error.

Fix

  • Switch to a quoted heredoc (<<'FORMULA_TEMPLATE') so the shell does not touch any # or $ characters inside it
  • Use envsubst to substitute only the known shell variables ($VERSION, $REPO, checksums) after the template is written
  • Ruby's #{bin} in the test block is left untouched by envsubst since it is not in the substitution list

Result

The generated formula now has hardcoded version strings in all URLs, which is the correct approach for a Homebrew formula.

Summary by CodeRabbit

  • Chores
    • Improved the Homebrew formula generation process during releases to enhance build reliability and consistency.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 93fd1ee1-f2ce-4569-8171-f75d301a0b49

📥 Commits

Reviewing files that changed from the base of the PR and between 257dd0d and 476a7f6.

📒 Files selected for processing (1)
  • .github/workflows/release.yml

📝 Walkthrough

Walkthrough

The release workflow now generates the Homebrew formula by separating template definition from substitution. SHA256 checksums are extracted into shell variables from the checksums file, a quoted heredoc template is written with deferred ${...} placeholders, and envsubst substitutes only the selected variables into the final formula.

Changes

Homebrew Formula Generation via Deferred Substitution

Layer / File(s) Summary
Template definition and SHA256 metadata extraction
.github/workflows/release.yml
The workflow defines REPO from GitHub context, extracts SHA256 values for macOS/Linux on arm64/x86_64 from dist/sha256sums.txt via grep, and writes a quoted heredoc template to /tmp/kdc.rb.tpl with ${VERSION}, ${REPO}, and ${SHA_*} placeholders that are not expanded by the shell during template creation.
Template rendering via envsubst substitution
.github/workflows/release.yml
The workflow exports a controlled set of shell variables and runs envsubst to substitute only those ${...} placeholders from the template into dist/kdc.rb, preserving Ruby interpolation syntax and other template structure that is not part of the substitution set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • KDM-cli/kdc-cli#12: This PR refines the Homebrew formula generation step introduced in the original release workflow by switching from inline GitHub context interpolation to deferred heredoc templating and envsubst-based substitution.

Poem

🍺 A heredoc whispers secrets safe,
envsubst renders them with grace,
No shell expansion spoils the day,
SHA checksums find their way,
Ruby keeps its #{...} in place! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@utkarsh232005 utkarsh232005 merged commit 4c1d734 into KDM-cli:main Jun 1, 2026
2 of 3 checks passed
Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Our agent can fix these. Install it.

No application code in the PR — skipped Code Health checks.

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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