Skip to content

Commit

Permalink
Merge pull request #53 from lriccardo/master
Browse files Browse the repository at this point in the history
Add internal sharing download url to outputs and env
  • Loading branch information
r0adkll authored Dec 30, 2020
2 parents 84d17e8 + 21e00b9 commit ca061d7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ The mapping.txt file used to de-obfuscate your stack traces from crash reports

The name of the release published to Google Play, which is generated on commit by default

### `internalSharingDownloadUrls`

A JSON list containing the download urls for every release file uploaded using the `track` `internalsharing`

### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URLS`

The environment variable that is set when using the `track` `internalsharing`

### `internalSharingDownloadUrl`

The download url for an app that was uploaded using the `track` `internalsharing`
The download url for the last release file uploaded using the `track` `internalsharing`, useful when a single release file is uploaded

### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URL`

Expand Down
19 changes: 15 additions & 4 deletions lib/edits.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ function uploadToPlayStore(options, releaseFiles) {
// Check the 'track' for 'internalsharing', if so switch to a non-track api
if (options.track === 'internalsharing') {
core.debug("Track is Internal app sharing, switch to special upload api");
let downloadUrls = []
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
yield uploadInternalSharingRelease(options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
yield uploadInternalSharingRelease(options, releaseFile)
.then(downloadUrl => {
downloadUrls.push(downloadUrl)
})
.catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
}
core.setOutput("internalSharingDownloadUrls", downloadUrls);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URLS", downloadUrls);
}
else {
// Create a new Edit
Expand Down Expand Up @@ -118,11 +125,15 @@ function uploadInternalSharingRelease(options, releaseFile) {
return __awaiter(this, void 0, void 0, function* () {
if (releaseFile.endsWith('.apk')) {
const res = yield internalSharingUploadApk(options, releaseFile);
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
}
else if (releaseFile.endsWith('.aab')) {
const res = yield internalSharingUploadBundle(options, releaseFile);
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
}
Expand Down
19 changes: 15 additions & 4 deletions src/edits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
// Check the 'track' for 'internalsharing', if so switch to a non-track api
if (options.track === 'internalsharing') {
core.debug("Track is Internal app sharing, switch to special upload api")
let downloadUrls: string[] = []
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
await uploadInternalSharingRelease(options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
await uploadInternalSharingRelease(options, releaseFile)
.then(downloadUrl => {
downloadUrls.push(downloadUrl as string)
})
.catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
}
core.setOutput("internalSharingDownloadUrls", downloadUrls);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URLS", downloadUrls);
} else {
// Create a new Edit
core.info(`Creating a new Edit for this release`)
Expand Down Expand Up @@ -111,10 +118,14 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
async function uploadInternalSharingRelease(options: EditOptions, releaseFile: string): Promise<string | undefined | null> {
if (releaseFile.endsWith('.apk')) {
const res = await internalSharingUploadApk(options, releaseFile)
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
return Promise.resolve(res.downloadUrl)
} else if (releaseFile.endsWith('.aab')) {
const res = await internalSharingUploadBundle(options, releaseFile)
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
return Promise.resolve(res.downloadUrl)
} else {
Expand Down

0 comments on commit ca061d7

Please sign in to comment.