Skip to content

Commit

Permalink
Mapping file for bundles (#440)
Browse files Browse the repository at this point in the history
* Update main.ts

* Update vsts-extension-google-play.json

* Update task.json

* Update task.loc.json

* Update fileHelper.ts

* common logic in a separate function

* update versions

---------

Co-authored-by: DenisRumyantsev <[email protected]>
  • Loading branch information
barindervir and DenisRumyantsev authored May 17, 2024
1 parent d73b146 commit ce94683
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 44 deletions.
62 changes: 28 additions & 34 deletions Tasks/GooglePlayReleaseV4/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,32 @@ async function run(): Promise<void> {
if (action === 'OnlyStoreListing') {
tl.debug('Selected store listing update only -> skip APK/AAB reading');
} else {
async function uploadRelatedFiles (filePath: string, versionCode: number): Promise<void> {
// Uploading mapping file
if (uploadMappingFiles) {
const mappingFilePath: string | null = fileHelper.getMappingFile(filePath);

if (mappingFilePath !== null) {
tl.debug(`Uploading ${mappingFilePath} for version code ${versionCode}`);
await googleutil.uploadDeobfuscation(edits, mappingFilePath, packageName, versionCode);
} else {
tl.warning(tl.loc('NotFoundMappingFile', versionCode));
}
}

// Uploading native debug symbols file
if (uploadNativeDebugSymbolFiles) {
const nativeDebugSymbolsFilePath: string | null = fileHelper.getSymbolsFile(filePath);

if (nativeDebugSymbolsFilePath !== null) {
tl.debug(`Uploading ${nativeDebugSymbolsFilePath} for version code ${versionCode}`);
await googleutil.uploadNativeDeobfuscation(edits, nativeDebugSymbolsFilePath, packageName, versionCode);
} else {
tl.warning(tl.loc('NotFoundSymbolsFile', versionCode));
}
}
}

requireTrackUpdate = true;

tl.debug(`Uploading ${bundleFileList.length} AAB(s).`);
Expand All @@ -137,19 +163,8 @@ async function run(): Promise<void> {
tl.debug(`Uploading bundle ${bundleFile}`);
const bundle: pub3.Schema$Bundle = await googleutil.addBundle(edits, packageName, bundleFile);
tl.debug(`Uploaded ${bundleFile} with the version code ${bundle.versionCode}`);
await uploadRelatedFiles(bundleFile, bundle.versionCode);
versionCodes.push(bundle.versionCode);

// Uploading native debug symbols for aab files
if (uploadNativeDebugSymbolFiles) {
const nativeDebugSymbolsFilePath: string | null = fileHelper.getSymbolsFile(bundleFile);

if (nativeDebugSymbolsFilePath !== null) {
tl.debug(`Uploading ${nativeDebugSymbolsFilePath} for version code ${bundle.versionCode}`);
await googleutil.uploadNativeDeobfuscation(edits, nativeDebugSymbolsFilePath, packageName, bundle.versionCode);
} else {
tl.warning(tl.loc('NotFoundSymbolsFile', bundle.versionCode));
}
}
}

tl.debug(`Uploading ${apkFileList.length} APK(s).`);
Expand Down Expand Up @@ -177,28 +192,7 @@ async function run(): Promise<void> {
}
}

if (uploadMappingFiles) {
const mappingFilePath: string | null = fileHelper.getMappingFile(apkFile);

if (mappingFilePath !== null) {
tl.debug(`Uploading ${mappingFilePath} for version code ${apk.versionCode}`);
await googleutil.uploadDeobfuscation(edits, mappingFilePath, packageName, apk.versionCode);
} else {
tl.warning(tl.loc('NotFoundMappingFile', apk.versionCode));
}
}

if (uploadNativeDebugSymbolFiles) {
const nativeDebugSymbolsFilePath: string | null = fileHelper.getSymbolsFile(apkFile);

if (nativeDebugSymbolsFilePath !== null) {
tl.debug(`Uploading ${nativeDebugSymbolsFilePath} for version code ${apk.versionCode}`);
await googleutil.uploadNativeDeobfuscation(edits, nativeDebugSymbolsFilePath, packageName, apk.versionCode);
} else {
tl.warning(tl.loc('NotFoundSymbolsFile', apk.versionCode));
}
}

await uploadRelatedFiles(apkFile, apk.versionCode);
versionCodes.push(apk.versionCode);
}

Expand Down
12 changes: 6 additions & 6 deletions Tasks/GooglePlayReleaseV4/modules/fileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ export function getObbFile(apkPath: string, packageName: string, versionCode: nu
}

/**
* Get `mapping.txt` file from apk directory
* @param apkPath apk file path
* Get `mapping.txt` file from apk/aab directory
* @param filePath apk file path
* @returns path of the `mapping.txt` file if present else null
*/
export function getMappingFile(apkPath: string): string | null {
const mappingFilePath: string = path.join(path.dirname(apkPath), 'mapping.txt');
export function getMappingFile(filePath: string): string | null {
const mappingFilePath: string = path.join(path.dirname(filePath), 'mapping.txt');

if (fs.existsSync(mappingFilePath)) {
tl.debug(`Found Mapping file for upload in apk directory: ${mappingFilePath}`);
tl.debug(`Found Mapping file for upload in apk/aab directory: ${mappingFilePath}`);
return mappingFilePath;
}

tl.debug(`No Mapping file found for ${apkPath}, skipping upload`);
tl.debug(`No Mapping file found for ${filePath}, skipping upload`);
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion Tasks/GooglePlayReleaseV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"demands": [],
"version": {
"Major": "4",
"Minor": "236",
"Minor": "240",
"Patch": "0"
},
"minimumAgentVersion": "2.182.1",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/GooglePlayReleaseV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"demands": [],
"version": {
"Major": "4",
"Minor": "236",
"Minor": "240",
"Patch": "0"
},
"minimumAgentVersion": "2.182.1",
Expand Down Expand Up @@ -398,4 +398,4 @@
"Default": "4.232.1",
"Node20-228": "4.235.0"
}
}
}
2 changes: 1 addition & 1 deletion vsts-extension-google-play.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1.0,
"id": "google-play",
"name": "Google Play",
"version": "4.235.0",
"version": "4.240.0",
"publisher": "ms-vsclient",
"description": "Provides tasks for continuous delivery to the Google Play Store from TFS/Team Services build or release definitions",
"categories": [
Expand Down

0 comments on commit ce94683

Please sign in to comment.