Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proguard): Release association #1688

Merged
merged 7 commits into from
Jul 20, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,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 @@ -2354,6 +2378,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