release: automate GitHub releases#278
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds automated GitHub Release creation and a manual backfill workflow. The release workflow determines a single repo-wide release version from public Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Maintainer
participant Actions as "GitHub Actions"
participant Registry as "npm Registry"
participant GitHub as "GitHub API (gh)"
Maintainer->>Actions: Push merge to main / trigger workflow
Actions->>Actions: Checkout (persist-credentials:false)
Actions->>Actions: Run tools/release-version.cjs -> determine VERSION
Actions->>Registry: (backfill) npm view `@tko/build.reference`@VERSION
Registry-->>Actions: responds (exists / not found)
Actions->>GitHub: gh release view vVERSION (check tag)
alt tag absent
Actions->>GitHub: gh release create vVERSION --generate-notes [--prerelease if alpha/beta/rc]
GitHub-->>Actions: release created
else tag exists & points to same SHA
Actions-->>Maintainer: No-op success
else tag exists & points elsewhere
Actions-->>Maintainer: Fail workflow
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/release.yml (1)
116-118: Consider adding error handling for version extraction.If
lerna.jsonis missing or malformed, the Node.js command will fail with an error. While this is acceptable in CI (the job would fail visibly), you could add a validation step for clearer error messages.💡 Optional: Add version validation
- name: Determine release version id: version - run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT" + run: | + version=$(node -p 'require("./lerna.json").version') + if [ -z "$version" ]; then + echo "::error::Could not determine version from lerna.json" + exit 1 + fi + echo "version=$version" >> "$GITHUB_OUTPUT"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 116 - 118, The "Determine release version" step currently runs a raw node command to read lerna.json which can throw if the file is missing or malformed; update the step (id: version) to run a small Node script that catches errors, validates the parsed object has a string version, and prints a clear error to stderr and exits non‑zero if validation fails, otherwise echo "version=<version>" to GITHUB_OUTPUT; include contextual messages like "Failed to read lerna.json" or "Invalid version field in lerna.json" to make CI failures easy to understand.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/release.yml:
- Around line 116-118: The "Determine release version" step currently runs a raw
node command to read lerna.json which can throw if the file is missing or
malformed; update the step (id: version) to run a small Node script that catches
errors, validates the parsed object has a string version, and prints a clear
error to stderr and exits non‑zero if validation fails, otherwise echo
"version=<version>" to GITHUB_OUTPUT; include contextual messages like "Failed
to read lerna.json" or "Invalid version field in lerna.json" to make CI failures
easy to understand.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ced91c27-31c9-4408-84e3-aa148fddf0d3
📒 Files selected for processing (4)
.github/workflows/release.ymlAGENTS.mdREADME.mdplans/build-and-release-certainty.md
There was a problem hiding this comment.
Pull request overview
Adds a post-publish GitHub Release/tag creation step to the existing Changesets-based release workflow, and updates documentation to reflect the new automated GitHub Release boundary.
Changes:
- Add a
github-releasejob that creates a GitHub Release (idempotently) after a successful npm publish. - Update contributor/release documentation to mention GitHub Releases are created by CI.
- Extend the release plan doc to include the new GitHub Release/tag step.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README.md | Updates the release workflow description to include GitHub Release creation. |
| plans/build-and-release-certainty.md | Documents the additional post-publish GitHub Release/tag step. |
| AGENTS.md | Updates workflow table and release process steps to mention GitHub Release/tag creation. |
| .github/workflows/release.yml | Adds a post-publish job to create a GitHub Release/tag if missing. |
|
|
||
| - name: Determine release version | ||
| id: version | ||
| run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
The Determine release version step is over-escaped. As written, the shell runs node -p 'require(\"./lerna.json\").version', which includes literal backslashes inside the JavaScript expression (because it’s inside single quotes) and will cause a syntax error. Remove the unnecessary escaping so the Node expression is valid (e.g., require("./lerna.json") should not have backslashes when wrapped in single quotes).
| run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT" | |
| run: echo "version=$(node -p 'require("./lerna.json").version')" >> "$GITHUB_OUTPUT" |
|
|
||
| - name: Determine release version | ||
| id: version | ||
| run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
The release tag/version is derived from lerna.json, but the workflow’s versioning/publishing is driven by Changesets (npx changeset version / npx changeset publish). Changesets does not inherently guarantee lerna.json stays in sync with the published package versions, so this can create a GitHub Release tag that doesn’t match what was just published. Consider sourcing the version from a package that is definitely versioned by Changesets (e.g., a canonical published package.json), or adjust the versioning step so lerna.json is updated as part of the version PR.
| run: echo "version=$(node -p 'require(\"./lerna.json\").version')" >> "$GITHUB_OUTPUT" | |
| run: echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT" |
Summary
Testing
Summary by CodeRabbit