fix/ android-release-build workflow
This commit is contained in:
25
.github/workflows/android-release.yml
vendored
25
.github/workflows/android-release.yml
vendored
@@ -100,21 +100,21 @@ jobs:
|
||||
echo "签名配置就绪"
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# 6. 覆盖版本号(如果从 Tag 或手动输入获取)
|
||||
# 6. 记录版本注入参数(通过 Gradle project properties 传入,避免修改 Kotlin DSL)
|
||||
# -----------------------------------------------------------------------
|
||||
- name: Update version in build.gradle.kts
|
||||
- name: Log version build inputs
|
||||
working-directory: app-android
|
||||
run: |
|
||||
VERSION_NAME="${{ steps.version.outputs.version_name }}"
|
||||
VERSION_CODE="${{ steps.version.outputs.version_code }}"
|
||||
|
||||
echo "更新版本: versionName=${VERSION_NAME}, versionCode=${VERSION_CODE}"
|
||||
|
||||
sed -i "s/versionCode = [0-9]*/versionCode = ${VERSION_CODE}/" app/build.gradle.kts
|
||||
sed -i "s/versionName = \"[^\"]*\"/versionName = \"${VERSION_NAME}\"/" app/build.gradle.kts
|
||||
|
||||
echo "验证更新后的版本信息:"
|
||||
grep -E 'versionCode|versionName' app/build.gradle.kts
|
||||
#region agent log
|
||||
echo "[agent][H3] 使用 Gradle 属性注入版本号,避免 sed 修改 build.gradle.kts"
|
||||
echo "[agent][H3] versionName=${VERSION_NAME}"
|
||||
echo "[agent][H3] versionCode=${VERSION_CODE}"
|
||||
echo "[agent][H3] build.gradle.kts 当前仍保留变量引用:"
|
||||
grep -E 'versionCode = appVersionCode|versionName = appVersionName' app/build.gradle.kts
|
||||
#endregion
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# 7. 构建 Release APK
|
||||
@@ -124,7 +124,12 @@ jobs:
|
||||
run: |
|
||||
echo "开始构建 Release APK..."
|
||||
chmod +x gradlew
|
||||
./gradlew assembleRelease --no-daemon
|
||||
VERSION_NAME="${{ steps.version.outputs.version_name }}"
|
||||
VERSION_CODE="${{ steps.version.outputs.version_code }}"
|
||||
#region agent log
|
||||
echo "[agent][H3] 执行: ./gradlew assembleRelease --no-daemon -PversionName=${VERSION_NAME} -PversionCode=${VERSION_CODE}"
|
||||
#endregion
|
||||
./gradlew assembleRelease --no-daemon -PversionName="${VERSION_NAME}" -PversionCode="${VERSION_CODE}"
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# 8. 查找并重命名 APK
|
||||
|
||||
Reference in New Issue
Block a user