-
Notifications
You must be signed in to change notification settings - Fork 121
127 lines (106 loc) · 3.63 KB
/
build_foss.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
name: Build FOSS
run-name: foss @ ${{ github.sha }}
on:
workflow_dispatch:
inputs:
version_name:
description: Version name
default: 1.0.0
required: true
version_code:
description: Version code
default: '100000'
required: true
concurrency: ${{ github.ref }}
env:
filename: delta-v${{ inputs.version_name }}-foss
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Export variables
run: |
python -u .github/scripts/resolve_paths.py -p >> $GITHUB_ENV
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 18
- name: Install dependencies
run: |
cd ${{ env.sd }}
sudo pip install -r requirements.txt
- name: Add new icons
run: |
cd ${{ env.sd }}
python -u add_icons_wrapper.py
- name: Change version
run: |
python - << EOF
import re
target = 'app/build.gradle'
regexp_version_code = re.compile('versionCode (\d+)')
regexp_version_name = re.compile('versionName "(\d+\.\d+\.\d+(-beta\d+)?)"')
with open(target, 'r+') as file:
content = file.read()
content = re.sub(regexp_version_code, f'versionCode ${{ inputs.version_code }}', content)
content = re.sub(regexp_version_name, f'versionName "${{ inputs.version_name }}"', content)
file.seek(0)
file.write(content)
file.truncate()
EOF
- name: Set custom icons count
run: |
drawable_xml=app/src/main/res/xml/drawable.xml
drawable_lines=$(grep '<item' $drawable_xml | sort)
summary=$(echo "$drawable_lines" | wc -l)
amount_all=$(echo "$drawable_lines" | uniq | wc -l)
amount_new=$(( $summary - $amount_all ))
shortcut=java/website/leifs/delta/applications/CandyBar.java
sed -i "s|setCustomIconsCount\(.*\);|setCustomIconsCount\($amount_all\);|" app/src/foss/$shortcut
sed -i "s|setCustomIconsCount\(.*\);|setCustomIconsCount\($amount_all\);|" app/src/play/$shortcut
- name: Create changelog
run: |
cat << EOF > app/src/main/res/values/changelog.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="changelog_date"></string>
<string-array name="changelog">
<item><![CDATA[<font color=#ff837d><item>¯\\_(ツ)_/¯</item></font>]]></item>
</string-array>
</resources>
EOF
- name: Sort appfilter and drawable
run: |
cd ${{ env.sd }}
python sort_appfilter.py -o
python sort_drawable.py -o
cp -fv ${{ env.a1 }} ${{ env.a2 }}
cp -fv ${{ env.d1 }} ${{ env.a2 }}
- name: Build APK
run: |
bash gradlew assembleFoss
- name: Move unsigned APK
run: |
mv -v app/build/outputs/apk/foss/release/*.apk .
- name: Sign APK
uses: kevin-david/zipalign-sign-android-release@main
id: sign_step
with:
alias: ${{ secrets.KEYSTORE_KEY_ALIAS }}
keyPassword: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
signingKeyBase64: ${{ secrets.KEYSTORE_BASE64 }}
releaseDirectory: .
- name: Move signed APK
run: |
mv -v ${{ steps.sign_step.outputs.signedReleaseFile }} ${{ env.filename }}.apk
- name: Upload signed APK in Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.filename }}
path: ${{ env.filename }}.apk
retention-days: 90