forked from ylx2016/kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (113 loc) · 5.47 KB
/
Centos_kernel_latest_bbrplus.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
# 不维护了
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# Description: Build Kernel using GitHub Actions
# Change from P3TERX
#
name: Centos Kernel Latest BBRPLUS
on:
workflow_dispatch:
#schedule:
#- cron: "39 20 * * 2,4"
# inputs:
# ssh:
# description: 'SSH connection to Actions'
# required: false
# default: 'false'
env:
UPLOAD_DIR: false
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
container: docker.io/centos:7
steps:
- name: Checkout
uses: actions/checkout@v2
- name: intall deps
run: |
yum update -y
yum install epel-release -y && yum install ansible -y && yum install openssh-clients -y
yum install -y wget tar gcc automake autoconf libtool make zip unzip centos-release-scl scl-utils bzip2 wget curl jq htop sudo time patch
yum groups install development -y
yum install gcc bc ncurses-devel openssl-devel elfutils-libelf-devel rsync glibc-static tmux -y
yum -y install devtoolset-9 devtoolset-9-libatomic-devel
mkdir /github/home/.ssh/ && mkdir /workdir
- name: Check for updates
id: check
run: |
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}')
echo "github_ver=" $github_ver
echo "kernel_ver=" $kernel_ver
if [[ $github_ver == *"$kernel_ver"* ]]; then
echo "::set-output name=status::fail"
else
echo "::set-output name=status::success"
fi
- name: Get source code
id: code
if: steps.check.outputs.status == 'success'
working-directory: /workdir
run: |
df -hT $PWD
kernel_file=$(curl -s https://www.kernel.org/ | grep 'alt="Download"' | awk -F '"' '{print $2}')
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}')
wget -O kernel.tar.xz $kernel_file
tar -Jxvf kernel.tar.xz -C /workdir && cd /workdir/linux-$kernel_ver
echo "::set-output name=status::success"
- name: SSH connection to Actions
uses: P3TERX/[email protected]
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: Compile the kernel
id: compile
if: steps.code.outputs.status == 'success'
working-directory: /workdir
run: |
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}')
cd linux-$kernel_ver
wget -O 5.13_bbrplus.patch https://raw.githubusercontent.com/ylx2016/kernel/master/convert_official_linux-5.13.x_src_to_bbrplus.patch
patch -p0 < 5.13_bbrplus.patch
wget -O .config https://raw.githubusercontent.com/ylx2016/kernel/master/config-5.10.27-bbrplus
sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' .config && scripts/config --disable MODULE_SIG && scripts/config --disable DEBUG_INFO
echo -e "$(nproc) thread compile"
ln -s /opt/rh/devtoolset-9/root/usr/bin/* /usr/local/bin/
sudo time make -j$(nproc) rpm-pkg
mv /root/rpmbuild/RPMS/* /workdir/upload
echo "::set-output name=status::success"
echo "FILE_DATE=Kernel_Centos_$kernel_ver_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
- name: Check space usage
if: (!cancelled()) && steps.compile.outputs.status == 'success'
run: df -hT
- name: Upload
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && env.UPLOAD_DIR == 'true'
with:
name: ${{ env.FILE_DATE }}
path: /workdir/upload
- name: Generate release tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && steps.compile.outputs.status == 'success' && !cancelled()
run: |
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}')
echo "::set-output name=release_tag::Centos_Kernel_${kernel_ver}_latest_bbrplus_$(date +"%Y.%m.%d-%H%M")"
touch release.txt
echo "only for Cloud VMs" >> release.txt
echo "for centos 7" >> release.txt
echo "::set-output name=status::success"
- name: Upload kernel to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
#GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: /workdir/upload/*