-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): android internal testing
- Loading branch information
1 parent
2b795da
commit d438cd0
Showing
19 changed files
with
442 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ App/**/*.p8 | |
*.zip | ||
*.cer | ||
App/fastlane/report.xml | ||
affine.keystore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/frontend/apps/android/App/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { execSync } from 'node:child_process'; | ||
import fs from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
import { | ||
androidpublisher_v3, | ||
auth as google_auth, | ||
} from '@googleapis/androidpublisher'; | ||
|
||
export async function fetchVersionCode(applicationId: string): Promise<number> { | ||
const auth = new google_auth.GoogleAuth({ | ||
scopes: ['https://www.googleapis.com/auth/androidpublisher'], | ||
}); | ||
const androidPublisher = new androidpublisher_v3.Androidpublisher({ | ||
auth, | ||
}); | ||
const appEdit = await androidPublisher.edits.insert({ | ||
packageName: applicationId, | ||
requestBody: { | ||
// 20min | ||
expiryTimeSeconds: (Math.floor(Date.now() / 1000) + 12000).toString(), | ||
}, | ||
}); | ||
|
||
if (!appEdit.data.id) { | ||
throw new Error('Failed to create edit'); | ||
} | ||
|
||
const lists = await androidPublisher.edits.bundles.list({ | ||
packageName: applicationId, | ||
editId: appEdit.data.id, | ||
}); | ||
|
||
let versionCode: number = 1; | ||
try { | ||
versionCode = | ||
lists.data.bundles?.[lists.data.bundles.length - 1].versionCode || 1; | ||
} catch {} | ||
|
||
console.info(`Remote version code: ${versionCode}`); | ||
|
||
console.info(`Writing edit ID to ${process.env.GITHUB_OUTPUT}`); | ||
|
||
if (process.env.GITHUB_OUTPUT) { | ||
execSync( | ||
`echo "EDIT_ID=${appEdit.data.id}" >> ${process.env.GITHUB_OUTPUT}`, | ||
{ | ||
stdio: 'inherit', | ||
} | ||
); | ||
} | ||
|
||
return versionCode; | ||
} | ||
|
||
const versionCodeRegexPattern = /(versionCode(?:\s|=)*)(.*)/; | ||
const gradlePath = join( | ||
fileURLToPath(import.meta.url), | ||
'..', | ||
'..', | ||
'..', | ||
'packages/frontend/apps/android/App/app/build.gradle' | ||
); | ||
|
||
let gradleVersionCode = 0; | ||
|
||
const gradleFile = fs.readFileSync(gradlePath, 'utf8'); | ||
const matched = gradleFile.match(versionCodeRegexPattern); | ||
|
||
const remoteVersion = await fetchVersionCode('app.affine.pro'); | ||
|
||
gradleVersionCode = parseInt(matched?.[2] || '0'); | ||
gradleVersionCode = isNaN(gradleVersionCode) ? 0 : gradleVersionCode; | ||
const versionCode = Math.max(gradleVersionCode, remoteVersion) + 1; | ||
|
||
fs.writeFileSync( | ||
gradlePath, | ||
gradleFile.replace(versionCodeRegexPattern, `$1 ${versionCode}`) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@affine/playstore-auto-bump", | ||
"version": "0.17.0", | ||
"private": true, | ||
"type": "module", | ||
"description": "Automatically bump the versionCode and versionName of an Android app from the Google Play Store versions", | ||
"main": "index.ts", | ||
"scripts": { | ||
"bump": "node --import @oxc-node/core/register index.ts" | ||
}, | ||
"dependencies": { | ||
"@googleapis/androidpublisher": "^22.0.0", | ||
"@oxc-node/core": "^0.0.15" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.14.12", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": ".", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler" | ||
}, | ||
"exclude": ["dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.