Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Merged
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
13 changes: 11 additions & 2 deletions docs/src/fragments/commands/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# Upload an Android build (APK or AAB) for size analysis
sentry build upload ./app-release.apk

# Upload an iOS build (XCArchive directory or IPA)
sentry build upload ./MyApp.xcarchive
sentry build upload ./MyApp.ipa

# Upload with a build configuration and release notes
sentry build upload ./app.aab --build-configuration Release --release-notes "Nightly"

Expand All @@ -27,8 +31,13 @@ sentry build download 1234567890 --json

## Important Notes

- `build upload` supports **Android APK and AAB**. iOS XCArchive/IPA upload is
not yet supported. **Sentry SaaS only.**
- `build upload` supports **Android APK/AAB** and **iOS XCArchive/IPA**. An
XCArchive is a directory; an IPA is converted to an XCArchive layout for
upload. **Sentry SaaS only.**
- iOS caveat: `Assets.car` asset catalogs are **not** parsed into per-asset
images (that required native macOS frameworks), so the server sees the raw
`.car` rather than a per-image breakdown. XCArchive symlinks and Unix file
permissions are preserved.
- Multiple paths may be uploaded at once; the command exits non-zero if any
build fails to upload.
- Git metadata (commit, branch, PR number, repo) is **auto-collected in CI**
Expand Down
4 changes: 4 additions & 0 deletions plugins/sentry-cli/skills/sentry-cli/references/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Download a build artifact
# Upload an Android build (APK or AAB) for size analysis
sentry build upload ./app-release.apk

# Upload an iOS build (XCArchive directory or IPA)
sentry build upload ./MyApp.xcarchive
sentry build upload ./MyApp.ipa

# Upload with a build configuration and release notes
sentry build upload ./app.aab --build-configuration Release --release-notes "Nightly"

Expand Down
50 changes: 28 additions & 22 deletions src/commands/build/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import {
} from "../../lib/api/preprod-artifacts.js";
import {
detectBuildFormat,
normalizeBuildDirectory,
normalizeBuildFile,
normalizeIpa,
parsePluginFromPipeline,
validateXcarchiveDirectory,
} from "../../lib/build/index.js";
import {
collectVcsMetadata,
Expand Down Expand Up @@ -110,36 +113,37 @@ async function uploadOne(
throw new ValidationError(`Path does not exist: ${path}`, "path");
}

// XCArchive is a directory; iOS support is ported separately.
const plugin = parsePluginFromPipeline(ctx.env.SENTRY_PIPELINE);

// An XCArchive is a directory; validate its structure, then zip it. The
// validation refuses arbitrary directories so a stray `sentry build upload ./`
// can't sweep up source, .git/, or secrets.
if (info.isDirectory()) {
throw new ValidationError(
`iOS XCArchive upload is not yet supported: ${path}`,
"path"
);
validateXcarchiveDirectory(path);
const normalized = await normalizeBuildDirectory(path, plugin);
return await uploadBuild({ org, project, content: normalized, metadata });
}

// NOTE: the build is read fully into memory (and normalized into a second
// buffer). Fine for typical mobile builds, but files above Node's ~2 GiB
// Buffer cap will throw. A follow-up can stream normalization to a temp file
// and use the file-based chunk path; the legacy CLI memory-maps instead.
const content = await readFile(path);
// detectBuildFormat only classifies files (apk/aab/ipa); XCArchive is a
// directory, handled above.
const format = detectBuildFormat(content);

if (format === "ipa" || format === "xcarchive") {
let normalized: Buffer;
if (format === "ipa") {
normalized = normalizeIpa(content, plugin);
} else if (format === "apk" || format === "aab") {
normalized = normalizeBuildFile(path, content, plugin);
} else {
throw new ValidationError(
`iOS ${format.toUpperCase()} upload is not yet supported: ${path}`,
`Unsupported build format (expected APK, AAB, IPA, or XCArchive): ${path}`,
"path"
);
}
if (format !== "apk" && format !== "aab") {
throw new ValidationError(
`Unsupported build format (expected APK or AAB): ${path}`,
"path"
);
}

const plugin = parsePluginFromPipeline(ctx.env.SENTRY_PIPELINE);
const normalized = normalizeBuildFile(path, content, plugin);
return await uploadBuild({ org, project, content: normalized, metadata });
}

Expand All @@ -148,13 +152,15 @@ export const uploadCommand = buildCommand({
brief: "Upload builds to a project",
fullDescription:
"Upload mobile builds to Sentry for preprod size analysis. Each build " +
"is wrapped in a deterministic ZIP and uploaded via the chunk-upload + " +
"assemble protocol.\n\n" +
"Supported formats: Android APK and AAB. (iOS XCArchive/IPA is not yet " +
"supported.) This feature only works with Sentry SaaS.\n\n" +
"is normalized into a deterministic ZIP and uploaded via the " +
"chunk-upload + assemble protocol.\n\n" +
"Supported formats: Android APK/AAB, iOS XCArchive (a directory) and IPA. " +
"Note: iOS Assets.car asset catalogs are not parsed into per-asset " +
"images. This feature only works with Sentry SaaS.\n\n" +
"Usage:\n" +
" sentry build upload ./app-release.apk\n" +
" sentry build upload ./app.aab --build-configuration Release\n" +
" sentry build upload ./MyApp.xcarchive\n" +
" sentry build upload ./MyApp.ipa --build-configuration Release\n" +
" sentry build upload ./app.aab --install-group qa --install-group beta",
},
output: {
Expand All @@ -164,7 +170,7 @@ export const uploadCommand = buildCommand({
positional: {
kind: "array",
parameter: {
brief: "Path(s) to the build(s) to upload (APK or AAB)",
brief: "Path(s) to the build(s) to upload (APK, AAB, IPA, or XCArchive)",
parse: String,
placeholder: "path",
},
Expand Down
Loading
Loading