-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (170 loc) · 7.38 KB
/
Copy pathcheck_firmware.yml
File metadata and controls
202 lines (170 loc) · 7.38 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
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Check OnePlus Open Firmware (IN)
on:
schedule:
# Run daily at 6 AM UTC
- cron: '0 6 * * *'
workflow_dispatch:
# Allow manual trigger
jobs:
extract-and-patch:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Free up disk space
run: |
echo "=== Disk space before cleanup ==="
df -h /
# Remove unnecessary tools to free up space (~25GB)
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force 2>/dev/null || true
echo "=== Disk space after cleanup ==="
df -h /
- name: Check for new firmware
id: check
run: |
# Get firmware info
./download_firmware.py --variant 14 --check-only --json > firmware.json
cat firmware.json
# Extract version info
VERSION=$(jq -r '.version_number' firmware.json)
FILENAME=$(jq -r '.filename' firmware.json)
OTA_VERSION=$(jq -r '.ota_version_number' firmware.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
echo "ota_version=$OTA_VERSION" >> $GITHUB_OUTPUT
# Compare with stored version
if [ -f current_version.txt ]; then
CURRENT=$(cat current_version.txt)
echo "Current version: $CURRENT"
echo "Latest version: $VERSION"
if [ "$VERSION" = "$CURRENT" ]; then
echo "No update available"
echo "need_update=false" >> $GITHUB_OUTPUT
else
echo "New version available!"
echo "need_update=true" >> $GITHUB_OUTPUT
fi
else
echo "No version file found - first run"
echo "need_update=true" >> $GITHUB_OUTPUT
fi
- name: Download firmware
if: steps.check.outputs.need_update == 'true'
run: |
echo "=== Downloading firmware ==="
./download_firmware.py --variant 14 -n 8 --no-clobber
- name: Extract payload.bin
if: steps.check.outputs.need_update == 'true'
run: |
echo "=== Extracting payload.bin from firmware ==="
FIRMWARE_FILE="${{ steps.check.outputs.filename }}"
# Extract only payload.bin from the ZIP
unzip -j "$FIRMWARE_FILE" payload.bin
# Remove the firmware ZIP to free space
rm -f "$FIRMWARE_FILE"
- name: Extract boot partitions
if: steps.check.outputs.need_update == 'true'
run: |
echo "=== Extracting boot partitions from payload.bin ==="
./extract_payload.py payload.bin -p boot init_boot vendor_boot vendor_dlkm vbmeta dtbo -o .
# Remove payload.bin to free space
rm -f payload.bin
- name: Download Magisk
id: magisk
if: steps.check.outputs.need_update == 'true'
run: |
echo "=== Downloading latest Magisk release APK ==="
MAGISK_URL=$(curl -s https://api.github.com/repos/topjohnwu/Magisk/releases/latest \
| jq -r '.assets[] | select(.name | startswith("Magisk-v")) | .browser_download_url')
MAGISK_VERSION=$(curl -s https://api.github.com/repos/topjohnwu/Magisk/releases/latest \
| jq -r '.tag_name')
echo "Downloading Magisk $MAGISK_VERSION from: $MAGISK_URL"
wget -q "$MAGISK_URL" -O magisk.apk
echo "magisk_version=$MAGISK_VERSION" >> $GITHUB_OUTPUT
ls -lh magisk.apk
- name: Patch boot image with Magisk
id: patch
if: steps.check.outputs.need_update == 'true'
run: |
echo "=== Patching init_boot.img with Magisk ==="
./patch_boot.sh init_boot.img magisk.apk
echo "=== Patching complete ==="
ls -lh *.img
- name: Update version file
if: steps.check.outputs.need_update == 'true'
run: |
echo "${{ steps.check.outputs.version }}" > current_version.txt
- name: Commit version update
if: steps.check.outputs.need_update == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add current_version.txt
git diff --staged --quiet || git commit -m "Update firmware version to ${{ steps.check.outputs.version }}"
git push
- name: Create Release
if: steps.check.outputs.need_update == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.check.outputs.version }}
name: OnePlus Open ${{ steps.check.outputs.version }}
body: |
## OnePlus Open Firmware ${{ steps.check.outputs.version }}
**OTA Version:** ${{ steps.check.outputs.ota_version }}
**Magisk Version:** ${{ steps.magisk.outputs.magisk_version }}
### Included files
- `init_boot.img` - Stock init_boot image (for backup/restore)
- `boot.img` - Stock boot image (for backup/restore)
- `vendor_boot.img` - Stock vendor_boot image (vendor ramdisk/modules)
- `vendor_dlkm.img` - Stock vendor_dlkm image (kernel modules)
- `vbmeta.img` - Stock vbmeta image (verified boot metadata)
- `dtbo.img` - Stock dtbo image (device tree overlay)
- `magisk_patched_init_boot.img` - Magisk patched init_boot image
### Flashing instructions
1. **Backup first!** Save your current init_boot partition
2. Boot into fastboot mode: `adb reboot bootloader`
3. Flash patched image:
```
fastboot flash init_boot magisk_patched_init_boot.img
```
4. Reboot: `fastboot reboot`
5. Install Magisk app from [GitHub releases](https://github.com/topjohnwu/Magisk/releases)
### Restore stock
If you need to restore stock partitions:
```
fastboot flash init_boot init_boot.img
fastboot flash boot boot.img
fastboot flash vendor_boot vendor_boot.img
fastboot flash vendor_dlkm vendor_dlkm.img
fastboot flash dtbo dtbo.img
fastboot flash vbmeta vbmeta.img
```
---
*Automatically generated by GitHub Actions*
files: |
init_boot.img
boot.img
vendor_boot.img
vendor_dlkm.img
vbmeta.img
dtbo.img
magisk_patched_init_boot.img
- name: Summary
if: always()
run: |
echo "## Workflow Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check.outputs.need_update }}" == "true" ]; then
echo "- **Status:** New firmware processed" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ steps.check.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **OTA Version:** ${{ steps.check.outputs.ota_version }}" >> $GITHUB_STEP_SUMMARY
else
echo "- **Status:** No update available" >> $GITHUB_STEP_SUMMARY
echo "- **Current Version:** $(cat current_version.txt 2>/dev/null || echo 'N/A')" >> $GITHUB_STEP_SUMMARY
fi