forked from M66B/FairEmail
-
Notifications
You must be signed in to change notification settings - Fork 1
296 lines (270 loc) · 10.6 KB
/
build-github.yml
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# 2024-01-28 21:10
# build-github.yml
name: FairEmail - github
on:
workflow_dispatch:
inputs:
create-archive-all:
description: Create archive with ~ all files
type: boolean
default: false
compileSdkVersion:
description: compileSdkVersion
type: boolean
default: false
skip_sign:
description: skip sign
type: boolean
default: false
env:
PRG_NAME: "FairEmail"
PRG_VERSION: "v1.2080"
PRG_VERSION_suffix: "a"
PRG_FLAVOR: "github"
TAG_NAME: "FairEmail"
TAG_VERSION: "v1.2080"
TAG_BUILD: "-b"
TAG_REF: "0000000"
ANDROID_SIGNING_KEY: '${{ secrets.ANDROID_SIGNING_KEY }}'
# signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
# alias: ${{ secrets.ANDROID_ALIAS }}
# keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
# keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
# BUILD_TOOLS_VERSION: "34.0.0"
# BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOLS_VERSION }}
BUILD_TOOLS_VERSION: "34.0.0"
jobs:
validation:
runs-on: ubuntu-latest
steps:
- uses: deep-soft/checkout@v4
- uses: deep-soft/wrapper-validation-action@v2
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: deep-soft/checkout@v4
- name: Get ref, set build version
continue-on-error: true
shell: bash
run: |
# set -x
_ref_all_=$(git log -1 --format='%H')
# _ref_=$(echo ${_ref_all_::7})
_ref_org_=${{ env.TAG_REF }}
_ref_len_="${#_ref_org_}"
_ref_=$(echo ${_ref_all_::$_ref_len_})
_prg_version_base_="v"$(grep "versionName " "app/build.gradle" | cut -d '"' -f2)
_prg_version_=$_prg_version_base_$(grep "def getVersionCode" "app/build.gradle" | cut -d ' ' -f7)
echo "TAG_REF=$_ref_" >> $GITHUB_ENV
_build_=${{ env.TAG_BUILD }}.$_ref_
echo "TAG_BUILD=$_build_" >> $GITHUB_ENV
echo "PRG_VERSION=$_prg_version_" >> $GITHUB_ENV
echo "TAG_VERSION=$_prg_version_" >> $GITHUB_ENV
- name: Print ref, build version
shell: bash
run: |
echo "NAM: ${{ env.PRG_NAME }}"
echo "VER: ${{ env.PRG_VERSION }}"
echo "TAG: ${{ env.TAG_VERSION }}"
echo "REF: ${{ env.TAG_REF }}"
echo "BLD: ${{ env.TAG_BUILD }}"
echo "${{ env.PRG_NAME }}-src-${{ env.PRG_VERSION }}-${{ env.TAG_BUILD }}" > _tag_name_.txt
- name: compileSdkVersion
if: ${{ inputs.compileSdkVersion }}
shell: bash
run: |
#set -x;
echo "compileSdk ... ";
grep -i "compileSdk" "app/build.gradle" || true;
echo "... done";
sed -ibak 's|compileSdk |compileSdkVersion |' "app/build.gradle";
sed -ibk2 's| dimension "all"| dimension "all"\n compileSdkVersion 34|' "app/build.gradle";
echo "compileSdk ... ";
grep -i "compileSdk" "app/build.gradle" || true;
echo "... done";
ls -la app/
# signingConfig signingConfigs.release
- name: skip sign
if: ${{ inputs.skip_sign }}
shell: bash
run: |
#set -x;
echo "sign ... ";
grep -i "sign" "app/build.gradle" || true;
echo "... done ";
echo "keystore ... ";
grep "keystore" "app/build.gradle" || true;
echo "... done ";
sed -i '/^ signingConfigs {$/,/^ }$/d' "app/build.gradle";
sed -i '/signingConfig signingConfigs.release/d' "app/build.gradle";
sed -i '/^def keystoreProperties = new Properties()$/,/^keystoreProperties.load(new FileInputStream(rootProject.file(\"keystore.properties\")))$/d' "app/build.gradle";
echo "sign ... ";
grep -i "sign" "app/build.gradle" || true;
sleep 2
echo "keystore ... ";
grep "keystore" "app/build.gradle" || true;
echo "... done";
echo " app/build.gradle ... ";
cat "app/build.gradle";
echo " ... app/build.gradle";
# signingConfig signingConfigs.release
- name: skip sign v2
shell: bash
run: |
#set -x;
echo "sign ... ";
grep -i "sign" "app/build.gradle" || true;
echo "... done ";
sed -i '/^ signingConfigs {$/,/^ }$/d' "app/build.gradle";
sed -i 's|signingConfig signingConfigs.release|// signingConfig signingConfigs.release|' "app/build.gradle";
echo "sign ... ";
grep -i "sign" "app/build.gradle" || true;
echo "... done";
echo " app/build.gradle ... ";
cat "app/build.gradle";
echo " ... app/build.gradle";
# zip source begin
- name: Create Archive source
# if: inputs.create-archive-all == true
uses: deep-soft/zip-release@v3
with:
type: 'zip'
filename: '${{ env.TAG_NAME }}-${{ env.TAG_VERSION }}-${{ env.PRG_FLAVOR }}-src.zip'
directory: '.'
path: '.'
exclusions: '*.git* ./*.git/* ./app/schemas/* ./app/schemas/ /*node_modules/* .editorconfig'
env_variable: 'ZIP_RELEASE_SOURCE'
# default archive name is ${{ env.ZIP_RELEASE_ARCHIVE }}
- name: print env value
# if: inputs.create-archive-all == true
shell: bash
run: |
echo "env.ZIP_RELEASE_SOURCE=${{ env.ZIP_RELEASE_SOURCE }}"
echo "env.ZIP_RELEASE_ARCHIVE=${{ env.ZIP_RELEASE_ARCHIVE }}"
- name: Publish source
# if: inputs.create-archive-all == true
continue-on-error: true
uses: deep-soft/action-gh-release@v2.1
with:
draft: true
tag_name: ${{ env.TAG_NAME }}-${{ env.PRG_FLAVOR }}
files: |
${{ env.ASSET_REL }}
${{ env.ZIP_RELEASE_SOURCE }}
# zip source end
- name: Setup java (v4)
uses: deep-soft/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: gradle build (v3)
uses: deep-soft/gradle-build-action@v3
- name: gradle Assemble github Release
run: ./gradlew assemblegithubRelease
# Search in /usr/local/lib/android/sdk/build-tools/
- name: List android/sdk/build-tools/
shell: bash
run: |
echo "ls -la /usr/local/lib/android/sdk/ || true;"
ls -la /usr/local/lib/android/sdk/ || true;
echo "ls -la /usr/local/lib/android/sdk/build-tools/ || true;"
ls -la /usr/local/lib/android/sdk/build-tools/ || true;
# zip release begin
- name: Create Archive All
if: inputs.create-archive-all == true
uses: deep-soft/zip-release@v3
with:
type: 'zip'
filename: '${{ env.TAG_NAME }}-${{ env.TAG_VERSION }}-${{ env.PRG_FLAVOR }}-all.zip'
directory: '.'
path: '.'
exclusions: '*.git* ./*.git/* ./app/schemas/* ./app/schemas/ /*node_modules/* .editorconfig'
# archive name is ${{ env.ZIP_RELEASE_ARCHIVE }}
- name: print env value
if: inputs.create-archive-all == true
shell: bash
run: |
echo "env.ZIP_RELEASE_ARCHIVE=${{ env.ZIP_RELEASE_ARCHIVE }}"
- name: Publish Release
if: inputs.create-archive-all == true
continue-on-error: true
uses: deep-soft/action-gh-release@v2.1
with:
draft: true
tag_name: ${{ env.TAG_NAME }}-${{ env.PRG_FLAVOR }}
files: |
${{ env.ASSET_REL }}
${{ env.ZIP_RELEASE_ARCHIVE }}
# zip release end
- name: Upload Artifact
uses: deep-soft/upload-artifact@v4
with:
name: upload-artifact
path: |
./app/build/outputs/apk/github/release/
- name: Copy apk from outputs/
shell: bash
run: |
set -x
mkdir -p signed-apk
echo "LIST: " ./app/build/outputs/apk/github/release/
ls -l ./app/build/outputs/apk/github/release/
cp ./app/build/outputs/apk/github/release/*.apk ./signed-apk/ || true;
cp ./app/build/outputs/apk/github/release/*.json ./signed-apk/ || true;
echo "LIST: " ./signed-apk/
ls -l ./signed-apk/ || true;
mv ./signed-apk/${{ env.PRG_NAME }}-${{ env.PRG_VERSION }}*-${{ env.PRG_FLAVOR }}-release-unsigned.apk ./signed-apk/${{ env.PRG_NAME }}-${{ env.PRG_VERSION }}-${{ env.PRG_FLAVOR }}-release.apk
echo "LIST: " ${{ env.PRG_NAME }}-${{ env.PRG_VERSION }}-${{ env.PRG_FLAVOR }}-release.apk
ls -l ./signed-apk/ || true;
- uses: deep-soft/sign-android-release@v1
name: Sign app APK
if: env.ANDROID_SIGNING_KEY != null
id: sign-FairEmail
with:
releaseDirectory: ./signed-apk
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
alias: ${{ secrets.ANDROID_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
env:
# override default build-tools version (29.0.3) -- optional
# BUILD_TOOLS_VERSION: "30.0.2"
# BUILD_TOOLS_VERSION: "34.0.5"
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOLS_VERSION }}
- name: Upload Artifacts
if: env.ANDROID_SIGNING_KEY != null
uses: deep-soft/upload-artifact@v4
with:
name: ${{ env.PRG_NAME }}-${{ env.PRG_VERSION }}-${{ env.PRG_FLAVOR }}-release.apk
path: ${{steps.sign-FairEmail.outputs.signedReleaseFile}}
- name: Publish signed apk package
if: env.ANDROID_SIGNING_KEY != null
uses: deep-soft/action-gh-release@v2.1
with:
draft: true
tag_name: ${{ env.TAG_NAME }}
body: "${{ env.PRG_NAME }} ${{ env.PRG_VERSION }} build:${{ env.TAG_BUILD }}"
files: |
${{steps.sign-FairEmail.outputs.signedReleaseFile}}
_tag_name_.txt
- name: Publish version build - signed apk package
if: env.ANDROID_SIGNING_KEY != null
uses: deep-soft/action-gh-release@v2.1
with:
draft: true
tag_name: ${{ env.TAG_NAME }}-${{ env.TAG_VERSION }}${{ env.TAG_BUILD }}
body: "${{ env.PRG_NAME }} ${{ env.PRG_VERSION }} build:${{ env.TAG_BUILD }}"
files: |
${{steps.sign-FairEmail.outputs.signedReleaseFile}}
_tag_name_.txt
- name: Publish unsigned apk package
if: env.ANDROID_SIGNING_KEY == null
uses: deep-soft/action-gh-release@v2.1
with:
draft: true
tag_name: ${{ env.TAG_NAME }}
files: |
./signed-apk/${{ env.PRG_NAME }}-${{ env.PRG_VERSION }}-${{ env.PRG_FLAVOR }}-unsigned.apk
_tag_name_.txt