Skip to content

Commit 42718ec

Browse files
committed
ci: add release
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
1 parent 639932f commit 42718ec

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Auto Release openRuyi linux patchset & kernelconfig
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
env:
12+
BASELINE_TAG: v6.18
13+
KERNEL_TREM_TOOLS_DIR: kernel-team-tools
14+
KERNEL_DIR: linux
15+
ARTIFACTS_DIR: artifacts
16+
UPSTREAM_GIT: https://github.com/torvalds/linux.git
17+
STABLE_GIT: https://github.com/gregkh/linux.git
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout openRuyi's kernel-team-tools
24+
uses: actions/checkout@v7
25+
with:
26+
path: ${{ env.KERNEL_TREM_TOOLS_DIR }}
27+
28+
- name: Checkout openRuyi's linux
29+
uses: actions/checkout@v7
30+
with:
31+
repository: 'openRuyi-Project/linux'
32+
path: ${{ env.KERNEL_DIR }}
33+
fetch-tags: true
34+
35+
- name: Fetch linux repo partial history
36+
run: |
37+
pushd ${{ env.KERNEL_DIR }}
38+
# Restore part of the history; otherwise, the clone speed is unacceptable.
39+
LINUX_SHA=$(git rev-parse HEAD)
40+
git fetch origin "$LINUX_SHA" --shallow-exclude=${{ env.BASELINE_TAG }}
41+
popd
42+
43+
- name: Generate patchset & config
44+
run: |
45+
pushd ${{ env.KERNEL_DIR }}
46+
find ${{ github.workspace }}/${{ env.KERNEL_TREM_TOOLS_DIR }}/configs -mindepth 1 -maxdepth 1 -type d | while read -r dir; do
47+
kernel_package_name=$(basename "$dir")
48+
mkdir -p ${{ github.workspace }}/${{ env.ARTIFACTS_DIR }}/${kernel_package_name}
49+
50+
while IFS='=' read -r key value; do
51+
key=$(echo "$key" | xargs)
52+
value=$(echo "$value" | xargs)
53+
54+
[[ -z "$key" || "$key" == \#* ]] && continue
55+
export "$key"="$value"
56+
done < ${{ github.workspace }}/${{ env.KERNEL_TREM_TOOLS_DIR }}/configs/${kernel_package_name}/config.env
57+
58+
RUYI_TAG=ruyi/${TAG_NAME}
59+
BASE_VERSION_TAG="${TAG_NAME%-*}"
60+
61+
COMMIT_ID=$(git ls-remote --tags ${STABLE_GIT} ${BASE_VERSION_TAG} | tail -n 1 | awk '{print $1}')
62+
if [ -z "$COMMIT_ID" ]; then
63+
COMMIT_ID=$(git ls-remote --tags ${UPSTREAM_GIT} ${BASE_VERSION_TAG} | tail -n 1 | awk '{print $1}')
64+
fi
65+
66+
if [ -z "$COMMIT_ID" ]; then
67+
echo "$COMMIT_ID is not found."
68+
exit 1
69+
fi
70+
71+
git fetch origin ${RUYI_TAG} --shallow-exclude=${{ env.BASELINE_TAG }}
72+
git clean -xfd
73+
git checkout --progress --force ${RUYI_TAG}
74+
75+
git fetch origin ${COMMIT_ID} --shallow-exclude=${{ env.BASELINE_TAG }}
76+
git format-patch ${COMMIT_ID} --subject-prefix="RUYI PATCH" \
77+
--no-numbered -o ${{ github.workspace }}/${{ env.ARTIFACTS_DIR }}/${kernel_package_name}
78+
pushd ${{ github.workspace }}/${{ env.ARTIFACTS_DIR }}/${kernel_package_name}
79+
ls *.patch > series
80+
popd
81+
82+
annotations_file=${{ github.workspace }}/${{ env.KERNEL_TREM_TOOLS_DIR }}/configs/${kernel_package_name}/annotations
83+
FLAVOURS=$(sed -ne 's/^# FLAVOUR: //p' "${annotations_file}")
84+
for arch_flavour in ${FLAVOURS} ; do
85+
arch=${arch_flavour%%-*}
86+
flavour=${arch_flavour#*-}
87+
python3 ${{ github.workspace }}/${{ env.KERNEL_TREM_TOOLS_DIR }}/annotations/annotations \
88+
-f "${annotations_file}" \
89+
--arch "${arch}" --flavour "${flavour}" \
90+
-e > ${{ github.workspace }}/${{ env.ARTIFACTS_DIR }}/${kernel_package_name}/config.${arch_flavour}
91+
done
92+
93+
# summary
94+
ls -al ${{ github.workspace }}/${{ env.ARTIFACTS_DIR }}/${kernel_package_name}/
95+
tar -czvf ${{ env.ARTIFACTS_DIR }}/${kernel_package_name}-${TAG_NAME}.tar.gz \
96+
-C ${{ github.workspace }}/${{ env.ARTIFACTS_DIR }}/"${kernel_package_name}" .
97+
done
98+
99+
# summary
100+
ls -al ${{ github.workspace }}/
101+
popd

0 commit comments

Comments
 (0)