ci: create workflow to publish packages#232
Conversation
WalkthroughAdds a dedicated GitHub Actions release workflow triggered on release.published, validates tag-version consistency with packages/federation-sdk/package.json, runs lint/tests/build/bundle, and publishes to NPM. Removes release trigger from CI workflow. Updates package.json to run build before bundling the SDK. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Maintainer
participant GitHub as GitHub Release
participant GHA as Release Workflow
participant Repo as Repo
participant NPM as NPM Registry
Maintainer->>GitHub: Publish release (tag vX.Y.Z)
GitHub-->>GHA: trigger release.published
GHA->>Repo: actions/checkout
GHA->>GHA: Setup Turbo cache
GHA->>GHA: Install Bun
GHA->>Repo: Install dependencies
GHA->>Repo: Lint, Test, Build
GHA->>Repo: bundle:sdk (build && bundle.ts)
GHA->>Repo: Parse packages/federation-sdk/package.json version
alt Tag matches package version
GHA->>NPM: Publish federation-bundle (using NPM token)
NPM-->>GHA: 200 OK
else Mismatch
GHA-->>GHA: Exit with non-zero (fail job)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate 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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #232 +/- ##
=======================================
Coverage 81.67% 81.67%
=======================================
Files 63 63
Lines 4682 4682
=======================================
Hits 3824 3824
Misses 858 858 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.github/workflows/ci.yml(1 hunks).github/workflows/release.yml(1 hunks)package.json(1 hunks)
🔇 Additional comments (2)
package.json (1)
53-53: Build-before-bundle guard looks goodRunning
bun run buildahead ofbundle.tsensures the SDK bundles from fresh artifacts. Looks solid..github/workflows/ci.yml (1)
2-11: CI trigger scope is appropriateLimiting this workflow to PRs and pushes keeps release events on the new dedicated pipeline. No concerns here.
| run: | | ||
| TAG_VERSION="${{ github.event.release.tag_name }}" | ||
| SDK_VERSION=$(jq -r '.version' packages/federation-sdk/package.json) | ||
| if [ "$TAG_VERSION" != "$SDK_VERSION" ]; then | ||
| echo "Tag version ($TAG_VERSION) does not match federation-sdk version ($SDK_VERSION)" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Allow release tags with a leading v.
This comparison will fail for the common convention of tagging releases as vX.Y.Z, since package.json holds X.Y.Z. The workflow would abort even though the versions actually match, blocking every release that keeps the v prefix. Please normalize the tag (and optionally the SDK version) before comparing.
Apply this diff to tolerate the v prefix:
- TAG_VERSION="${{ github.event.release.tag_name }}"
- SDK_VERSION=$(jq -r '.version' packages/federation-sdk/package.json)
- if [ "$TAG_VERSION" != "$SDK_VERSION" ]; then
+ RAW_TAG_VERSION="${{ github.event.release.tag_name }}"
+ TAG_VERSION="${RAW_TAG_VERSION#v}"
+ TAG_VERSION="${TAG_VERSION#V}"
+ SDK_VERSION=$(jq -r '.version' packages/federation-sdk/package.json)
+ if [ "$TAG_VERSION" != "$SDK_VERSION" ]; then
echo "Tag version ($TAG_VERSION) does not match federation-sdk version ($SDK_VERSION)"
exit 1
fi📝 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.
| run: | | |
| TAG_VERSION="${{ github.event.release.tag_name }}" | |
| SDK_VERSION=$(jq -r '.version' packages/federation-sdk/package.json) | |
| if [ "$TAG_VERSION" != "$SDK_VERSION" ]; then | |
| echo "Tag version ($TAG_VERSION) does not match federation-sdk version ($SDK_VERSION)" | |
| exit 1 | |
| fi | |
| run: | | |
| RAW_TAG_VERSION="${{ github.event.release.tag_name }}" | |
| TAG_VERSION="${RAW_TAG_VERSION#v}" | |
| TAG_VERSION="${TAG_VERSION#V}" | |
| SDK_VERSION=$(jq -r '.version' packages/federation-sdk/package.json) | |
| if [ "$TAG_VERSION" != "$SDK_VERSION" ]; then | |
| echo "Tag version ($TAG_VERSION) does not match federation-sdk version ($SDK_VERSION)" | |
| exit 1 | |
| fi |
🤖 Prompt for AI Agents
.github/workflows/release.yml around lines 15 to 21: the workflow fails when
tags are prefixed with "v" because TAG_VERSION is compared directly to
package.json version; normalize the values before comparison by stripping a
leading "v" from the tag (and/or from SDK_VERSION) so "v1.2.3" becomes "1.2.3",
then compare the normalized versions and keep the existing exit-on-mismatch
behavior.
[FED-173]
Summary by CodeRabbit
New Features
Chores