Skip to content

Commit

Permalink
feat(proguard): Release association (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor authored Jul 20, 2023
1 parent 3e81cb3 commit 9b4b29b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 18 deletions.
30 changes: 30 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,30 @@ impl Api {
)
}

pub fn associate_proguard_mappings(
&self,
org: &str,
project: &str,
data: &AssociateProguard,
) -> ApiResult<()> {
let path = format!(
"/projects/{}/{}/files/proguard-artifact-releases",
PathArg(org),
PathArg(project)
);
let resp: ApiResponse = self
.request(Method::Post, &path)?
.with_json_body(data)?
.send()?;
if resp.status() == 201 {
Ok(())
} else if resp.status() == 404 {
return Err(ApiErrorKind::ResourceNotFound.into());
} else {
resp.convert()
}
}

/// Associate arbitrary debug symbols with a build
pub fn associate_dsyms(
&self,
Expand Down Expand Up @@ -2404,6 +2428,12 @@ pub struct AssociateDsyms {
pub build: Option<String>,
}

#[derive(Debug, Serialize)]
pub struct AssociateProguard {
pub release_name: String,
pub proguard_uuid: String,
}

#[derive(Deserialize)]
struct MissingChecksumsResponse {
missing: HashSet<Digest>,
Expand Down
43 changes: 25 additions & 18 deletions src/commands/upload_proguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use proguard::ProguardMapping;
use symbolic::common::ByteView;
use uuid::Uuid;

use crate::api::{Api, AssociateDsyms};
use crate::api::Api;
use crate::api::AssociateProguard;
use crate::config::Config;
use crate::utils::android::{dump_proguard_uuids_as_properties, AndroidManifest};
use crate::utils::args::ArgExt;
Expand Down Expand Up @@ -216,7 +217,6 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
let tf = TempFile::create()?;
{
let mut zip = zip::ZipWriter::new(tf.open()?);

for mapping in &mappings {
let pb = make_byte_progress_bar(mapping.size);
zip.start_file(
Expand Down Expand Up @@ -267,22 +267,29 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

// if values are given associate
} else if let Some(app_id) = matches.get_one::<String>("app_id") {
api.associate_dsyms(
&org,
&project,
&AssociateDsyms {
platform: matches
.get_one::<String>("platform")
.map(String::as_str)
.unwrap_or("android")
.to_string(),
checksums: all_checksums,
name: app_id.to_string(),
app_id: app_id.to_string(),
version: matches.get_one::<String>("version").unwrap().to_owned(),
build: matches.get_one::<String>("version_code").cloned(),
},
)?;
let version = matches.get_one::<String>("version").unwrap().to_owned();
let build: Option<String> = matches.get_one::<String>("version_code").cloned();

let mut release_name = app_id.to_owned();
release_name.push('@');
release_name.push_str(&version);

if let Some(build_str) = build {
release_name.push('+');
release_name.push_str(&build_str);
}

for mapping in &mappings {
let uuid = forced_uuid.unwrap_or(&mapping.uuid);
api.associate_proguard_mappings(
&org,
&project,
&AssociateProguard {
release_name: release_name.to_owned(),
proguard_uuid: uuid.to_string(),
},
)?;
}
}

// If wanted trigger reprocessing
Expand Down

0 comments on commit 9b4b29b

Please sign in to comment.