forked from keke1023/Padavan
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (128 loc) · 4.87 KB
/
new-test.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
name: Build new Padavan Firmware
on:
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: 'no'
release:
types: [published]
jobs:
build:
name: Build Firmware
runs-on: ubuntu-20.04
if: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }}
env:
images_dir: /opt/images
strategy:
matrix:
include:
- build_variant: "mt7621-usb"
targets: "MI-R3P" # 指定编译的机型为 MI-R3P
steps:
- name: Checkout repository
uses: actions/checkout@v2
- id: cache-replacement-files
name: Cache Replacement Files Repository
uses: actions/cache@v3
with:
path: temp/padavan-4.4
key: padavan-4.4-${{ hashFiles('**/padavan-4.4/**/*') }}
restore-keys: |
padavan-4.4-
- name: Clone Padavan-4.4 Repository
if: steps.cache-replacement-files.outputs.cache-hit != 'true'
run: |
git clone https://github.com/ifox6677/padavan-4.4.git temp/padavan-4.4
- name: Replace User Packages
run: |
chmod +x scripts/replace_files.sh
./scripts/replace_files.sh temp/padavan-4.4 ./ # 假设目标目录是仓库根目录
- name: Checkout additional repository (hadzhioglu/padavan-ng)
uses: actions/checkout@v2
with:
repository: hadzhioglu/padavan-ng
path: padavan-ng # 将 padavan-ng 克隆到工作目录的 padavan-ng 文件夹中
- name: Copy toolchain
run: |
# 确保目标目录存在
# mkdir -p ./toolchain-mipsel
# 复制工具链
cp -r ./padavan-ng/toolchain/* ./toolchain-mipsel/
- name: Copy uClibc-ng
run: |
# 确保目标目录存在
#mkdir -p ./trunk/libs
# 复制 uClibc-ng-1.0.50 目录
cp -r ./padavan-ng/trunk/libc/* ./trunk/libc/
- name: Prepare environment
run: |
sudo apt update
sudo apt install -y unzip libtool-bin curl cmake gperf gawk flex bison \
nano xxd fakeroot kmod cpio git python3-docutils gettext automake \
autopoint texinfo build-essential help2man pkg-config zlib1g-dev \
libgmp3-dev libmpc-dev libmpfr-dev libncurses5-dev libltdl-dev \
wget libc-dev-bin squashfs-tools # 添加维护人推荐的依赖项
- name: Install Go
run: |
wget https://golang.org/dl/go1.23.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> $GITHUB_ENV
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Prepare toolchain
run: |
cd ./toolchain-mipsel
sh dl_toolchain.sh
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'yes' }}
with:
limit-access-to-actor: true
- name: Start build
run: |
cd ./trunk # 确保目录正确
mkdir -p ${images_dir}
# 编译每个目标
for m in ${{ matrix.targets }}; do
fakeroot ./build_firmware_ci $m
if [ $? = 0 ]; then
cp -f images/*.trx ${images_dir}/$m.trx
else
exit 1
fi
./clear_tree_simple >/dev/null 2>&1
done
- name: Create archive
if: ${{ github.event_name != 'release' && success() }}
run: |
ls -lh ${images_dir}
GIT_VERSION=$(git rev-parse --short=7 HEAD 2>/dev/null) && [ -n "$GIT_VERSION" ] && \
image_name=images_${{ matrix.build_variant }}_${GIT_VERSION} || image_name=images_${{ matrix.build_variant }}
cd ${images_dir}
md5sum *.trx | tee md5sum.txt
7z a -mx=9 ${image_name}.7z ./*
echo "image_name=${image_name}" >> $GITHUB_ENV
- name: Upload images to Artifact
if: ${{ github.event_name != 'release' && success() }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.image_name }}
path: ${{ env.images_dir }}/*.7z
- name: Upload images to Releases
if: ${{ github.event_name == 'release' && success() }}
uses: svenstaro/upload-release-action@2.2.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.images_dir }}/*.trx
tag: ${{ github.ref }}
overwrite: true
file_glob: true