Skip to content

Commit

Permalink
Fix up Android authorization and signing
Browse files Browse the repository at this point in the history
  • Loading branch information
luxaritas committed Sep 6, 2024
1 parent 7bd84ec commit cfb814b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
if: ${{ matrix.target == 'android' }}
run: |
npx cordova build ${{ matrix.target }} --${{ env.BUILD_TYPE == 'prod' && 'release' || 'debug' }} --device \
--keystore="$RUNNER_TEMP/keystore.jks" --storePassword=${{ secrets.GOOGLE_PLAY_KEYSTORE_PASSWORD }} --alias=upload --password=${{ secrets.GOOGLE_PLAY_UPLOAD_KEY_PASSWORD }}
-- --keystore="$RUNNER_TEMP/keystore.jks" --storePassword=${{ secrets.GOOGLE_PLAY_KEYSTORE_PASSWORD }} --alias=upload --password=${{ secrets.GOOGLE_PLAY_UPLOAD_KEY_PASSWORD }}
env:
PARALLEL_BUILD: true

Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
if: ${{ matrix.target == 'ios' }}
run: |
npx cordova build ${{ matrix.target }} --${{ env.BUILD_TYPE == 'prod' && 'release' || 'debug' }} --device \
--automaticProvisioning --authenticationKeyPath="$RUNNER_TEMP/app_store_connect.p8" \
-- --automaticProvisioning --authenticationKeyPath="$RUNNER_TEMP/app_store_connect.p8" \
--authenticationKeyID=${{ secrets.APP_STORE_CONNECT_API_KEY_ID }} --authenticationKeyIssuerID="${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}" \
--developmentTeam="${{ secrets.APP_STORE_CONNECT_TEAM_ID }}" --codeSignIdentity="Apple Development" \
--packageType="${{ matrix.packageType }}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/google-play/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const PACKAGE_NAME = 'org.eternagame.mob';
const args = parseArgs();
const playStoreApi = await PlayStoreApi.create(args.apiKey);
if (args.mode === 'upload') {
console.log('Starting Upload')
const editId = await playStoreApi.insertEdit(PACKAGE_NAME);
await playStoreApi.uploadBundle(PACKAGE_NAME, editId, args.bundlePath);
await playStoreApi.commitEdit(PACKAGE_NAME, editId);
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/google-play/src/play-store-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ export class PlayStoreApi {
body: new URLSearchParams({
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
assertion: authToken
}).toString()
}).toString(),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
console.log('Access token:', res.status, res.statusText);
const parsed = await res.json();
return new PlayStoreApi(parsed['access_token']);
}
Expand All @@ -58,6 +62,7 @@ export class PlayStoreApi {
Authorization: `Bearer ${this.accessToken}`
}
});
console.log('Edit insert:', res.status, res.statusText);
const parsed = await res.json();
return parsed['id'];
}
Expand All @@ -69,7 +74,7 @@ export class PlayStoreApi {
*/
async uploadBundle(packageName, editId, bundlePath) {
const bundle = await readFile(bundlePath);
await fetch(`https://androidpublisher.googleapis.com/upload/androidpublisher/v3/applications/${packageName}/edits/${editId}/bundles?uploadType=media`, {
const res = await fetch(`https://androidpublisher.googleapis.com/upload/androidpublisher/v3/applications/${packageName}/edits/${editId}/bundles?uploadType=media`, {
method: 'POST',
headers: {
Authorization: `Bearer ${this.accessToken}`,
Expand All @@ -78,14 +83,17 @@ export class PlayStoreApi {
},
body: bundle
});
if (res.status === 403) console.log(await res.json())
console.log('Edit upload bundle:', res.status, res.statusText);
}

async commitEdit(packageName, editId) {
await fetch(`https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/edits/${editId}:commit`, {
const res = await fetch(`https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/edits/${editId}:commit`, {
method: 'POST',
headers: {
Authorization: `Bearer ${this.accessToken}`,
},
});
console.log('Edit commit:', res.status, res.statusText);
}
}

0 comments on commit cfb814b

Please sign in to comment.