-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (130 loc) · 4.97 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
name: Check firmware update
on:
schedule:
- cron: '0 0 * * *'
push:
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- model: "SM-S911B"
region: "EUX"
- model: "SM-S9160"
region: "TGY"
- model: "SM-S918B"
region: "EUX"
steps:
- name: Checkout repo
uses: actions/checkout@v3
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_modem=`echo $latest | cut -d'/' -f3`
current=`cat current.${{ matrix.model }}` || need_update=1
[[ $latest != $current ]] && need_update=1
echo "latest_version=$latest" >> $GITHUB_ENV
echo "latest_shortversion=$latest_short" >> $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 openssl
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-S911B" ]]; then
imei="352772520002740"
elif [[ "${{ matrix.model }}" == "SM-S9160" ]]; then
imei="355267720345327"
elif [[ "${{ matrix.model }}" == "SM-S918B" ]]; then
imei="354721880318483"
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
- name: Check contents of downloaded firmware
if: env.need_update == 1
run: |
tar tvf ${{ env.ap_tar }}
tar tvf ${{ env.bl_tar }}
tar tvf ${{ env.cp_tar }} || true
- name: Extract kernel images
if: env.need_update == 1
env:
FILES: boot.img.lz4 dtbo.img.lz4 init_boot.img.lz4 vendor_boot.img.lz4 recovery.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: Generate patched vbmeta
if: env.need_update == 1
run: |
tar xvf ${{ env.bl_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: Generate patched fastboot
if: env.need_update == 1
run: |
tar xvf ${{ env.ap_tar }} recovery.img.lz4
lz4 -d recovery.img.lz4 recovery.img
git clone https://github.com/engineer4t/fastboot-patcher.git && mv recovery.img ./fastboot-patcher/ && cd fastboot-patcher && ./patcher-minimal
mv output/output.img ../recovery.img && cd ..
tar cvf ${{ env.latest_shortversion }}_patched_fastboot.tar recovery.img
rm -rf fastboot-patcher *.lz4
- 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 }}
git add current.${{ matrix.model }}
git commit -m "${{ matrix.model }}: ${{ env.latest_version }}"
git tag ${{ env.latest_shortversion }}
- name: Push changes to repo
if: env.need_update == 1
uses: ad-m/github-push-action@master
with:
tags: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release assets
if: env.need_update == 1
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.latest_shortversion }}
files: |
${{ env.bl_tar }}
${{ env.cp_tar }}
${{ env.latest_shortversion }}_kernel.tar
${{ env.latest_shortversion }}_patched_vbmeta.tar
${{ env.latest_shortversion }}_patched_fastboot.tar