forked from Locietta/xanmod-kernel-WSL2
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (122 loc) · 4.94 KB
/
build.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
name: Kernel CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
# manual trigger
schedule:
- cron: '0 6,14,22 * * *'
env:
IS_LTS: NO
jobs:
build:
runs-on: ubuntu-latest
container: locietta/loia-dev-base:latest
outputs:
current_version: ${{ steps.out.outputs.current_version }}
release_version: ${{ steps.out.outputs.release_version }}
clang_version: ${{ steps.out.outputs.clang_version }}
rebuild_flag: ${{ steps.out.outputs.rebuild_flag }}
strategy:
matrix:
include:
- arch: riscv
image-name: vmlinux-riscv64
steps:
- uses: actions/checkout@main
- name: Install dependencies
id: dep
run: |
pacman -Syu --noconfirm pahole xmlto inetutils bc cpio jq llvm llvm-libs clang lld ccache zip unzip
- name: Trust this directory
run: git config --global --add safe.directory '*' # v2.35.3 or later
- name: Initialize ccache
uses: hendrikmuhs/[email protected]
with:
max-size: 2048M
key: ${{ github.job }}-${{ matrix.arch }}
- name: Prepare source code
shell: bash
run: |
export VERSION_BRANCH=v6.11
git clone https://github.com/torvalds/linux -b $VERSION_BRANCH --depth 1 linux
cd linux && ../config.sh
scripts/config -d riscv # avoid override warning for duplicate arch flags
scripts/config -e ${{ matrix.arch }}
# Load version info into env
echo "CLANG_VERSION=$(pacman -Qs clang | grep local/clang | sed 's#^.*local\/clang.*[^0-9]\(.*\) (\(.*\))#\1#')" | tee -a $GITHUB_ENV
export CURRENT_VERSION=$(grep 'LOCALVERSION=' ../riscv_defconfig | sed 's/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/')
# must query with a token, or will fail with api rate limit on public runners
export RELEASED_TAG=$(curl -sL -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}'\
https://api.github.com/repos/ZLangJIT/riscv-kernel/tags\?per_page\=60 | jq -r '.[].name' | grep -v 'lts' | head -n 1)
export RELEASED_VERSION=$(echo $RELEASED_TAG | sed 's/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/' )
export RELEASED_MINOR=$(echo $RELEASED_TAG | sed 's/^.*[^0-9][0-9]*\.\([0-9]*\)\.[0-9]*\.*$/\1/' )
echo "CURRENT_VERSION=$CURRENT_VERSION" | tee -a $GITHUB_ENV
echo "RELEASED_VERSION=$RELEASED_VERSION" | tee -a $GITHUB_ENV
if [[ $CURRENT_VERSION != $RELEASED_VERSION || \
($CURRENT_VERSION = $RELEASED_VERSION && 1 -gt "$RELEASED_MINOR") || \
"${{ github.event_name }}" = 'pull_request' ]]; then
echo "REBUILD_FLAG=1" | tee -a $GITHUB_ENV
else
echo "REBUILD_FLAG=" | tee -a $GITHUB_ENV
fi
- name: Build kernel
if: ${{ env.REBUILD_FLAG }}
run: |
cd linux && ../build.sh
- name: Copy ${{ matrix.image-name }}
if: ${{ env.REBUILD_FLAG }}
run: |
cd linux
mv vmlinux ../${{ matrix.image-name }}
cd ..
sha256sum ${{ matrix.image-name }} > ${{ matrix.image-name }}.sha256
- name: Upload ${{ matrix.image-name }}
uses: actions/upload-artifact@main
if: ${{ env.REBUILD_FLAG }}
with:
name: ${{ matrix.image-name }}
path: |
${{ matrix.image-name }}
${{ matrix.image-name }}.sha256
- id: out
run: |
echo "current_version=${{ env.CURRENT_VERSION }}" >> $GITHUB_OUTPUT
echo "release_version=${{ env.RELEASED_VERSION }}" >> $GITHUB_OUTPUT
echo "clang_version=${{ env.CLANG_VERSION }}" >> $GITHUB_OUTPUT
echo "rebuild_flag=${{ env.REBUILD_FLAG }}" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@main
- uses: actions/download-artifact@main
with:
path: release_images/
- id: fetch_commit_sha
run: |
if [ ${{ github.event_name }} = 'pull_request' ]; then
echo "sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=${{ needs.build.outputs.current_version }}-PR" | tee -a $GITHUB_ENV
else
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=${{ needs.build.outputs.current_version }}" | tee -a $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@master
if: ${{ needs.build.outputs.rebuild_flag }}
with:
name: ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
draft: ${{ github.event_name == 'pull_request' }}
target_commitish: ${{ steps.fetch_commit_sha.outputs.sha }}
body: |
RISC-V linux kernel, built with Clang ${{ needs.build.outputs.clang_version }}
* `vmlinux` for riscv ( built-in busybox ramdisk - initrd.zip )
files: |
release_images/*/*
token: ${{ secrets.GITHUB_TOKEN }}
# generate_release_notes: true
fail_on_unmatched_files: true