This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
202 lines (183 loc) · 7.15 KB
/
check.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
name: Check firmware update
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * *"
push:
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# BRI OMC (A52SXQ_CHN_TW)
- model: "SM-A528B"
region: "BRI"
# ODM OMC
- model: "SM-A528B"
region: "INS"
# OJM OMC
- model: "SM-A528B"
region: "EGY"
# OKR OMC
- model: "SM-A528N"
region: "KOO"
# OLE OMC
- model: "SM-A528B"
region: "XID"
# OLM OMC
- model: "SM-A528B"
region: "XSA"
# OWA OMC
- model: "SM-A528B"
region: "CDR"
# OWM OMC
- model: "SM-A528B"
region: "TGP"
# OWO OMC
- model: "SM-A528B"
region: "PEO"
# OXM OMC
- model: "SM-A528B"
region: "BTU"
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: true
- name: Compare latest version with current version
run: |
need_update=0
latest=`curl --retry 5 --retry-delay 5 http://fota-cloud-dn.ospserver.net/firmware/${{ matrix.region }}/${{ matrix.model }}/version.xml | grep latest | sed 's/^[^>]*>//' | sed 's/<.*//'`
latest_short=`echo $latest | cut -d'/' -f1`
latest_csc=`echo $latest | cut -d'/' -f2`
latest_modem=`echo $latest | cut -d'/' -f3`
current=`cat current.${{ matrix.model }}_${{ matrix.region }}` || need_update=1
[[ $latest != $current ]] && need_update=1
echo "latest_version=$latest" >> $GITHUB_ENV
echo "latest_shortversion=$latest_short" >> $GITHUB_ENV
echo "latest_cscversion=$latest_csc" >> $GITHUB_ENV
echo "latest_modemversion=$latest_modem" >> $GITHUB_ENV
echo "need_update=$need_update" >> $GITHUB_ENV
- name: Set up Node.js
if: env.need_update == 1
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Set up Python 3
if: env.need_update == 1
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
if: env.need_update == 1
run: |
sudo apt-get update
sudo apt-get install -y liblz4-tool zip simg2img f2fs-tools
sudo wget -O /usr/bin/samfirm https://github.com/DavidArsene/samfirm.js/releases/download/v0.3.0/samfirm.js && sudo chmod +x /usr/bin/samfirm
- name: Fetch firmware
if: env.need_update == 1
run: |
if [[ "${{ matrix.model }}" == "SM-A528N" ]]; then
imei="354049881234560"
else
imei="352599501234566"
fi
samfirm -m ${{ matrix.model }} -r ${{ matrix.region }} -i $imei
- name: Get path of files
if: env.need_update == 1
run: |
echo "ap_tar=`find -name AP*`" >> $GITHUB_ENV
echo "bl_tar=`find -name BL*`" >> $GITHUB_ENV
echo "cp_tar=`find -name CP*`" >> $GITHUB_ENV
echo "csc_tar=`find -name CSC*`" >> $GITHUB_ENV
echo "home_csc_tar=`find -name HOME_CSC*`" >> $GITHUB_ENV
- name: Check downloaded firmware version
if: env.need_update == 1
run: |
version_short=`echo ${{ env.ap_tar }} | cut -d'_' -f3`
version_csc=`echo ${{ env.csc_tar }} | cut -d'_' -f4`
version_modem=`echo ${{ env.cp_tar }} | cut -d'_' -f3`
[[ $version_short == ${{ env.latest_shortversion }} ]]
[[ $version_csc == ${{ env.latest_cscversion }} ]]
[[ $version_modem == ${{ env.latest_modemversion }} ]]
echo PDA version: $version_short > versions.txt
echo CSC version: $version_csc >> versions.txt
echo Modem version: $version_modem >> versions.txt
- name: Cleanup space
if: env.need_update == 1
run: |
sudo apt-get remove --purge -y "php*" "dotnet*" "mysql*" "nodejs*" "clang*" "google*"
sudo apt-get autoremove -y
sudo apt-get clean
sudo rm -rf /usr/local
- name: Extract kernel images
if: env.need_update == 1
env:
FILES: boot.img.lz4 dtbo.img.lz4 vbmeta.img.lz4 vendor_boot.img.lz4
run: |
for file in $FILES; do tar xvf ${{ env.ap_tar }} ${file}; done
tar cvf ${{ env.latest_shortversion }}_kernel.tar *.lz4
rm *.lz4
- name: Extract PIT file
if: env.need_update == 1
run: |
tar --wildcards --exclude='*/*' -xvf ${{ env.csc_tar }} '*.pit'
echo "pit_file=`find -name *.pit`" >> $GITHUB_ENV
- name: Generate patched vbmeta
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} vbmeta.img.lz4
lz4 -d vbmeta.img.lz4 vbmeta.img
rm vbmeta.img.lz4
printf "$(printf '\\x%02X' 3)" | dd of="vbmeta.img" bs=1 seek=123 count=1 conv=notrunc &> /dev/null
tar cvf ${{ env.latest_shortversion }}_patched_vbmeta.tar vbmeta.img
rm vbmeta.img
- name: Extract vendor partition
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} super.img.lz4
lz4 -d super.img.lz4 super.img
rm super.img.lz4
simg2img super.img super_raw.img
rm super.img
mv super_raw.img super.img
python3 tools/bin/lpunpack.py -p vendor super.img .
rm super.img
[[ -e vendor.img.ext4 ]] && mv vendor.img.ext4 vendor.img
[[ -e vendor.img ]] && zip ${{ env.latest_shortversion }}_vendor.zip vendor.img
[[ -e vendor.img ]] && rm vendor.img
- name: Update current version
if: env.need_update == 1
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git pull origin ${{github.ref}} --ff-only
echo ${{ env.latest_version }} > current.${{ matrix.model }}_${{ matrix.region }}
git add current.${{ matrix.model }}_${{ matrix.region }}
git commit -m "${{ matrix.model }}: ${{ env.latest_version }}"
git tag "${{ env.latest_shortversion }}_${{ matrix.region }}"
- name: Push changes to repo
if: env.need_update == 1
uses: ad-m/github-push-action@master
with:
tags: true
github_token: ${{ secrets.TOKEN }}
- name: Upload release assets
if: env.need_update == 1
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
body_path: versions.txt
tag_name: "${{ env.latest_shortversion }}_${{ matrix.region }}"
name: "${{ env.latest_shortversion }} - ${{ matrix.model }} - ${{ matrix.region }}"
files: |
${{ env.bl_tar }}
${{ env.cp_tar }}
${{ env.home_csc_tar }}
${{ env.latest_shortversion }}_kernel.tar
${{ env.pit_file }}
${{ env.latest_shortversion }}_patched_vbmeta.tar
${{ env.latest_shortversion }}_vendor.zip