ci(android): add Android NDK caching and installation to build workflow

This commit is contained in:
lafay
2026-05-14 01:25:54 +08:00
parent 1d9c312c6c
commit 4308077232
5 changed files with 162 additions and 11 deletions

View File

@@ -17,19 +17,40 @@ const withJPush = (config, options = {}) => {
// 1. Android: Inject manifestPlaceholders into app/build.gradle
config = withAppBuildGradle(config, (config) => {
const block = '\n manifestPlaceholders = [\n' +
' JPUSH_APPKEY: "' + appKey + '",\n' +
' JPUSH_CHANNEL: "' + channel + '"\n' +
' ]';
const contents = config.modResults.contents;
if (contents.includes('manifestPlaceholders')) {
config.modResults.contents = contents.replace(
/manifestPlaceholders\s*=\s*\[[\s\S]*?\]/,
block.trim()
);
const requiredPlaceholders = {
JPUSH_APPKEY: appKey,
JPUSH_CHANNEL: channel,
};
const manifestPlaceholderRegex = /manifestPlaceholders\s*=\s*\[([\s\S]*?)\]/;
const match = contents.match(manifestPlaceholderRegex);
if (match) {
const existingBlock = match[1];
const existingEntries = {};
const entryRegex = /(\w+)\s*:\s*"([^"]*)"/g;
let entryMatch;
while ((entryMatch = entryRegex.exec(existingBlock)) !== null) {
existingEntries[entryMatch[1]] = entryMatch[2];
}
for (const [key, value] of Object.entries(requiredPlaceholders)) {
existingEntries[key] = value;
}
const entriesStr = Object.entries(existingEntries)
.map(([k, v]) => `${k}: "${v}"`)
.join(',\n ');
const newBlock = `\n manifestPlaceholders = [\n ${entriesStr}\n ]`;
config.modResults.contents = contents.replace(manifestPlaceholderRegex, newBlock.trim());
} else if (contents.includes('REACT_NATIVE_RELEASE_LEVEL')) {
const entriesStr = Object.entries(requiredPlaceholders)
.map(([k, v]) => `${k}: "${v}"`)
.join(',\n ');
const block = '\n manifestPlaceholders = [\n ' + entriesStr + '\n ]';
const lines = contents.split('\n');
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes('REACT_NATIVE_RELEASE_LEVEL')) {