Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ workspaces:
Build:
- "/^sentry-.*$/"
- "npm-package"
- "npm-package-sentry-cli"
- "/^pypi-wheel-.*$/"
- "mcp-server-npm-package"
- "vercel"
- "install-scripts"
targets:
- name: npm
includeNames: '/^sentry-\d.*\.tgz$/'
# The same package under the v3 name. An npm owner deprecates it in
# favor of `sentry` after the first release.
- name: npm
id: "@sentry/cli"
includeNames: &npm-sentry-cli '/^sentry-cli-\d.*\.tgz$/'
# The standalone MCP server, published at the CLI's version.
- name: npm
id: "@sentry/mcp-server"
Expand All @@ -57,6 +64,25 @@ workspaces:
manifest: server.json
- name: github
tagPrefix: "cli@"
# PyPI and Sentry's internal index, under the v3 package name.
- name: pypi
includeNames: &wheels '/^sentry_cli-.*\.whl$/'
- name: sentry-pypi
internalPypiRepo: getsentry/pypi
includeNames: *wheels
# The v3 download location, downloads.sentry-cdn.com/sentry-cli/. v4
# binaries keep their own names, so URLs of v3 binary names keep serving
# v3: the v3 releases' files, and the 3.x files left in latest/.
- name: gcs
bucket: sentry-sdk-assets
includeNames: &cdn-binaries '/^sentry-(darwin|linux|windows)-(arm64|x64)(\.exe)?(\.gz)?$/'
paths:
- path: /sentry-cli/{{version}}/
metadata:
cacheControl: public, max-age=2592000
- path: /sentry-cli/latest/
metadata:
cacheControl: public, max-age=600
- name: vercel
projectId: prj_wVkOnIwI3eIQbGD1Gw7qS1MqFFIK
- name: registry
Expand All @@ -70,6 +96,21 @@ workspaces:
checksums:
- algorithm: sha256
format: hex
# The v3 app. Lists only the files the gcs target uploads: the registry
# target links every artifact that its target-level includeNames lets
# through, and ignores includeNames under an app.
- name: registry
id: "app:sentry-cli"
includeNames: *cdn-binaries
apps:
"app:sentry-cli":
name: "Sentry CLI"
packageUrl: "https://www.npmjs.com/package/sentry"
mainDocsUrl: "https://cli.sentry.dev"
urlTemplate: "https://downloads.sentry-cdn.com/sentry-cli/{{version}}/{{file}}"
checksums:
- algorithm: sha256
format: hex
- name: brew
tap: getsentry/tools
formula: sentry
Expand Down Expand Up @@ -133,6 +174,10 @@ workspaces:
assert_match version.to_s, shell_output("#{bin}/sentry --version").chomp
end
end
# Fail before publishing anything if an artifact for the v3 names is missing.
requireNames:
- *npm-sentry-cli
- *wheels
# No preReleaseCommand: Craft bumps package.json through the npm target.
packages/logger:
changelog:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/cli-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@ jobs:
with:
name: sentry-${{ matrix.target }}-gz
path: packages/cli/dist-bin/*.gz
# PyPI `sentry-cli` (the v3 package name) ships one wheel per binary.
- name: Build PyPI wheel
Comment thread
sentry-junior[bot] marked this conversation as resolved.
Resolved
working-directory: packages/cli
env:
TARGET: ${{ matrix.target }}
run: pnpm run ts script/build-wheel.ts "$TARGET"
- name: Smoke test PyPI wheel
if: matrix.target == 'linux-x64'
env:
SENTRY_AUTH_TOKEN: ""
SENTRY_TOKEN: ""
SENTRY_CONFIG_DIR: ${{ runner.temp }}/.sentry-smoke
run: pipx run --spec packages/cli/dist-wheel/sentry_cli-*.whl sentry --help
- name: Upload PyPI wheel artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: pypi-wheel-${{ matrix.target }}
path: packages/cli/dist-wheel/*.whl
if-no-files-found: error

generate-patches:
name: Generate nightly delta patches
Expand Down Expand Up @@ -289,6 +308,17 @@ jobs:
with:
name: npm-package
path: packages/cli/*.tgz
# The same package under the v3 name, @sentry/cli. Packed after the
# upload above so npm-package holds only the sentry tarball.
- name: Pack @sentry/cli
working-directory: packages/cli
run: pnpm run ts script/pack-npm-alias.ts
- name: Upload @sentry/cli npm artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: npm-package-sentry-cli
path: packages/cli/sentry-cli-*.tgz
if-no-files-found: error
# Every CLI release also publishes @sentry/mcp-server at the same version.
- name: Bundle mcp-server
run: pnpm --filter @sentry/mcp-server run bundle
Expand Down
34 changes: 34 additions & 0 deletions apps/cli-docs/src/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,37 @@ Homebrew installs shell completions but can't install agent skills into your hom
sentry cli setup --no-modify-path --no-completions
```

The v3 formula, `getsentry/tools/sentry-cli`, is renamed to
`getsentry/tools/sentry`, so installing it installs this formula.

## pip

The PyPI package `sentry-cli` installs the standalone binary as `sentry`:

```bash
pipx install sentry-cli # or: pip install sentry-cli
```

It has wheels for macOS, Linux with glibc, and Windows on the platforms listed
above, and no source distribution, so pip cannot install it elsewhere, such as
on Alpine Linux. The `sentry` PyPI package (self-hosted Sentry) also installs a
`sentry` command; do not install both into the same environment.

## Direct Download

Each release's binaries are attached to its
[GitHub release](https://github.com/getsentry/toolkit/releases) and served
from `https://downloads.sentry-cdn.com/sentry-cli/<version>/`, as
`sentry-<os>-<arch>` (`.exe` on Windows) and gzipped as `.gz`. For example:

```bash
curl -fsSL https://downloads.sentry-cdn.com/sentry-cli/latest/sentry-linux-x64.gz | gunzip > sentry
chmod +x sentry
```

The release registry, `https://release-registry.services.sentry.io/apps/sentry-cli/latest`,
lists their SHA-256 checksums.

## Package Managers

Install globally with your preferred package manager (the npm packages require **Node.js 20+**; on **22.15+** the built-in `node:sqlite` is used, on 20–22.14 a bundled WASM fallback is used transparently):
Expand All @@ -161,6 +192,9 @@ Install globally with your preferred package manager (the npm packages require *
bun="bun add -g sentry"
/>

The v3 package name, `@sentry/cli`, also has v4 releases with the same code.
It is deprecated; install `sentry` instead.

Unlike the install script, package manager installs don't set up shell completions or agent skills. Run `sentry cli setup` once to enable them:

```bash
Expand Down
37 changes: 36 additions & 1 deletion apps/cli-docs/src/content/docs/migrating-from-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ own pace.
| Area | v3 (`sentry-cli`) | v4 (`sentry`) |
|------|-------------------|---------------|
| Binary name | `sentry-cli` | `sentry` |
| npm package | `@sentry/cli` | `sentry` |
| npm package | `@sentry/cli` | `sentry` (`@sentry/cli@4` is the same code, deprecated) |
| Command groups | plural (`releases`, `projects`) | singular (`release`, `project`) |
| Output | plain text | Markdown on a TTY, plain when piped, `--json` for machines |
| Exit codes | mostly `1` | [semantic ranges](/exit-codes/) (auth=1x, input=2x, API=3x…) |
Expand All @@ -48,6 +48,9 @@ npm install -g sentry # or: pnpm add -g sentry / yarn global add sent
brew uninstall sentry-cli
brew install getsentry/tools/sentry

# pip
pip install --upgrade sentry-cli

# Install script
curl https://cli.sentry.dev/install -fsS | bash

Expand All @@ -62,6 +65,38 @@ sentry --version
sentry auth status
```

### Where v3 was published

v4 is also published under the v3 names, so upgrading through the channel you
already use gets you v4. Every channel installs a `sentry` command; none
installs `sentry-cli`. Pin the major version to stay on v3.

| v3 channel | What a v4 upgrade does | Stay on v3 |
|------------|------------------------|------------|
| npm `@sentry/cli` | Installs `@sentry/cli@4`, the `sentry` package under the old name. It is deprecated: switch to `sentry`. | `@sentry/cli@^3` |
| Homebrew `getsentry/tools/sentry-cli` | The formula is renamed to `getsentry/tools/sentry`. `brew update` moves your install to it, and `brew upgrade` installs v4. | `brew pin sentry-cli` before updating |
| PyPI `sentry-cli` | Installs the standalone v4 binary as `sentry`. | `sentry-cli<4` |
| `downloads.sentry-cdn.com/sentry-cli/<version>/` | v4 versions hold the v4 binaries, named like `sentry-linux-x64` and `sentry-darwin-arm64.gz`. | Use a 3.x version in the URL |
| Release registry `app:sentry-cli` | `latest` is v4, with download URLs on `downloads.sentry-cdn.com`. | `apps/sentry-cli/3` |
| `https://sentry.io/get-cli/` | Installs v4 with `https://cli.sentry.dev/install`, which needs bash. | `SENTRY_CLI_VERSION=3.8.2` |
| `sentry-cli update` | Finds no v4 binary under a v3 name, so it stops with "Could not get the latest release version." | Nothing to do |

The v3 file names, such as `sentry-cli-Linux-x86_64`, exist only for v3 versions,
including under `downloads.sentry-cdn.com/sentry-cli/latest/`. A script that
downloads one of them keeps getting v3, never a v4 binary that it would run as
`sentry-cli`.

A global install of `@sentry/cli@4` and one of `sentry` both provide the
`sentry` command, so npm refuses to install the second. Uninstall
`@sentry/cli` first. `sentry cli upgrade` keeps upgrading the npm package that
you installed, so it upgrades an `@sentry/cli` install in place.

The PyPI wheels need macOS 13.5 or later, or Linux with glibc 2.28 or later, on
x64 or arm64, or Windows on x64. There are no musl (Alpine) wheels; use
`npm install -g sentry` there. The `sentry` PyPI package, which is self-hosted
Sentry, also installs a `sentry` command, so do not install both into one
environment.

## The `sentry-cli` → `sentry` rename

If you only ever call the top-level binary, the simplest bridge is a plain
Expand Down
5 changes: 4 additions & 1 deletion design/sentry-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ a terminal, with as little setup as the current project allows.
- Targets: `<org>/<project>`, `<org>/`, a project name, or a Sentry URL.
- `--json` on list and view commands, and `-w`/`--web` on view commands.
- The npm package `sentry`, release binaries, and the docs at
<https://cli.sentry.dev/>.
<https://cli.sentry.dev/>. Releases also go out under the v3 names: npm
`@sentry/cli`, PyPI `sentry-cli`, and `downloads.sentry-cdn.com/sentry-cli/`.
Each installs the `sentry` command. The Homebrew formula
`getsentry/tools/sentry-cli` is renamed to `getsentry/tools/sentry`.

## Rules

Expand Down
3 changes: 2 additions & 1 deletion docs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ CLI releases build it from that workspace. Start here for repository guides:
[command conventions](../../packages/cli/CONTRIBUTING.md) — implementation
details and command design.
- [CLI build workflow](../../.github/workflows/cli-build.yml) and
[release configuration](../../.craft.yml) — binaries, npm packaging, and
[release configuration](../../.craft.yml) — binaries, npm and PyPI
packaging (including the v3 names `@sentry/cli` and `sentry-cli`), and
release-gated website artifacts.
- [Website packaging](../../apps/cli-docs/vercel/build-output.mjs) — the
Vercel routes for `/install`, and the `/install/<handoff code>` function that
Expand Down
1 change: 1 addition & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ node_modules
out
dist
dist-bin
dist-wheel
dist-build
# Scratch output of script/lib/split-bundle.ts
.split-*
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/packaging/npm-sentry-cli-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# @sentry/cli

Version 4 of the Sentry CLI is published as [`sentry`](https://www.npmjs.com/package/sentry).
`@sentry/cli` 4.x ships the same code under the old package name, so that
upgrades find it. Install `sentry` instead:

```bash
npm install -g sentry
```

The command is now `sentry`, not `sentry-cli`, and the `SentryCli` class is
replaced by `createSentrySDK()`. Version 3 stays available as `@sentry/cli@3`.

See [Migrating from v3](https://cli.sentry.dev/migrating-from-v3/) and the
[documentation](https://cli.sentry.dev).
21 changes: 21 additions & 0 deletions packages/cli/packaging/pypi-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# sentry-cli

The command-line interface for [Sentry](https://sentry.io), built for
developers and AI agents.

Each wheel contains the standalone `sentry` binary for one platform: macOS
(arm64, x64), Linux with glibc 2.28 or later (arm64, x64), and Windows (x64).
There is no source distribution, so pip cannot install it on other platforms,
such as Alpine Linux. Use `npm install -g sentry` there.

```bash
pip install sentry-cli
sentry --help
```

Version 4 installs a `sentry` command, not `sentry-cli`. To keep version 3,
pin `sentry-cli<4`. The `sentry` package (self-hosted Sentry) also installs a
`sentry` command, so do not install both into the same environment.

See [Migrating from v3](https://cli.sentry.dev/migrating-from-v3/) and the
[documentation](https://cli.sentry.dev).
42 changes: 42 additions & 0 deletions packages/cli/script/build-wheel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Build the PyPI wheel of one standalone binary.
*
* Usage (from packages/cli, after `pnpm run build -- --target <target>`):
* pnpm run ts script/build-wheel.ts linux-x64
*
* Reads dist-bin/sentry-<target>[.exe] and writes dist-wheel/<wheel>.whl.
*/

