Compare commits

..

No commits in common. "99dbce20539c4dce3e6e36c452010b4fd23cb3d1" and "f2b83650b5e71e23390f3d3fd365e704b70d11fa" have entirely different histories.

4 changed files with 8 additions and 178 deletions

View File

@ -777,15 +777,13 @@ cdc_resnapshot() {
fi
done
# Clear processed_cdc_events tables in all CDC consumer databases
# Clear processed_cdc_events table
log_step "Clearing processed CDC events..."
for db in "rwa_contribution" "rwa_auth"; do
if run_psql "$db" "TRUNCATE TABLE processed_cdc_events;" 2>/dev/null; then
log_success "Truncated processed_cdc_events in $db"
else
log_warn "Could not truncate processed_cdc_events in $db (table may not exist)"
fi
done
if run_psql "rwa_contribution" "TRUNCATE TABLE processed_cdc_events;" 2>/dev/null; then
log_success "Truncated processed_cdc_events in rwa_contribution"
else
log_warn "Could not truncate processed_cdc_events (table may not exist)"
fi
# For each CDC Postgres connector, save config, delete, and recreate
log_step "Re-creating CDC Postgres connectors..."

View File

@ -43,9 +43,3 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
# Auto-generated version code (each dev machine maintains its own)
/android/app/version.properties
# Build publish output
/publish/

View File

@ -1,7 +1,3 @@
import java.util.Properties
import java.io.FileInputStream
import java.io.FileOutputStream
plugins {
id("com.android.application")
id("kotlin-android")
@ -9,33 +5,6 @@ plugins {
id("dev.flutter.flutter-gradle-plugin")
}
// ============================================
// Auto-increment version code on each build
// ============================================
val versionPropertiesFile = rootProject.file("app/version.properties")
val versionProperties = Properties()
fun calculateNextVersionCode(): Int {
if (versionPropertiesFile.exists()) {
versionProperties.load(FileInputStream(versionPropertiesFile))
}
val currentCode = versionProperties.getProperty("VERSION_CODE", "0").toInt()
val newCode = currentCode + 1
versionProperties.setProperty("VERSION_CODE", newCode.toString())
versionProperties.store(FileOutputStream(versionPropertiesFile), "Auto-generated version code - DO NOT EDIT MANUALLY")
return newCode
}
// Get auto-incremented version code
val autoVersionCode = calculateNextVersionCode()
// Version name format: major.minor.patch (from pubspec.yaml) + build number
// Example: 1.0.0.123
fun getAutoVersionName(): String {
val flutterVersionName = flutter.versionName
return "$flutterVersionName.$autoVersionCode"
}
android {
namespace = "com.rwadurian.mining_app"
compileSdk = flutter.compileSdkVersion
@ -54,9 +23,8 @@ android {
applicationId = "com.rwadurian.mining_app"
minSdk = 24
targetSdk = flutter.targetSdkVersion
// Auto-incremented version code and name
versionCode = autoVersionCode
versionName = getAutoVersionName()
versionCode = flutter.versionCode
versionName = flutter.versionName
// 多dex支持
multiDexEnabled = true

View File

@ -1,130 +0,0 @@
#!/bin/bash
# =============================================================================
# Flutter APK 构建脚本(自动增加构建号)
# =============================================================================
# 用法:
# ./scripts/build.sh # 构建 release APK自动增加构建号
# ./scripts/build.sh --no-bump # 构建但不增加构建号
# ./scripts/build.sh --set 100 # 设置指定构建号
# =============================================================================
set -e
# 颜色
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
# 获取脚本目录
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
PUBSPEC_FILE="$PROJECT_DIR/pubspec.yaml"
# 读取当前版本
get_current_version() {
grep "^version:" "$PUBSPEC_FILE" | sed 's/version: //'
}
# 解析版本号
parse_version() {
local version="$1"
VERSION_NAME=$(echo "$version" | cut -d'+' -f1)
BUILD_NUMBER=$(echo "$version" | cut -d'+' -f2)
}
# 更新版本号
update_version() {
local new_version="$1"
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' "s/^version:.*/version: $new_version/" "$PUBSPEC_FILE"
else
# Linux
sed -i "s/^version:.*/version: $new_version/" "$PUBSPEC_FILE"
fi
}
# 主函数
main() {
cd "$PROJECT_DIR"
# 获取当前版本
CURRENT_VERSION=$(get_current_version)
parse_version "$CURRENT_VERSION"
log_info "当前版本: $CURRENT_VERSION"
log_info "版本名: $VERSION_NAME, 构建号: $BUILD_NUMBER"
# 处理参数
BUMP_VERSION=true
NEW_BUILD_NUMBER=""
while [[ $# -gt 0 ]]; do
case $1 in
--no-bump)
BUMP_VERSION=false
shift
;;
--set)
NEW_BUILD_NUMBER="$2"
shift 2
;;
*)
shift
;;
esac
done
# 更新构建号
if [ -n "$NEW_BUILD_NUMBER" ]; then
BUILD_NUMBER="$NEW_BUILD_NUMBER"
log_info "设置构建号为: $BUILD_NUMBER"
elif [ "$BUMP_VERSION" = true ]; then
BUILD_NUMBER=$((BUILD_NUMBER + 1))
log_info "自动增加构建号为: $BUILD_NUMBER"
fi
NEW_VERSION="${VERSION_NAME}+${BUILD_NUMBER}"
if [ "$CURRENT_VERSION" != "$NEW_VERSION" ]; then
update_version "$NEW_VERSION"
log_success "版本更新为: $NEW_VERSION"
fi
# 清理并获取依赖
log_info "获取依赖..."
flutter pub get
# 构建 APK
log_info "构建 Release APK..."
flutter build apk --release
# 输出结果
APK_PATH="$PROJECT_DIR/build/app/outputs/flutter-apk/app-release.apk"
if [ -f "$APK_PATH" ]; then
APK_SIZE=$(du -h "$APK_PATH" | cut -f1)
log_success "构建完成!"
echo ""
echo "APK 信息:"
echo " 版本: $NEW_VERSION"
echo " 路径: $APK_PATH"
echo " 大小: $APK_SIZE"
echo ""
# 复制到 publish 目录
PUBLISH_DIR="$PROJECT_DIR/publish"
mkdir -p "$PUBLISH_DIR"
cp "$APK_PATH" "$PUBLISH_DIR/mining-app-${VERSION_NAME}-${BUILD_NUMBER}.apk"
log_success "已复制到: $PUBLISH_DIR/mining-app-${VERSION_NAME}-${BUILD_NUMBER}.apk"
else
log_warn "APK 文件未找到"
exit 1
fi
}
main "$@"