Add releases to the edit track correctly
This commit is contained in:
22
lib/edits.js
22
lib/edits.js
@@ -41,13 +41,16 @@ function uploadToPlayStore(options, releaseFiles) {
|
|||||||
auth: options.auth,
|
auth: options.auth,
|
||||||
packageName: options.applicationId
|
packageName: options.applicationId
|
||||||
});
|
});
|
||||||
|
var versionCodes = new Array();
|
||||||
releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () {
|
releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () {
|
||||||
core.debug(`Uploading ${releaseFile}`);
|
core.debug(`Uploading ${releaseFile}`);
|
||||||
yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
|
const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
|
||||||
core.setFailed(reason);
|
core.setFailed(reason);
|
||||||
return Promise.reject(reason);
|
return Promise.reject(reason);
|
||||||
});
|
});
|
||||||
|
versionCodes.push(versionCode);
|
||||||
}));
|
}));
|
||||||
|
const track = trackVersionCode(appEdit.data, options, versionCodes);
|
||||||
const res = yield androidPublisher.edits.commit({
|
const res = yield androidPublisher.edits.commit({
|
||||||
auth: options.auth,
|
auth: options.auth,
|
||||||
editId: appEdit.data.id,
|
editId: appEdit.data.id,
|
||||||
@@ -72,12 +75,12 @@ function uploadRelease(appEdit, options, releaseFile) {
|
|||||||
if (releaseFile.endsWith('.apk')) {
|
if (releaseFile.endsWith('.apk')) {
|
||||||
const res = yield internalSharingUploadApk(options, releaseFile);
|
const res = yield internalSharingUploadApk(options, releaseFile);
|
||||||
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
|
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
|
||||||
return Promise.resolve(res.downloadUrl);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
else if (releaseFile.endsWith('.aab')) {
|
else if (releaseFile.endsWith('.aab')) {
|
||||||
const res = yield internalSharingUploadBundle(options, releaseFile);
|
const res = yield internalSharingUploadBundle(options, releaseFile);
|
||||||
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
|
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
|
||||||
return Promise.resolve(res.downloadUrl);
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.setFailed(`${releaseFile} is invalid`);
|
core.setFailed(`${releaseFile} is invalid`);
|
||||||
@@ -89,16 +92,15 @@ function uploadRelease(appEdit, options, releaseFile) {
|
|||||||
core.setFailed(`Track "${options.track}" could not be found `);
|
core.setFailed(`Track "${options.track}" could not be found `);
|
||||||
return Promise.reject(`No track found for "${options.track}"`);
|
return Promise.reject(`No track found for "${options.track}"`);
|
||||||
}
|
}
|
||||||
let track = undefined;
|
|
||||||
if (releaseFile.endsWith('.apk')) {
|
if (releaseFile.endsWith('.apk')) {
|
||||||
const apk = yield uploadApk(appEdit, options, releaseFile);
|
const apk = yield uploadApk(appEdit, options, releaseFile);
|
||||||
yield uploadMappingFile(appEdit, apk.versionCode, options);
|
yield uploadMappingFile(appEdit, apk.versionCode, options);
|
||||||
track = yield trackVersionCode(appEdit, options, apk.versionCode);
|
return Promise.resolve(apk.versionCode);
|
||||||
}
|
}
|
||||||
else if (releaseFile.endsWith('.aab')) {
|
else if (releaseFile.endsWith('.aab')) {
|
||||||
const bundle = yield uploadBundle(appEdit, options, releaseFile);
|
const bundle = yield uploadBundle(appEdit, options, releaseFile);
|
||||||
yield uploadMappingFile(appEdit, bundle.versionCode, options);
|
yield uploadMappingFile(appEdit, bundle.versionCode, options);
|
||||||
track = yield trackVersionCode(appEdit, options, bundle.versionCode);
|
return Promise.resolve(bundle.versionCode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.setFailed(`${releaseFile} is invalid`);
|
core.setFailed(`${releaseFile} is invalid`);
|
||||||
@@ -116,7 +118,7 @@ function getAllTracks(appEdit, options) {
|
|||||||
return res.data.tracks;
|
return res.data.tracks;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function trackVersionCode(appEdit, options, versionCode) {
|
function trackVersionCode(appEdit, options, versionCodes) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let status;
|
let status;
|
||||||
if (options.userFraction != undefined) {
|
if (options.userFraction != undefined) {
|
||||||
@@ -125,7 +127,7 @@ function trackVersionCode(appEdit, options, versionCode) {
|
|||||||
else {
|
else {
|
||||||
status = 'completed';
|
status = 'completed';
|
||||||
}
|
}
|
||||||
core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCode(${versionCode})`);
|
core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCodes(${versionCodes})`);
|
||||||
const res = yield androidPublisher.edits.tracks
|
const res = yield androidPublisher.edits.tracks
|
||||||
.update({
|
.update({
|
||||||
auth: options.auth,
|
auth: options.auth,
|
||||||
@@ -139,9 +141,7 @@ function trackVersionCode(appEdit, options, versionCode) {
|
|||||||
userFraction: options.userFraction,
|
userFraction: options.userFraction,
|
||||||
status: status,
|
status: status,
|
||||||
releaseNotes: yield whatsnew_1.readLocalizedReleaseNotes(options.whatsNewDir),
|
releaseNotes: yield whatsnew_1.readLocalizedReleaseNotes(options.whatsNewDir),
|
||||||
versionCodes: [
|
versionCodes: versionCodes.map(x => x.toString())
|
||||||
versionCode.toString()
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/edits.ts
24
src/edits.ts
@@ -33,14 +33,17 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
|
|||||||
packageName: options.applicationId
|
packageName: options.applicationId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var versionCodes = new Array<number>()
|
||||||
releaseFiles.forEach(async releaseFile => {
|
releaseFiles.forEach(async releaseFile => {
|
||||||
core.debug(`Uploading ${releaseFile}`)
|
core.debug(`Uploading ${releaseFile}`)
|
||||||
await uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
|
const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
|
||||||
core.setFailed(reason)
|
core.setFailed(reason)
|
||||||
return Promise.reject(reason)
|
return Promise.reject(reason)
|
||||||
})
|
})
|
||||||
|
versionCodes.push(versionCode!)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const track = trackVersionCode(appEdit.data, options, versionCodes)
|
||||||
const res = await androidPublisher.edits.commit({
|
const res = await androidPublisher.edits.commit({
|
||||||
auth: options.auth,
|
auth: options.auth,
|
||||||
editId: appEdit.data.id!,
|
editId: appEdit.data.id!,
|
||||||
@@ -56,18 +59,18 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile: string): Promise<string | undefined | null> {
|
async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile: string): Promise<number | undefined | null> {
|
||||||
// Check the 'track' for 'internalsharing', if so switch to a non-track api
|
// Check the 'track' for 'internalsharing', if so switch to a non-track api
|
||||||
if (options.track === 'internalsharing'){
|
if (options.track === 'internalsharing'){
|
||||||
core.debug("Track is Internal app sharing, switch to special upload api")
|
core.debug("Track is Internal app sharing, switch to special upload api")
|
||||||
if (releaseFile.endsWith('.apk')) {
|
if (releaseFile.endsWith('.apk')) {
|
||||||
const res = await internalSharingUploadApk(options, releaseFile)
|
const res = await internalSharingUploadApk(options, releaseFile)
|
||||||
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
|
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
|
||||||
return Promise.resolve(res.downloadUrl)
|
return Promise.resolve(undefined)
|
||||||
} else if (releaseFile.endsWith('.aab')) {
|
} else if (releaseFile.endsWith('.aab')) {
|
||||||
const res = await internalSharingUploadBundle(options, releaseFile)
|
const res = await internalSharingUploadBundle(options, releaseFile)
|
||||||
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
|
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
|
||||||
return Promise.resolve(res.downloadUrl)
|
return Promise.resolve(undefined)
|
||||||
} else {
|
} else {
|
||||||
core.setFailed(`${releaseFile} is invalid`)
|
core.setFailed(`${releaseFile} is invalid`)
|
||||||
return Promise.reject(`${releaseFile} is invalid`)
|
return Promise.reject(`${releaseFile} is invalid`)
|
||||||
@@ -80,15 +83,14 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile
|
|||||||
return Promise.reject(`No track found for "${options.track}"`)
|
return Promise.reject(`No track found for "${options.track}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let track: Track | undefined = undefined;
|
|
||||||
if (releaseFile.endsWith('.apk')) {
|
if (releaseFile.endsWith('.apk')) {
|
||||||
const apk = await uploadApk(appEdit, options, releaseFile);
|
const apk = await uploadApk(appEdit, options, releaseFile);
|
||||||
await uploadMappingFile(appEdit, apk.versionCode!, options);
|
await uploadMappingFile(appEdit, apk.versionCode!, options);
|
||||||
track = await trackVersionCode(appEdit, options, apk.versionCode!)
|
return Promise.resolve(apk.versionCode)
|
||||||
} else if (releaseFile.endsWith('.aab')) {
|
} else if (releaseFile.endsWith('.aab')) {
|
||||||
const bundle = await uploadBundle(appEdit, options, releaseFile);
|
const bundle = await uploadBundle(appEdit, options, releaseFile);
|
||||||
await uploadMappingFile(appEdit, bundle.versionCode!, options);
|
await uploadMappingFile(appEdit, bundle.versionCode!, options);
|
||||||
track = await trackVersionCode(appEdit, options, bundle.versionCode!)
|
return Promise.resolve(bundle.versionCode)
|
||||||
} else {
|
} else {
|
||||||
core.setFailed(`${releaseFile} is invalid`)
|
core.setFailed(`${releaseFile} is invalid`)
|
||||||
return Promise.reject(`${releaseFile} is invalid`)
|
return Promise.reject(`${releaseFile} is invalid`)
|
||||||
@@ -105,7 +107,7 @@ async function getAllTracks(appEdit: AppEdit, options: EditOptions): Promise<Tra
|
|||||||
return res.data.tracks
|
return res.data.tracks
|
||||||
}
|
}
|
||||||
|
|
||||||
async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCode: number): Promise<Track> {
|
async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCodes: number[]): Promise<Track> {
|
||||||
let status: string;
|
let status: string;
|
||||||
if (options.userFraction != undefined) {
|
if (options.userFraction != undefined) {
|
||||||
status = 'inProgress'
|
status = 'inProgress'
|
||||||
@@ -113,7 +115,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC
|
|||||||
status = 'completed'
|
status = 'completed'
|
||||||
}
|
}
|
||||||
|
|
||||||
core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCode(${versionCode})`);
|
core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCodes(${versionCodes})`);
|
||||||
const res = await androidPublisher.edits.tracks
|
const res = await androidPublisher.edits.tracks
|
||||||
.update({
|
.update({
|
||||||
auth: options.auth,
|
auth: options.auth,
|
||||||
@@ -127,9 +129,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC
|
|||||||
userFraction: options.userFraction,
|
userFraction: options.userFraction,
|
||||||
status: status,
|
status: status,
|
||||||
releaseNotes: await readLocalizedReleaseNotes(options.whatsNewDir),
|
releaseNotes: await readLocalizedReleaseNotes(options.whatsNewDir),
|
||||||
versionCodes: [
|
versionCodes: versionCodes.map(x => x.toString())
|
||||||
versionCode.toString()
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user