import { mkdir, readFile, writeFile } from "node:fs/promises";
import { extname, join } from "node:path";
import pkg from "../package.json" with { type: "json" };
import { buildWheel, WHEEL_TARGETS } from "./lib/python-wheel.js";
import { logger } from "../src/lib/logger.js";

const OUT_DIR = "dist-wheel";

const target = process.argv[2] ?? "";
const exe = WHEEL_TARGETS[target]?.exe;
if (!exe) {
logger.error(
`Usage: build-wheel.ts <target>, one of: ${Object.keys(WHEEL_TARGETS).join(", ")}`,
);
process.exit(1);
}

const [binary, readme, license] = await Promise.all([
readFile(join("dist-bin", `sentry-${target}${extname(exe)}`)),
readFile("packaging/pypi-README.md", "utf-8"),
readFile("LICENSE.md", "utf-8"),
]);
const wheel = buildWheel({
target,
version: pkg.version,
binary,
summary: pkg.description,
readme,
license,
});
await mkdir(OUT_DIR, { recursive: true });
await writeFile(join(OUT_DIR, wheel.filename), wheel.contents);
logger.success(`Built ${OUT_DIR}/${wheel.filename}`);
45 changes: 45 additions & 0 deletions packages/cli/script/lib/npm-alias.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* The `@sentry/cli` npm package: the `sentry` package under the v3 name, so
* `npm install @sentry/cli@latest` gets version 4.
*/

