-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathaction.yml
More file actions
312 lines (294 loc) · 14.5 KB
/
action.yml
File metadata and controls
312 lines (294 loc) · 14.5 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: "Rebuild Armbian and Kernel"
author: "https://github.com/ophub/amlogic-s9xxx-armbian"
description: "Support Amlogic, Rockchip and Allwinner boxes."
inputs:
# Select build target
build_target:
description: "Select build target: armbian / kernel"
required: false
default: "armbian"
# For build armbian -----
armbian_path:
description: "Set Armbian file path."
required: false
default: "build/output/images/*.img"
armbian_board:
description: "Set device Board."
required: false
default: "all"
kernel_repo:
description: "Set kernel repository."
required: false
default: "ophub/kernel"
kernel_usage:
description: "Set the tags of the stable kernel."
required: false
default: "stable"
armbian_kernel:
description: "Set kernel version."
required: false
default: "6.1.y_6.12.y"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
armbian_fstype:
description: "Set armbian rootfs type: ext4 / btrfs"
required: false
default: "ext4"
armbian_size:
description: "Set armbian rootfs size(Unit: MiB)."
required: false
default: ""
armbian_files:
description: "Add custom Armbian files."
required: false
default: ""
builder_name:
description: "Set Armbian builder signature."
required: false
default: ""
# For compile kernel -----
kernel_source:
description: "Select the kernel source code"
required: false
default: "unifreq"
kernel_version:
description: "Select kernel version"
required: false
default: "6.1.y_6.12.y"
kernel_auto:
description: "Auto use the latest kernel"
required: false
default: "true"
kernel_package:
description: "Select compile package list"
required: false
default: "all"
kernel_sign:
description: "Set the kernel custom signature"
required: false
default: "-ophub"
kernel_toolchain:
description: "Select the compilation toolchain"
required: false
default: "clang"
config_flavor:
description: "Set the kernel config flavor"
required: false
default: ""
kernel_config:
description: "Set the path of kernel .config"
required: false
default: "false"
kernel_patch:
description: "Set the directory for kernel patches"
required: false
default: "false"
auto_patch:
description: "Set whether to use kernel patches"
required: false
default: "false"
compress_format:
description: "Set the initrd compression format"
required: false
default: "xz"
delete_source:
description: "Set whether to delete the kernel source"
required: false
default: "false"
silent_log:
description: "Set whether to use silent log output"
required: false
default: "false"
enable_log:
description: "Set whether to output logs to a file"
required: false
default: "false"
ccache_clear:
description: "Set whether to clear the cache"
required: false
default: "false"
docker_hostpath:
description: "Set Docker working directory"
required: false
default: ""
docker_image:
description: "Select Armbian docker image"
required: false
default: ""
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${{ github.action_path }}
echo -e "Current running path: [ ${PWD} ]"
build_target="${{ inputs.build_target }}"
[[ -z "${build_target}" ]] && build_target="armbian"
if [[ "${build_target}" == "armbian" ]]; then
cd ${{ github.action_path }}
echo -e "Starting Armbian rebuild..."
armbian_file="${{ inputs.armbian_path }}"
armbian_filename="${armbian_file##*/}"
armbian_filepath="build/output/images"
echo -e "Armbian file input parameters: [ ${armbian_file} ]"
[[ -z "${armbian_file}" ]] && echo -e "The [ armbian_path ] variable must be specified." && exit 1
[[ -d "${armbian_filepath}" ]] || mkdir -p ${armbian_filepath}
if [[ "${armbian_file}" =~ ^http ]]; then
echo -e "Downloading file: [ ${armbian_file} ]"
curl -fsSL "${armbian_file}" -o "${armbian_filepath}/${armbian_filename}"
else
if [[ -z "$(ls ${armbian_filepath}/${armbian_filename} 2>/dev/null)" ]]; then
echo -e "Copying files: [ ${armbian_file} ]"
if [[ "${armbian_file}" =~ ^/ ]]; then
cp -vf ${armbian_file} -t ${armbian_filepath}/ || true
else
cp -vf ${{ github.workspace }}/${armbian_file} -t ${armbian_filepath}/ || true
fi
else
echo -e "File [ ${armbian_filepath}/${armbian_filename} ] already exists, skipping."
fi
fi
sync
echo -e "Contents of [ ${armbian_filepath} ] directory: \n$(ls -lh ${armbian_filepath} 2>/dev/null)"
cd ${armbian_filepath}
echo -e "Checking the Armbian file format..."
down_file="$(ls -l *.img* 2>/dev/null | grep "^-" | awk '{print $9}' | sort -u | head -n 1)"
if [[ -n "${down_file}" ]]; then
echo -e "Selected Armbian file: [ ${down_file} ]"
else
echo -e "The Armbian file is invalid!"
exit 1
fi
[[ "${down_file:0-7}" == ".img.gz" ]] && gzip -df ${down_file} 2>/dev/null && sync
[[ "${down_file:0-7}" == ".img.xz" ]] && xz -d ${down_file} 2>/dev/null && sync
[[ "${down_file:0-4}" == ".zip" ]] && unzip -o ${down_file} 2>/dev/null && sync
echo -e "Armbian file: \n$(ls -lh *.img 2>/dev/null)"
echo -e "Checking the Armbian filename (-trunk_)..."
image_file="$(ls *.img 2>/dev/null | head -n 1)"
if [[ "${image_file}" =~ "-trunk_" ]]; then
echo -e "The Armbian filename is correct."
else
echo -e "Modifying Armbian filename..."
# Get image version, such as 25.11.0
image_version="$(echo ${image_file} | grep -oE '[0-9]{2}\.[0-9]{1,2}\.[0-9]{1,2}' | head -n 1)"
# Get image kernel version, such as 6.12.56
image_kernel="$(echo ${image_file} | grep -oE '[0-9]+\.[0-9]{1,2}\.[0-9]{1,3}' | grep -v "${image_version}" | head -n 1)"
# Get image codename, such as trixie
image_codename="$(echo ${image_file} | grep -oE "(trixie|bookworm|bullseye|resolute|noble|jammy)" || echo '')"
# Rename armbian image file
image_save_name="Armbian_${image_version}-trunk_${image_codename}_arm64_${image_kernel}.img"
rm -f ${image_save_name}
mv -f ${image_file} ${image_save_name}
echo -e "Renamed Armbian file: [ ${image_save_name} ]"
fi
# Custom Armbian rebuild files
if [[ -n "${{ inputs.armbian_files }}" && "${{ inputs.armbian_files }}" != "false" ]]; then
echo -e "Adding custom Armbian rebuild files..."
copy_from_path="${{ inputs.armbian_files }}"
copy_from_path="${copy_from_path%/}"
[[ "${copy_from_path}" != /* ]] && copy_from_path="${{ github.workspace }}/${copy_from_path}"
copy_to_path="build-armbian/armbian-files/common-files"
cp -avf --no-preserve=ownership "${copy_from_path}/." -t "${copy_to_path}/" || true
else
echo -e "Using the default Armbian rebuild files."
fi
cd ${{ github.action_path }}
echo -e "Starting to rebuild Armbian..."
make_command=""
[[ -n "${{ inputs.armbian_board }}" ]] && make_command="${make_command} -b ${{ inputs.armbian_board }}"
[[ -n "${{ inputs.kernel_repo }}" ]] && make_command="${make_command} -r ${{ inputs.kernel_repo }}"
[[ -n "${{ inputs.kernel_usage }}" ]] && make_command="${make_command} -u ${{ inputs.kernel_usage }}"
[[ -n "${{ inputs.armbian_kernel }}" ]] && make_command="${make_command} -k ${{ inputs.armbian_kernel }}"
[[ -n "${{ inputs.auto_kernel }}" ]] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[[ -n "${{ inputs.armbian_fstype }}" ]] && make_command="${make_command} -t ${{ inputs.armbian_fstype }}"
[[ -n "${{ inputs.armbian_size }}" ]] && make_command="${make_command} -s ${{ inputs.armbian_size }}"
[[ -n "${{ inputs.builder_name }}" ]] && make_command="${make_command} -n ${{ inputs.builder_name }}"
read -r -a make_args <<< "${make_command}"
sudo ./rebuild "${make_args[@]}"
cd ${{ github.action_path }}/${armbian_filepath}
# Compress Armbian image file
pigz -qf *.img || gzip -qf *.img
sync && sleep 3
cd ${{ github.action_path }}
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTPATH=${PWD}/${armbian_filepath}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTDATE=$(date +"%m.%d.%H%M")" >> ${GITHUB_ENV}
echo "PACKAGED_STATUS=success" >> ${GITHUB_ENV}
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${armbian_filepath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list: \n$(ls -lh ${PWD}/${armbian_filepath}/ 2>/dev/null)"
elif [[ "${build_target}" == "kernel" ]]; then
cd ${{ github.action_path }}
echo -e "Starting kernel compilation..."
# Custom kernel config files
config_filepath="compile-kernel/tools/config"
[[ -d "${config_filepath}" ]] || mkdir -p ${config_filepath}
if [[ -n "${{ inputs.kernel_config }}" && "${{ inputs.kernel_config }}" != "false" ]]; then
if [[ "$(ls ${{ github.workspace }}/${{ inputs.kernel_config }}/config-* -l 2>/dev/null | grep "^-" | wc -l)" -ne "0" ]]; then
echo -e "Using a custom kernel compilation template..."
rm -f ${config_filepath}/* 2>/dev/null && sync
cp -vrf "${{ github.workspace }}/${{ inputs.kernel_config }}/." -t "${config_filepath}/" || true
echo -e "List of Kernel Custom Compilation Configuration Templates: \n$(ls -lh ${config_filepath} 2>/dev/null)"
else
echo -e "The custom kernel compilation template path is invalid. Using the default template."
fi
else
echo -e "Using the default kernel compilation template."
fi
# Custom kernel patch files
custom_kernel_patch="compile-kernel/tools/patch"
[[ -d "${custom_kernel_patch}" ]] || mkdir -p ${custom_kernel_patch}
if [[ -n "${{ inputs.kernel_patch }}" && "${{ inputs.kernel_patch }}" != "false" ]]; then
if [[ -d "${{ github.workspace }}/${{ inputs.kernel_patch }}" ]]; then
echo -e "Using custom kernel patches..."
rm -rf ${custom_kernel_patch}/* 2>/dev/null && sync
cp -vrf "${{ github.workspace }}/${{ inputs.kernel_patch }}/." -t "${custom_kernel_patch}/" || true
echo -e "Directory of custom kernel patches: \n$(ls -lh ${custom_kernel_patch} 2>/dev/null)"
else
echo -e "Invalid custom kernel patch directory. Skipping."
fi
else
echo -e "No custom kernel patches provided."
fi
echo -e "Building kernel compilation command."
make_command=""
[[ -n "${{ inputs.kernel_source }}" ]] && make_command="${make_command} -r ${{ inputs.kernel_source }}"
[[ -n "${{ inputs.kernel_version }}" ]] && make_command="${make_command} -k ${{ inputs.kernel_version }}"
[[ -n "${{ inputs.kernel_auto }}" ]] && make_command="${make_command} -a ${{ inputs.kernel_auto }}"
[[ -n "${{ inputs.kernel_package }}" ]] && make_command="${make_command} -m ${{ inputs.kernel_package }}"
[[ -n "${{ inputs.auto_patch }}" ]] && make_command="${make_command} -p ${{ inputs.auto_patch }}"
[[ -n "${{ inputs.kernel_sign }}" ]] && make_command="${make_command} -n ${{ inputs.kernel_sign }}"
[[ -n "${{ inputs.kernel_toolchain }}" ]] && make_command="${make_command} -t ${{ inputs.kernel_toolchain }}"
[[ -n "${{ inputs.compress_format }}" ]] && make_command="${make_command} -z ${{ inputs.compress_format }}"
[[ -n "${{ inputs.delete_source }}" ]] && make_command="${make_command} -d ${{ inputs.delete_source }}"
[[ -n "${{ inputs.silent_log }}" ]] && make_command="${make_command} -s ${{ inputs.silent_log }}"
[[ -n "${{ inputs.ccache_clear }}" ]] && make_command="${make_command} -c ${{ inputs.ccache_clear }}"
[[ -n "${{ inputs.config_flavor }}" ]] && make_command="${make_command} -f ${{ inputs.config_flavor }}"
[[ -n "${{ inputs.enable_log }}" ]] && make_command="${make_command} -l ${{ inputs.enable_log }}"
[[ -n "${{ inputs.docker_hostpath }}" ]] && make_command="${make_command} -h ${{ inputs.docker_hostpath }}"
[[ -n "${{ inputs.docker_image }}" ]] && make_command="${make_command} -i ${{ inputs.docker_image }}"
read -r -a make_args <<< "${make_command}"
sudo ./recompile "${make_args[@]}"
cd ${{ inputs.docker_hostpath }}
kernel_outpath="compile-kernel/output"
output_tags="$(ls -l ${kernel_outpath}/*.tar.gz 2>/dev/null | awk '{print $9}' | grep -oP '\d+\.\d+\.\d+' | sort -u | xargs | tr "[ ]" "_")"
echo -e "Setting output environment variables."
echo "PACKAGED_OUTPUTTAGS=${output_tags}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTPATH=${PWD}/${kernel_outpath}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTDATE=$(date +"%m.%d.%H%M")" >> ${GITHUB_ENV}
echo "PACKAGED_STATUS=success" >> ${GITHUB_ENV}
echo -e "PACKAGED_OUTPUTTAGS: ${output_tags}"
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${kernel_outpath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list: \n$(ls -lh ${PWD}/${kernel_outpath}/ 2>/dev/null)"
else
echo -e "Please select a build target: armbian / kernel"
exit 1
fi
branding:
icon: "terminal"
color: "gray-dark"