-
-
Notifications
You must be signed in to change notification settings - Fork 29
189 lines (169 loc) · 7.82 KB
/
Copy pathandroid.yml
File metadata and controls
189 lines (169 loc) · 7.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# Author: Kang Lin <kl222@126.com>
name: android
on:
workflow_call:
outputs:
name:
description: "The artifact name"
value: ${{ jobs.build_android.outputs.name }}
jobs:
build_android:
strategy:
matrix:
include:
- qt_arch: android_arm64_v8a
VCPKG_TARGET_TRIPLET: arm64-android
ANDROID_ABI: arm64-v8a
arch: arm64
qt_version: 6.10.3
BUILD_TYPE: Release
- qt_arch: android_x86_64
VCPKG_TARGET_TRIPLET: x64-android
ANDROID_ABI: x86_64
arch: x86_64
qt_version: 6.10.3
BUILD_TYPE: Release
# See: [About GitHub-hosted runners](https://docs.github.com/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners)
# See: [Choosing the runner for a job](https://docs.github.com/actions/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job)
# See: https://github.com/actions/runner-images/
runs-on: ubuntu-24.04
env:
artifact_name: build_android
VCPKGGITCOMMITID: 7213cf8135c329c37c7e2778e40774489a0583a8
VCPKG_TARGET_TRIPLET: ${{matrix.VCPKG_TARGET_TRIPLET}}
VCPKG_DEFAULT_TRIPLET: ${{matrix.VCPKG_TARGET_TRIPLET}}
VCPKG_DEFAULT_HOST_TRIPLET: x64-linux
VCPKG_MANIFEST_FEATURES: "freerdp;vnc;wol;filetransfer;${{matrix.VCPKG_MANIFEST_FEATURES}}"
BUILD_DIR: ${{github.workspace}}/build
SOURCE_DIR: ${{github.workspace}}/.cache/source
TOOLS_DIR: ${{github.workspace}}/.cache/tools
INSTALL_DIR: ${{github.workspace}}/.cache/install
#ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/26.3.11579264
ANDROID_PLATFORM: android-34
ANDROID_NATIVE_API_LEVEL: 34
ANDROID_ABI: ${{matrix.ANDROID_ABI}}
qt_modules: 'qtimageformats qtmultimedia qtscxml qtwebchannel qtpositioning qtserialport qt5compat'
ChineseChessControl_VERSION: "v2.0.14"
# Map the job outputs to step outputs
outputs:
name: ${{ env.artifact_name }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
submodules: recursive
- name: make directory
run: |
cmake -E make_directory ${{env.SOURCE_DIR}}
cmake -E make_directory ${{env.TOOLS_DIR}}
cmake -E make_directory ${{env.INSTALL_DIR}}
cmake -E make_directory ${{env.BUILD_DIR}}
- name: Install apt packages
run: |
#sudo apt-get update -y
#sudo apt-get upgrade -y
sudo apt install -y -q ninja-build nasm
- name: Cache installed
#if: false
uses: actions/cache@v5
id: cache-installed
with:
path: |
${{env.INSTALL_DIR}}
key: install_android_qt${{matrix.qt_version}}_${{matrix.qt_arch}}_${{matrix.BUILD_TYPE}}
- name: run vcpkg
uses: lukka/run-vcpkg@v11
with:
# Indicates whether to only setup vcpkg (i.e. installing it and setting the environment variables VCPKG_ROOT, RUNVCPK_VCPKG_ROOT), without installing any port.
#setupOnly: # optional
#vcpkgGitURL: https://github.com/KangLin/vcpkg.git
vcpkgGitCommitId: ${{env.VCPKGGITCOMMITID}}
vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
- name: Install Qt of linux_gcc_64
uses: jurplel/install-qt-action@v4
with:
dir: '${{env.TOOLS_DIR}}/qt' # optional
version: '${{matrix.qt_version}}'
#host: 'linux'
target: 'desktop'
arch: 'linux_gcc_64'
set-env: false
cache: true
cache-key-prefix: cached-qt_${{matrix.qt_version}}_${{matrix.qt_arch}}
- name: Install Qt of android
uses: jurplel/install-qt-action@v4
with:
# Directory to install Qt
dir: '${{env.TOOLS_DIR}}/qt' # optional
# Version of Qt to install
version: '${{matrix.qt_version}}'
# Host platform
#host: linux # optional
# Target platform for build
target: 'android' # optional, default is desktop
# Architecture for Windows/Android
arch: '${{matrix.qt_arch}}' # optional
# Additional Qt modules to install
modules: '${{env.qt_modules}}' # optional. See: https://ddalcino.github.io/aqt-list-server/
cache: true
cache-key-prefix: cached-qt_${{matrix.qt_version}}_${{matrix.qt_arch}}
- name: chmod qt-cmake
run: |
sudo chmod 777 ${QT_ROOT_DIR}/bin/qt-cmake
# 清理 resConfig
find ${QT_ROOT_DIR} -path "*/templates/build.gradle" -type f | while read file; do
echo "Fixing: $file"
sed -i 's/resConfig "en"//g' "$file"
done
- name: git clone RabbitCommon
working-directory: ${{env.SOURCE_DIR}}
run: |
git clone https://github.com/KangLin/RabbitCommon.git
- name: build ChineseChessControl
working-directory: ${{github.workspace}}/build
env:
RabbitCommon_ROOT: ${{env.SOURCE_DIR}}/RabbitCommon
QT_ANDROID_KEYSTORE_PATH: ${{env.SOURCE_DIR}}/RabbitCommon/RabbitCommon.keystore
QT_ANDROID_KEYSTORE_ALIAS: rabbitcommon
QT_ANDROID_KEYSTORE_STORE_PASS: ${{secrets.STOREPASS}}
JAVA_HOME: ${{env.JAVA_HOME_17_X64}}
run: |
sudo chmod 777 ${QT_ROOT_DIR}/bin/qt-cmake
${QT_ROOT_DIR}/bin/qt-cmake .. \
-DCMARK_SHARED=OFF \
-DCMARK_TESTS=OFF \
-DCMARK_STATIC=ON \
-DWITH_CMARK=OFF \
-DWITH_CMARK_GFM=ON \
-DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} \
-DANDROID_PLATFORM=${{env.ANDROID_PLATFORM}} \
-DQT_CHAINLOAD_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
-DVCPKG_TARGET_TRIPLET=${{env.VCPKG_TARGET_TRIPLET}} \
-DVCPKG_MANIFEST_FEATURES="${{env.VCPKG_MANIFEST_FEATURES}}" \
-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON \
-DVCPKG_VERBOSE=ON \
-DRABBIT_ENABLE_INSTALL_DEPENDENT=ON \
-DRABBIT_ENABLE_INSTALL_QT=ON \
-DRABBIT_ENABLE_INSTALL_TO_BUILD_PATH=ON \
-DCMAKE_PREFIX_PATH=${QT_ROOT_DIR}:${{env.INSTALL_DIR}} \
-DQT_HOST_PATH=${QT_ROOT_DIR}/../gcc_64 \
-DQT_ANDROID_SIGN_APK=ON \
-DQT_ENABLE_VERBOSE_DEPLOYMENT=ON \
-DVCPKG_TRACE_FIND_PACKAGE=ON \
-DQt6LinguistTools_DIR=${QT_ROOT_DIR}/../gcc_64/lib/cmake/Qt6LinguistTools \
-DCMAKE_INSTALL_PREFIX=`pwd`/install \
-DENABLE_UPDATE_TRANSLATIONS=ON
cmake --build . --parallel $(nproc) --config ${{matrix.BUILD_TYPE}} --target all
APK_FILE=`find . -name "android-*.apk"`
cp $APK_FILE ChineseChessControl_${{env.ChineseChessControl_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
cmake --build . --config ${{matrix.BUILD_TYPE}} --target install
7z a ChineseChessControl_${{env.ChineseChessControl_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.zip ./install/*
- name: Update artifact
#if: ${{ matrix.BUILD_TYPE == 'Release' }}
uses: actions/upload-artifact@v7
with:
name: ${{ env.artifact_name }}_${{matrix.qt_version}}_${{matrix.qt_arch}}
path: |
${{github.workspace}}/build/ChineseChessControl_${{env.ChineseChessControl_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.zip
${{github.workspace}}/build/ChineseChessControl_${{env.ChineseChessControl_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk