Open
Conversation
Adds the build and publish tooling for distributing the Upsun CLI as an npm package, so users can run `npm install -g upsun` or `npx upsun`. Implements the optionalDependencies pattern used by esbuild, swc, biome, turbo, and similar tools. A thin wrapper package (`upsun`) declares four platform-specific packages as optionalDependencies; npm uses each package's `os` and `cpu` fields to install only the matching one. The wrapper's bin script resolves that package at runtime and execs the embedded binary, forwarding argv, stdio, exit code, and signals. No postinstall script and no runtime download. Packages produced per release: upsun wrapper @upsun/cli-linux-x64 @upsun/cli-linux-arm64 @upsun/cli-darwin universal binary, x64 and arm64 @upsun/cli-win32-x64 macOS uses the universal binary that GoReleaser already builds, so a single darwin package covers both Apple Silicon and Intel. publish.sh classifies each tarball by reading its package.json once (wrapper = "upsun", everything else is a platform package), publishes the platform packages, waits for them to become queryable on the public registry, then publishes the wrapper. The wait matters: npm publish returns success before the package is visible to npm view, and any user running npx in that window gets a broken install in their npx cache that does not self-heal. Layout: - npm/wrapper: shim package with bin/upsun.js - npm/platform-template: template for the per-platform packages - npm/scripts/build.sh: assembles tarballs from GoReleaser archives - npm/scripts/publish.sh: classifies, publishes, waits, then wrapper - Makefile targets: npm-pack, npm-publish, npm-clean Verified end-to-end against the live registry: build, publish, install via `npx upsun`, exec, argv passthrough, and exit-code propagation all work. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds npm build/publish tooling to distribute the Upsun CLI via a wrapper package (upsun) plus platform-specific optionalDependency packages, enabling npm install -g upsun / npx upsun without postinstall downloads.
Changes:
- Add npm wrapper package (bin shim + package metadata) that resolves the correct platform package at runtime and execs the embedded binary.
- Add scripts to build npm tarballs from GoReleaser archives and publish them in a safe order (platforms first, then wrapper after propagation).
- Add templates/docs + Makefile targets and ignore
npm/dist/output.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| npm/wrapper/package.json.tmpl | Defines the upsun wrapper package and optionalDependencies on platform packages. |
| npm/wrapper/bin/upsun.js | Runtime resolver/launcher for the embedded platform binary. |
| npm/wrapper/README.md | Wrapper package README for npm consumers. |
| npm/scripts/build.sh | Builds wrapper + platform npm packages from GoReleaser artifacts. |
| npm/scripts/publish.sh | Publishes platform packages, waits for registry visibility, then publishes wrapper. |
| npm/platform-template/package.json.tmpl | Template for per-platform package metadata (os/cpu gated). |
| npm/platform-template/README.md.tmpl | Template README for per-platform packages. |
| npm/README.md | Repository docs for npm distribution workflow. |
| Makefile | Adds npm-pack, npm-publish, npm-clean targets. |
| .gitignore | Ignores npm/dist/ build outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review comments on PR #46: - Replace declare -A associative arrays in build.sh and publish.sh with case-statement helpers and parallel arrays, so the scripts run on macOS's default /bin/bash (3.2). - Stop swallowing chmod failures on Unix targets in build.sh; only the Windows binary, where the exec bit is meaningless, keeps || true. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the build and publish tooling for distributing the Upsun CLI as
an npm package, so users can run
npm install -g upsunornpx upsun.Implements the
optionalDependenciespattern used by esbuild, swc,biome, turbo, and similar tools. A thin wrapper package (
upsun)declares four platform-specific packages as
optionalDependencies;npm uses each package's
osandcpufields to install only thematching one. The wrapper's bin script resolves that package at
runtime and execs the embedded binary, forwarding argv, stdio, exit
code, and signals. No postinstall script and no runtime download.
Packages produced per release:
upsun@upsun/cli-linux-x64@upsun/cli-linux-arm64@upsun/cli-darwin@upsun/cli-win32-x64macOS uses the universal binary GoReleaser already builds, so a single
darwinpackage covers Apple Silicon and Intel.publish.shpublishes the platform packages first, waits for them tobecome queryable on the public registry, and only then publishes the
wrapper. The wait matters:
npm publishreturns success before thepackage is visible to
npm view, and any user runningnpx upsuninthat window gets a broken install in their npx cache that does not
self-heal.
Layout
npm/wrapper: shim package withbin/upsun.jsnpm/platform-template: template for the per-platform packagesnpm/scripts/build.sh: assembles tarballs from GoReleaser archivesnpm/scripts/publish.sh: publishes platforms, waits, then wrappernpm-pack,npm-publish,npm-cleanOut of scope
A GitHub Actions workflow that runs
make npm-pack && make npm-publishafter the existing release job will follow in a separate PR. That step
also needs an
NPM_TOKENautomation token added to the repo secrets.Verification
The current snapshot version was published to the public registry from
this branch as a seed;
npx upsun --versionresolves and runs the realbinary end to end. Build, install, exec, argv passthrough, exit-code
propagation all confirmed.
🤖 Generated with Claude Code