Files
goldenChart/scripts/bump-android-version.sh
T
Macbook c840e09885 feat: Android 폰·태블릿 다운로드·앱 내 업데이트 완료
CI에서 APK 버전 자동 bump, 앱 복귀 시 업데이트 확인·시스템 다운로드,
프론트 Android 전용 UI 정리(iPad는 향후).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 17:03:10 +09:00

48 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# CI: .env GC_MOBILE_APP_VERSION 또는 build.gradle 기준 patch bump + versionCode++
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
WORK_TREE="${WORK_TREE:-$ROOT}"
GRADLE="${GRADLE:-$ROOT/app/android/app/build.gradle}"
ENV_FILE="${ENV_FILE:-$WORK_TREE/.env}"
if [[ ! -f "$GRADLE" ]]; then
echo "build.gradle 없음: $GRADLE" >&2
exit 1
fi
ENV_VER=""
if [[ -f "$ENV_FILE" ]]; then
ENV_VER="$(grep '^GC_MOBILE_APP_VERSION=' "$ENV_FILE" 2>/dev/null | cut -d= -f2- | tr -d '\r' || true)"
fi
node -e "
const fs = require('fs');
const gradlePath = process.argv[1];
const envVersion = (process.argv[2] || '').trim();
let content = fs.readFileSync(gradlePath, 'utf8');
const vc = content.match(/versionCode\\s+(\\d+)/);
const vn = content.match(/versionName\\s+\"([^\"]+)\"/);
if (!vc || !vn) {
console.error('versionCode/versionName 파싱 실패');
process.exit(1);
}
let versionCode = parseInt(vc[1], 10);
let base = envVersion || vn[1];
const parts = base.split('.').map(n => parseInt(n, 10) || 0);
while (parts.length < 2) parts.push(0);
if (parts.length === 2) {
parts[1] += 1;
} else {
while (parts.length < 3) parts.push(0);
parts[2] += 1;
}
const versionName = parts.join('.');
versionCode += 1;
content = content.replace(/versionCode\\s+\\d+/, 'versionCode ' + versionCode);
content = content.replace(/versionName\\s+\"[^\"]+\"/, 'versionName \"' + versionName + '\"');
fs.writeFileSync(gradlePath, content);
console.log(versionName);
" "$GRADLE" "$ENV_VER"