forked from linux-surface/linux-surface
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (185 loc) · 8.23 KB
/
rebase-kernel.yml
File metadata and controls
208 lines (185 loc) · 8.23 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
name: Rebase and Build Kernel
on:
# Manual trigger with inputs
workflow_dispatch:
inputs:
branch:
description: 'Kernel branch to rebase (e.g., "v6.18-surface")'
required: true
type: string
target_tag:
description: 'Target version tag (optional, e.g., "v6.18.5"). If not specified, auto-detected.'
required: false
type: string
build:
description: 'Build kernel to validate rebase'
required: false
type: boolean
default: true
dry_run:
description: 'Dry run mode - skip push and tag operations'
required: false
type: boolean
default: false
# Prevent concurrent rebases of the same branch
concurrency:
group: rebase-kernel-${{ inputs.branch }}
cancel-in-progress: false
jobs:
rebase-and-build:
name: Rebase and build ${{ inputs.branch }}
runs-on: ubuntu-latest
steps:
- name: Maximize disk space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 10240 # Reserve 10GB for build
remove-dotnet: true
remove-android: true
remove-docker-images: true
remove-haskell: true
- name: Checkout linux-surface repo
uses: actions/checkout@v6
with:
path: linux-surface
- name: Checkout kernel repository
uses: actions/checkout@v6
with:
repository: linux-surface/kernel
path: kernel
ref: ${{ inputs.branch }}
fetch-depth: 0
token: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
bc \
bison \
flex \
libelf-dev \
libssl-dev \
libncurses-dev \
kmod \
cpio
- name: Setup git identity
run: |
git config --global user.name "surfacebot"
git config --global user.email "surfacebot@users.noreply.github.com"
- name: Rebase kernel
id: rebase
env:
TARGET_TAG: ${{ inputs.target_tag }}
working-directory: kernel
run: |
bash "${GITHUB_WORKSPACE}/linux-surface/.github/scripts/autoupdate/rebase-kernel.sh"
- name: Build kernel
id: build
if: steps.rebase.outputs.success == 'true' && steps.rebase.outputs.already_uptodate != 'true' && inputs.build == true
env:
KERNEL_VERSION: ${{ steps.rebase.outputs.kernel_version }}
LINUX_SURFACE_DIR: ${{ github.workspace }}/linux-surface
working-directory: kernel
run: |
bash "${GITHUB_WORKSPACE}/linux-surface/.github/scripts/autoupdate/build-kernel.sh"
- name: Create tag
id: create_tag
if: steps.rebase.outputs.success == 'true' && steps.rebase.outputs.already_uptodate != 'true' && (inputs.build == false || steps.build.outputs.build_success == 'true') && inputs.dry_run == false
env:
FULL_VERSION: ${{ steps.rebase.outputs.full_version }}
working-directory: kernel
run: |
SURFACE_TAG="surface/v${FULL_VERSION}"
echo "Creating tag: ${SURFACE_TAG}"
git tag "${SURFACE_TAG}"
echo "surface_tag=${SURFACE_TAG}" >> "${GITHUB_OUTPUT}"
- name: Push changes
if: steps.rebase.outputs.success == 'true' && steps.rebase.outputs.already_uptodate != 'true' && (inputs.build == false || steps.build.outputs.build_success == 'true') && inputs.dry_run == false
env:
KERNEL_BRANCH: ${{ inputs.branch }}
SURFACE_TAG: ${{ steps.create_tag.outputs.surface_tag }}
working-directory: kernel
run: |
echo "Force-pushing branch ${KERNEL_BRANCH}..."
git push --force-with-lease origin "${KERNEL_BRANCH}"
echo "Pushing tag ${SURFACE_TAG}..."
git push origin "${SURFACE_TAG}"
echo "Pushing new upstream tags..."
git push origin "refs/tags/v*"
- name: Upload kernel config artifact
if: steps.build.outputs.build_success == 'true'
uses: actions/upload-artifact@v7
with:
name: kernel-config-${{ inputs.branch }}-${{ steps.rebase.outputs.target_tag }}
path: kernel/.config
retention-days: 30
- name: Trigger patch generation
if: steps.rebase.outputs.success == 'true' && steps.rebase.outputs.already_uptodate != 'true' && (inputs.build == false || steps.build.outputs.build_success == 'true') && inputs.dry_run == false
env:
GH_TOKEN: ${{ secrets.LINUX_SURFACE_BOT_TOKEN }}
KERNEL_BRANCH: ${{ inputs.branch }}
TARGET_TAG: ${{ steps.rebase.outputs.target_tag }}
run: |
echo "Triggering patch generation for ${KERNEL_BRANCH}..."
gh workflow run generate-patches.yml \
--repo ${{ github.repository }} \
--field branch="${KERNEL_BRANCH}" \
--field base_version="${TARGET_TAG}"
echo "✓ Patch generation workflow triggered"
- name: Generate summary
if: always()
env:
REBASE_SUCCESS: ${{ steps.rebase.outputs.success }}
ALREADY_UPTODATE: ${{ steps.rebase.outputs.already_uptodate }}
BUILD_ENABLED: ${{ inputs.build }}
BUILD_SUCCESS: ${{ steps.build.outputs.build_success }}
KERNEL_BRANCH: ${{ inputs.branch }}
TARGET_TAG: ${{ steps.rebase.outputs.target_tag }}
FULL_VERSION: ${{ steps.rebase.outputs.full_version }}
DRY_RUN: ${{ inputs.dry_run }}
run: |
echo "## Kernel Rebase and Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${REBASE_SUCCESS}" = "true" ]; then
if [ "${ALREADY_UPTODATE}" = "true" ]; then
echo "✅ **Status:** Already up-to-date" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Branch \`${KERNEL_BRANCH}\` already contains target tag \`${TARGET_TAG}\`" >> $GITHUB_STEP_SUMMARY
echo "No rebase was necessary." >> $GITHUB_STEP_SUMMARY
elif [ "${BUILD_ENABLED}" = "false" ] || [ "${BUILD_SUCCESS}" = "true" ]; then
echo "✅ **Status:** Success" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** \`${KERNEL_BRANCH}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Target tag:** \`${TARGET_TAG}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Full version:** \`${FULL_VERSION}\`" >> $GITHUB_STEP_SUMMARY
if [ "${BUILD_ENABLED}" = "false" ]; then
echo "- **Build:** Skipped" >> $GITHUB_STEP_SUMMARY
else
echo "- **Build:** Passed" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${DRY_RUN}" = "true" ]; then
echo "⚠️ **Dry run mode** - Changes were not pushed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "To push the changes, run again with dry_run=false" >> $GITHUB_STEP_SUMMARY
else
echo "✅ Changes pushed successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Automatic Patch Generation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Patch generation workflow has been automatically triggered." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check the [Generate Kernel Patches workflow runs](../../actions/workflows/generate-patches.yml) for progress." >> $GITHUB_STEP_SUMMARY
fi
else
echo "❌ **Status:** Build failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Rebase succeeded but kernel build failed." >> $GITHUB_STEP_SUMMARY
echo "Check the build logs for errors." >> $GITHUB_STEP_SUMMARY
fi
else
echo "❌ **Status:** Rebase failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check the rebase logs for conflict details." >> $GITHUB_STEP_SUMMARY
fi