import { execFileSync } from "node:child_process";
import { copyFile, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";

export const NPM_ALIAS_NAME = "@sentry/cli";

/**
* Repack a `sentry` npm tarball as `@sentry/cli`, with the same files and the
* given README. npm names the result `sentry-cli-<version>.tgz`.
*
* @param tarball - Tarball from `npm pack` of the `sentry` package
* @param readme - README that replaces the package's own
* @param outDir - Directory for the new tarball
*/
export async function packNpmAlias(
tarball: string,
readme: string,
outDir: string,
): Promise<void> {
const dir = await mkdtemp(join(tmpdir(), "sentry-npm-alias-"));
try {
execFileSync("tar", ["-xzf", resolve(tarball), "-C", dir]);
// npm pack always puts the package in package/.
const packageDir = join(dir, "package");
const manifestPath = join(packageDir, "package.json");
const manifest = JSON.parse(await readFile(manifestPath, "utf-8"));
manifest.name = NPM_ALIAS_NAME;
manifest.publishConfig = { access: "public" };
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
await copyFile(readme, join(packageDir, "README.md"));
execFileSync(
"npm",
["pack", "--ignore-scripts", "--pack-destination", resolve(outDir)],
{ cwd: packageDir, stdio: ["ignore", "ignore", "inherit"] },
);
} finally {
await rm(dir, { recursive: true, force: true });
}
}
Loading
Loading