Skip to content

feat: add workspace support - #20

Merged
cdunster merged 4 commits into
mainfrom
add-workspace-support
Jul 7, 2026
Merged

feat: add workspace support#20
cdunster merged 4 commits into
mainfrom
add-workspace-support

Conversation

@cdunster

@cdunster cdunster commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Automatically detect if the project is in a workspace and use the --workspace flag for npm release if it is. The new version_file input is required to know where to read the new version from and to get the package name to check if that version already exists.

This assumes that all the packages are released under the same version.

This successfully worked with publishing v0.0.8 of the NPM test repo: https://github.com/holochain/npm-release-test/actions/runs/28855732581

@cdunster cdunster self-assigned this Jul 1, 2026
@cdunster
cdunster requested a review from a team July 1, 2026 15:54
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Changes

Related PRs: None specified.
Suggested reviewers: ThetaSinner, jost-s

The reusable publish workflow now accepts workspace_main_package and forwards it to the publish action. The publish action now resolves package metadata from a workspace main package when needed, publishes and packs with workspace-aware npm behavior, and handles GitHub release creation or updates using multiple tarballs. The prepare-release workflow now detects workspaces and adjusts version bump behavior for npm, yarn, and pnpm. The README adds release process documentation and workspace-specific usage notes.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding workspace support.
Description check ✅ Passed The description is related to the PR and describes workspace detection and version handling, despite some naming differences.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-workspace-support

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.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nodejs-publish/action.yml (1)

61-91: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Detect workspaces from the root package.json

inputs.version_file is documented to point at a package-level ./package.json for workspace projects, so require(process.env.VERSION_FILE).workspaces will stay empty and --workspaces never gets added. Read the root manifest here (or add a separate root input) in both steps.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nodejs-publish/action.yml` around lines 61 - 91, The workspace detection in
the Publish to npm and Pack npm artifact steps is reading inputs.version_file,
which points at a package-level manifest and can miss the root workspaces field.
Update the logic in both bash blocks to read the root package.json for workspace
detection, or introduce a dedicated root manifest input, and keep the existing
WORKSPACES_FLAGS and npm publish/npm pack flow unchanged otherwise.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nodejs-publish/action.yml`:
- Around line 16-21: The Get version step in action.yml is hiding failures from
the node -p call because the command substitution is wrapped inside echo, so a
bad VERSION_FILE can silently produce an empty output. Update the version
retrieval logic so the node invocation is executed as a standalone
command/assignment in the Get version step, letting bash errexit fail the step
immediately; keep the id version and GITHUB_OUTPUT write path, but ensure the
version read from process.env.VERSION_FILE cannot be swallowed by echo.
- Around line 116-138: The release asset upload path in the `gh release edit`
branch is not idempotent because `gh release upload` will fail on duplicate
tarball names during reruns. Update the upload loop in `action.yml` to make `gh
release upload` safe for retries, using `--clobber` or equivalent pre हट removal
of existing assets, while preserving the existing `RELEASE_VERSION`,
`TARBALL_ARGS`, and release edit/create flow.

---

Outside diff comments:
In `@nodejs-publish/action.yml`:
- Around line 61-91: The workspace detection in the Publish to npm and Pack npm
artifact steps is reading inputs.version_file, which points at a package-level
manifest and can miss the root workspaces field. Update the logic in both bash
blocks to read the root package.json for workspace detection, or introduce a
dedicated root manifest input, and keep the existing WORKSPACES_FLAGS and npm
publish/npm pack flow unchanged otherwise.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7ceb94a5-29ea-498c-8517-610076ef8a23

📥 Commits

Reviewing files that changed from the base of the PR and between 686ba4a and e9c3580.

📒 Files selected for processing (2)
  • .github/workflows/nodejs-publish-release.yml
  • nodejs-publish/action.yml

Comment thread nodejs-publish/action.yml Outdated
Comment thread nodejs-publish/action.yml
jost-s
jost-s previously approved these changes Jul 2, 2026

@jost-s jost-s left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If it works, I won't object!

@cdunster
cdunster force-pushed the add-workspace-support branch 2 times, most recently from 5b06c2a to 8eb116a Compare July 6, 2026 13:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
nodejs-publish/action.yml (2)

70-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated workspace-detection logic across two steps.

The WORKSPACES_FLAGS detection block (node -e "const p = require('./package.json')...") is copy-pasted identically in both "Publish to npm" (lines 70-73) and "Pack npm artifact" (lines 85-88). Any future change to the detection logic (e.g., supporting a different workspaces config shape) risks drifting between the two copies.

Consider hoisting this into a single earlier step (e.g., "Detect workspace") that writes a GITHUB_OUTPUT value, then reference it via steps.<id>.outputs.is_workspace in both downstream steps.

♻️ Proposed refactor
+    - name: Detect workspace
+      id: workspace
+      shell: bash
+      run: |
+        if node -e "const p = require('./package.json'); process.exit(p.workspaces ? 0 : 1)" 2>/dev/null; then
+          echo "is_workspace=true" >> "$GITHUB_OUTPUT"
+        else
+          echo "is_workspace=false" >> "$GITHUB_OUTPUT"
+        fi
+
     - name: Publish to npm
       shell: bash
       env:
         RELEASE_VERSION: ${{ steps.version.outputs.value }}
         NODE_AUTH_TOKEN: ${{ inputs.npm_token }}
         GITHUB_TOKEN: ${{ github.token }} # Required for napi-rs support
       run: |
         WORKSPACES_FLAGS=()
