1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

Android: building aab for release

This commit is contained in:
Andrii Danylchenko 2023-04-15 11:47:24 +03:00
parent c125e040c3
commit 4d34c83c0b
5 changed files with 144 additions and 17 deletions

View File

@ -130,7 +130,7 @@ jobs:
preset: android-conan-ninja-release preset: android-conan-ninja-release
conan_profile: android-64 conan_profile: android-64
conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
artifact_platform: aarch64-v8a artifact_platform: arm64-v8a
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
defaults: defaults:
run: run:
@ -225,6 +225,7 @@ jobs:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
path: | path: |
${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }} ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
- name: Android artifacts - name: Android artifacts
if: ${{ startsWith(matrix.platform, 'android') }} if: ${{ startsWith(matrix.platform, 'android') }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
@ -233,6 +234,14 @@ jobs:
path: | path: |
${{ env.ANDROID_APK_PATH }} ${{ env.ANDROID_APK_PATH }}
- name: Android JNI ${{matrix.platform}}
if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v3
with:
name: Android JNI ${{matrix.platform}}
path: |
${{ github.workspace }}/android/vcmi-app/src/main/jniLibs
- name: Upload build - name: Upload build
if: ${{ (matrix.pack == 1 || startsWith(matrix.platform, 'android')) && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/features/')) && matrix.platform != 'msvc' }} if: ${{ (matrix.pack == 1 || startsWith(matrix.platform, 'android')) && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/features/')) && matrix.platform != 'msvc' }}
continue-on-error: true continue-on-error: true
@ -254,3 +263,106 @@ jobs:
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always() if: always()
# copy-pasted mostly
bundle_release:
needs: build
if: always() && github.ref == 'refs/heads/master'
strategy:
matrix:
include:
- platform: android-32
os: ubuntu-22.04
extension: aab
preset: android-conan-ninja-release
conan_profile: android-32
conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
artifact_platform: aab
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Dependencies
run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
env:
VCMI_BUILD_PLATFORM: x64
- uses: actions/setup-python@v4
if: "${{ matrix.conan_profile != '' }}"
with:
python-version: '3.10'
- name: Conan setup
if: "${{ matrix.conan_profile != '' }}"
run: |
pip3 install 'conan<2.0'
conan profile new default --detect
conan install . \
--install-folder=conan-generated \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=CI/conan/${{ matrix.conan_profile }} \
${{ matrix.conan_options }}
env:
GENERATE_ONLY_BUILT_CONFIG: 1
- name: Git branch name
id: git-branch-name
uses: EthanSK/git-branch-name-action@v1
- name: Build Number
run: |
source '${{github.workspace}}/CI/get_package_name.sh'
if [ '${{ matrix.artifact_platform }}' ]; then
VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
fi
echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
echo VCMI_PACKAGE_GITVERSION="$VCMI_PACKAGE_GITVERSION" >> $GITHUB_ENV
env:
PULL_REQUEST: ${{ github.event.pull_request.number }}
- name: CMake Preset
run: |
cmake --preset ${{ matrix.preset }}
- name: Build Preset
run: |
cmake --build --preset ${{matrix.preset}}
- name: Download libs x64
uses: actions/download-artifact@v3
with:
name: Android JNI android-64
path: ${{ github.workspace }}/android/vcmi-app/src/main/jniLibs/
- name: Create android package
run: |
cd android
./gradlew bundleRelease --info
echo ANDROID_APK_PATH="$(ls ${{ github.workspace }}/android/vcmi-app/build/outputs/bundle/release/*.aab)" >> $GITHUB_ENV
env:
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Android artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
path: |
${{ env.ANDROID_APK_PATH }}
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
channel: '#notifications'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()

Binary file not shown.

View File

@ -0,0 +1,2 @@
STORE_FILE=android-release.jks
KEY_ALIAS=vcmi

View File

