Skip to content

Commit 5f47dd5

Browse files
noahsmartinclaude
andcommitted
feat(build): Add --distribution-group parameter to build upload
Add support for distribution groups in build uploads. This parameter allows specifying one or more groups that control update visibility. Builds with at least one matching distribution group will be shown updates for each other. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8a7d5d4 commit 5f47dd5

File tree

5 files changed

+56
-15
lines changed

5 files changed

+56
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Add `--distribution-group` parameter to `sentry-cli build upload` for controlling update visibility between builds ([#3094](https://github.com/getsentry/sentry-cli/pull/3094))
8+
39
## 3.1.0
410

511
### New Features

src/api/data_types/chunking/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ use sha1_smol::Digest;
55

66
use super::ChunkedFileState;
77

8+
fn is_empty_slice<T>(slice: &[T]) -> bool {
9+
slice.is_empty()
10+
}
11+
812
#[derive(Debug, Serialize)]
913
pub struct ChunkedBuildRequest<'a> {
1014
pub checksum: Digest,
@@ -13,6 +17,8 @@ pub struct ChunkedBuildRequest<'a> {
1317
pub build_configuration: Option<&'a str>,
1418
#[serde(skip_serializing_if = "Option::is_none")]
1519
pub release_notes: Option<&'a str>,
20+
#[serde(skip_serializing_if = "is_empty_slice")]
21+
pub distribution_groups: &'a [String],
1622
#[serde(flatten)]
1723
pub vcs_info: &'a VcsInfo<'a>,
1824
}

src/commands/build/upload.rs

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ pub fn make_command(command: Command) -> Command {
106106
.long("release-notes")
107107
.help("The release notes to use for the upload.")
108108
)
109+
.arg(
110+
Arg::new("distribution_group")
111+
.long("distribution-group")
112+
.action(ArgAction::Append)
113+
.help(
114+
"The distribution group(s) for this build. Can be specified multiple times. \
115+
Builds with at least one matching distribution group will be shown updates \
116+
for each other.",
117+
)
118+
)
109119
.arg(
110120
Arg::new("force_git_metadata")
111121
.long("force-git-metadata")
@@ -175,6 +185,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
175185

176186
let build_configuration = matches.get_one("build_configuration").map(String::as_str);
177187
let release_notes = matches.get_one("release_notes").map(String::as_str);
188+
let distribution_groups: Vec<String> = matches
189+
.get_many::<String>("distribution_group")
190+
.map(|vals| vals.cloned().collect())
191+
.unwrap_or_default();
178192

179193
let (plugin_name, plugin_version) = parse_plugin_from_pipeline(config.get_pipeline_env());
180194

@@ -237,15 +251,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
237251
for (path, zip) in normalized_zips {
238252
info!("Uploading file: {}", path.display());
239253
let bytes = ByteView::open(zip.path())?;
240-
match upload_file(
241-
&authenticated_api,
242-
&bytes,
243-
&org,
244-
&project,
254+
let metadata = BuildMetadata {
245255
build_configuration,
246256
release_notes,
247-
&vcs_info,
248-
) {
257+
distribution_groups: &distribution_groups,
258+
vcs_info: &vcs_info,
259+
};
260+
match upload_file(&authenticated_api, &bytes, &org, &project, &metadata) {
249261
Ok(artifact_url) => {
250262
info!("Successfully uploaded file: {}", path.display());
251263
uploaded_paths_and_urls.push((path.to_path_buf(), artifact_url));
@@ -588,19 +600,27 @@ fn handle_directory(
588600
normalize_directory(path, temp_dir.path(), plugin_name, plugin_version)
589601
}
590602

603+
/// Metadata for a build upload.
604+
struct BuildMetadata<'a> {
605+
build_configuration: Option<&'a str>,
606+
release_notes: Option<&'a str>,
607+
distribution_groups: &'a [String],
608+
vcs_info: &'a VcsInfo<'a>,
609+
}
610+
591611
/// Returns artifact url if upload was successful.
592612
fn upload_file(
593613
api: &AuthenticatedApi,
594614
bytes: &[u8],
595615
org: &str,
596616
project: &str,
597-
build_configuration: Option<&str>,
598-
release_notes: Option<&str>,
599-
vcs_info: &VcsInfo<'_>,
617+
metadata: &BuildMetadata<'_>,
600618
) -> Result<String> {
601619
debug!(
602-
"Uploading file to organization: {org}, project: {project}, build_configuration: {}, vcs_info: {vcs_info:?}",
603-
build_configuration.unwrap_or("unknown"),
620+
"Uploading file to organization: {org}, project: {project}, build_configuration: {}, distribution_groups: {:?}, vcs_info: {:?}",
621+
metadata.build_configuration.unwrap_or("unknown"),
622+
metadata.distribution_groups,
623+
metadata.vcs_info,
604624
);
605625

606626
let chunk_upload_options = api.get_chunk_upload_options(org)?;
@@ -641,9 +661,10 @@ fn upload_file(
641661
&ChunkedBuildRequest {
642662
checksum,
643663
chunks: &checksums,
644-
build_configuration,
645-
release_notes,
646-
vcs_info,
664+
build_configuration: metadata.build_configuration,
665+
release_notes: metadata.release_notes,
666+
distribution_groups: metadata.distribution_groups,
667+
vcs_info: metadata.vcs_info,
647668
},
648669
)?;
649670
chunks.retain(|Chunk((digest, _))| response.missing_chunks.contains(digest));

tests/integration/_cases/build/build-upload-help-macos.trycmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ Options:
7474
--release-notes <release_notes>
7575
The release notes to use for the upload.
7676

77+
--distribution-group <distribution_group>
78+
The distribution group(s) for this build. Can be specified multiple times. Builds with at
79+
least one matching distribution group will be shown updates for each other.
80+
7781
--force-git-metadata
7882
Force collection and sending of git metadata (branch, commit, etc.). If neither this nor
7983
--no-git-metadata is specified, git metadata is automatically collected when running in

tests/integration/_cases/build/build-upload-help-not-macos.trycmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ Options:
7373
--release-notes <release_notes>
7474
The release notes to use for the upload.
7575

76+
--distribution-group <distribution_group>
77+
The distribution group(s) for this build. Can be specified multiple times. Builds with at
78+
least one matching distribution group will be shown updates for each other.
79+
7680
--force-git-metadata
7781
Force collection and sending of git metadata (branch, commit, etc.). If neither this nor
7882
--no-git-metadata is specified, git metadata is automatically collected when running in

0 commit comments

Comments
 (0)