-        if node -e "const p = require('./package.json'); process.exit(p.workspaces ? 0 : 1)" 2>/dev/null; then
+        if [ "${{ steps.workspace.outputs.is_workspace }}" = "true" ]; then
           WORKSPACES_FLAGS=("--workspaces")
         fi
         ...

     - name: Pack npm artifact
       id: pack
       shell: bash
       run: |
         WORKSPACES_FLAGS=()
-        if node -e "const p = require('./package.json'); process.exit(p.workspaces ? 0 : 1)" 2>/dev/null; then
+        if [ "${{ steps.workspace.outputs.is_workspace }}" = "true" ]; then
           WORKSPACES_FLAGS=("--workspaces")
         fi
         ...
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nodejs-publish/action.yml` around lines 70 - 90, The workspace-detection
logic is duplicated in both the publish and pack steps, so move the `node -e`
check into a single earlier step (for example, a dedicated workspace detection
step) and write the result to `GITHUB_OUTPUT`. Then update both `Publish to npm`
and `Pack npm artifact` to read the shared output instead of rebuilding
`WORKSPACES_FLAGS` locally, keeping the existing behavior in sync.

22-23: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

version_file requires a ./-prefixed (or absolute) path to resolve via require().

require(process.env.VERSION_FILE) treats strings not starting with ./, ../, or / as a module-lookup, not a relative file path. The input description documents the ./ convention, and a misconfigured value will now fail loudly (good, thanks to the earlier fix) rather than silently — but the failure message (Cannot find module '<value>') may confuse consumers who omit the prefix.

Optionally normalize the path defensively, e.g. path.resolve(process.cwd(), process.env.VERSION_FILE), to accept paths with or without the ./ prefix.

Also applies to: 32-32

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nodejs-publish/action.yml` around lines 22 - 23, The VERSION_FILE lookup in
the action’s version-reading step still assumes a require()-resolvable path, so
inputs without a ./, ../, or / prefix will be treated as module names and fail
confusingly. Update the version extraction logic around the node -p
require(process.env.VERSION_FILE) usage to normalize the input path first, such
as by resolving it from process.cwd(), so the action accepts version_file values
with or without a ./ prefix while keeping the existing output assignment to
GITHUB_OUTPUT intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@nodejs-publish/action.yml`:
- Around line 70-90: The workspace-detection logic is duplicated in both the
publish and pack steps, so move the `node -e` check into a single earlier step
(for example, a dedicated workspace detection step) and write the result to
`GITHUB_OUTPUT`. Then update both `Publish to npm` and `Pack npm artifact` to
read the shared output instead of rebuilding `WORKSPACES_FLAGS` locally, keeping
the existing behavior in sync.
- Around line 22-23: The VERSION_FILE lookup in the action’s version-reading
step still assumes a require()-resolvable path, so inputs without a ./, ../, or
/ prefix will be treated as module names and fail confusingly. Update the
version extraction logic around the node -p require(process.env.VERSION_FILE)
usage to normalize the input path first, such as by resolving it from
process.cwd(), so the action accepts version_file values with or without a ./
prefix while keeping the existing output assignment to GITHUB_OUTPUT intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f92c95ed-a07a-4e9f-9387-758091d05cfa

📥 Commits

Reviewing files that changed from the base of the PR and between 5b06c2a and 8eb116a.

📒 Files selected for processing (2)
  • .github/workflows/nodejs-publish-release.yml
  • nodejs-publish/action.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/nodejs-publish-release.yml

@cdunster
cdunster force-pushed the add-workspace-support branch from 8eb116a to 1b72f14 Compare July 6, 2026 14:42
ThetaSinner
ThetaSinner previously approved these changes Jul 7, 2026
Comment thread .github/workflows/nodejs-publish-release.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 91-99: The publish workflow example is missing the newly required
version_file input, so readers can still copy an incomplete configuration and
fail at release time. Update the nodejs-publish-release usage example and the
workspace guidance in the README to explicitly include version_file alongside
workspace_main_package, and make sure the description of required inputs
reflects that the workflow now reads the release version from that file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e769b5d-0ee4-4441-b508-a2ea319fa386

📥 Commits

Reviewing files that changed from the base of the PR and between 84b244d and caf3239.

📒 Files selected for processing (1)
  • README.md

Comment thread README.md
ThetaSinner
ThetaSinner previously approved these changes Jul 7, 2026
@cocogitto-bot

cocogitto-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

✔️ 0b340f8...08eca6b - Conventional commits check succeeded.

@cdunster
cdunster requested a review from ThetaSinner July 7, 2026 10:14
@cdunster
cdunster enabled auto-merge (rebase) July 7, 2026 10:15
@cdunster
cdunster merged commit 53f074d into main Jul 7, 2026
5 checks passed
@cdunster
cdunster deleted the add-workspace-support branch July 7, 2026 11:21
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.

3 participants