@ -10,14 +10,16 @@ android {
applicationId "is.xyz.vcmi" applicationId "is.xyz.vcmi"
minSdk 19 minSdk 19
targetSdk 31 targetSdk 31
versionCode 1103 versionCode 1200
versionName "1.1" versionName "1.2"
setProperty("archivesBaseName", "vcmi") setProperty("archivesBaseName", "vcmi")
} }
signingConfigs { signingConfigs {
releaseSigning releaseSigning
LoadSigningConfig() dailySigning
LoadSigningConfig("releaseSigning")
LoadSigningConfig("dailySigning")
} }
buildTypes { buildTypes {
@ -46,6 +48,7 @@ android {
daily { daily {
initWith release initWith release
applicationIdSuffix '.daily' applicationIdSuffix '.daily'
signingConfig signingConfigs.dailySigning
manifestPlaceholders = [ manifestPlaceholders = [
applicationLabel: 'VCMI daily', applicationLabel: 'VCMI daily',
] ]
@ -118,38 +121,48 @@ def ResolveGitInfo() {
CommandOutput("git", ["describe", "--match=", "--always", "--abbrev=7"], ".") CommandOutput("git", ["describe", "--match=", "--always", "--abbrev=7"], ".")
} }
def SigningPropertiesPath(final basePath) { def SigningPropertiesPath(final basePath, final signingConfigKey) {
return file("${basePath}/signing.properties") return file("${basePath}/${signingConfigKey}.properties")
} }
def SigningKeystorePath(final basePath, final keystoreFileName) { def SigningKeystorePath(final basePath, final keystoreFileName) {
return file("${basePath}/${keystoreFileName}") return file("${basePath}/${keystoreFileName}")
} }
def LoadSigningConfig() { def LoadSigningConfig(final signingConfigKey) {
final def projectRoot = "${project.projectDir}/../../CI/android" final def projectRoot = "${project.projectDir}/../../CI/android"
final def props = new Properties() final def props = new Properties()
final def propFile = SigningPropertiesPath(projectRoot) final def propFile = SigningPropertiesPath(projectRoot, signingConfigKey)
def signingConfig = android.signingConfigs.getAt(signingConfigKey)
if (propFile.canRead()) { if (propFile.canRead()) {
props.load(new FileInputStream(propFile)) props.load(new FileInputStream(propFile))
if (props != null if (props != null
&& props.containsKey('STORE_FILE') && props.containsKey('STORE_FILE')
&& props.containsKey('STORE_PASSWORD') && props.containsKey('KEY_ALIAS')) {
&& props.containsKey('KEY_ALIAS')
&& props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.releaseSigning.storeFile = SigningKeystorePath(projectRoot, props['STORE_FILE']) signingConfig.storeFile = SigningKeystorePath(projectRoot, props['STORE_FILE'])
android.signingConfigs.releaseSigning.storePassword = props['STORE_PASSWORD'] signingConfig.storePassword = props['STORE_PASSWORD']
android.signingConfigs.releaseSigning.keyAlias = props['KEY_ALIAS'] signingConfig.keyAlias = props['KEY_ALIAS']
android.signingConfigs.releaseSigning.keyPassword = props['KEY_PASSWORD']
if(props.containsKey('STORE_PASSWORD'))
signingConfig.storePassword = props['STORE_PASSWORD']
else
signingConfig.storePassword = System.getenv("ANDROID_STORE_PASSWORD")
if(props.containsKey('KEY_PASSWORD'))
signingConfig.keyPassword = props['KEY_PASSWORD']
else
signingConfig.keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
} else { } else {
println("Some props from signing file are missing") println("Some props from signing file are missing")
android.buildTypes.release.signingConfig = null android.signingConfigs.putAt(signingConfigKey, null)
} }
} else { } else {
println("file with signing properties is missing") println("file with signing properties is missing")
android.buildTypes.release.signingConfig = null android.signingConfigs.putAt(signingConfigKey, null)
} }
} }