fix: CI跳过android目录,prebuild后再构建APK

This commit is contained in:
Developer
2026-03-20 14:15:01 +08:00
parent 7f585ff8ad
commit 77985d7540
2 changed files with 11 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ jobs:
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add app.json package.json android/app/build.gradle
git add app.json package.json
git commit -m "chore: bump version to v${{ steps.bump.outputs.version }} [skip ci]"
git push
@@ -49,6 +49,9 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Expo Prebuild
run: npx expo prebuild --platform android --no-install
- name: Grant Gradle execute permission
run: chmod +x android/gradlew

View File

@@ -25,11 +25,13 @@ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
pkgJson.version = newVersion;
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
// Update android/app/build.gradle
// Update android/app/build.gradle if it exists (skipped in CI before prebuild)
const gradlePath = path.join(root, 'android', 'app', 'build.gradle');
if (fs.existsSync(gradlePath)) {
let gradle = fs.readFileSync(gradlePath, 'utf8');
gradle = gradle.replace(/versionCode\s+\d+/, `versionCode ${newVersionCode}`);
gradle = gradle.replace(/versionName\s+"[^"]+"/, `versionName "${newVersion}"`);
fs.writeFileSync(gradlePath, gradle);
}
console.log(newVersion);