Skip to content

Commit b0ff3f6

Browse files
logically fix
1 parent 775c73a commit b0ff3f6

1 file changed

Lines changed: 75 additions & 54 deletions

File tree

.github/workflows/build.yml

Lines changed: 75 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,63 +18,74 @@ jobs:
1818
EXTRA: ${{ steps.parse-config.outputs.EXTRA }}
1919
LOCAL: ${{ steps.parse-config.outputs.LOCAL }}
2020
TAG: ${{ steps.parse-config.outputs.TAG }}
21+
# FIX 2: expose the correctly assembled full kernel version (e.g. "6.14" or "6.14.2")
22+
FULL_VERSION: ${{ steps.parse-config.outputs.FULL_VERSION }}
23+
2124
steps:
2225
- uses: actions/checkout@v4
2326

2427
- name: Validate and parse hyperion.config
2528
id: parse-config
2629
run: |
2730
python3 - << 'EOF'
28-
import sys
31+
import sys, os
2932
3033
config = {}
3134
with open('hyperion.config') as f:
3235
for line in f:
33-
line=line.strip()
36+
line = line.strip()
3437
if not line or line.startswith('#'): continue
3538
if '=' not in line:
3639
print(f"Invalid line: {line}")
3740
sys.exit(1)
38-
k,v = line.split('=',1)
41+
k, v = line.split('=', 1)
3942
config[k.strip()] = v.strip().strip('"')
4043
4144
def parse_int(k, d=0):
42-
val = config.get(k,'')
43-
if val=='': return d
45+
val = config.get(k, '')
46+
if val == '': return d
4447
try:
45-
iv = int(val)
46-
return iv
48+
return int(val)
4749
except ValueError:
4850
print(f"Invalid {k}: {val}"); sys.exit(1)
4951
5052
VERSION = parse_int('CONFIG_VERSION')
51-
PATCH = parse_int('CONFIG_PATCHLEVEL')
52-
SUB = parse_int('CONFIG_SUBLEVEL')
53-
EXTRA = config.get('CONFIG_EXTRAVERSION','') or ''
54-
LOCAL = config.get('CONFIG_LOCALVERSION','') or ''
53+
PATCH = parse_int('CONFIG_PATCHLEVEL')
54+
SUB = parse_int('CONFIG_SUBLEVEL')
55+
EXTRA = config.get('CONFIG_EXTRAVERSION', '') or ''
56+
LOCAL = config.get('CONFIG_LOCALVERSION', '') or ''
57+
58+
# FIX 2: kernel.org omits ".0" sublevel in the tarball name
59+
FULL_VERSION = f"{VERSION}.{PATCH}" if SUB == 0 else f"{VERSION}.{PATCH}.{SUB}"
5560
5661
tag_suffix = LOCAL.split('-Hyperion-')[-1] if '-Hyperion-' in LOCAL else LOCAL
5762
TAG = f"v{VERSION}.{PATCH}.{SUB}{tag_suffix}"
5863
59-
print(f"::set-output name=VERSION::{VERSION}")
60-
print(f"::set-output name=PATCH::{PATCH}")
61-
print(f"::set-output name=SUB::{SUB}")
62-
print(f"::set-output name=EXTRA::{EXTRA}")
63-
print(f"::set-output name=LOCAL::{LOCAL}")
64-
print(f"::set-output name=TAG::{TAG}")
64+
# FIX 1: use $GITHUB_OUTPUT instead of deprecated ::set-output
65+
out = os.environ['GITHUB_OUTPUT']
66+
with open(out, 'a') as f:
67+
f.write(f"VERSION={VERSION}\n")
68+
f.write(f"PATCH={PATCH}\n")
69+
f.write(f"SUB={SUB}\n")
70+
f.write(f"EXTRA={EXTRA}\n")
71+
f.write(f"LOCAL={LOCAL}\n")
72+
f.write(f"TAG={TAG}\n")
73+
f.write(f"FULL_VERSION={FULL_VERSION}\n")
6574
EOF
6675
6776
build-kernel:
6877
name: Build Linux Hyperion Kernel
6978
needs: validate-config
7079
runs-on: ubuntu-latest
7180
env:
72-
KERNEL_VERSION: ${{ needs.validate-config.outputs.VERSION }}
73-
PATCHLEVEL: ${{ needs.validate-config.outputs.PATCH }}
74-
SUBLEVEL: ${{ needs.validate-config.outputs.SUB }}
75-
EXTRAVERSION: ${{ needs.validate-config.outputs.EXTRA }}
76-
LOCALVERSION: ${{ needs.validate-config.outputs.LOCAL }}
77-
TAG_NAME: ${{ needs.validate-config.outputs.TAG }}
81+
KERNEL_VERSION: ${{ needs.validate-config.outputs.VERSION }}
82+
PATCHLEVEL: ${{ needs.validate-config.outputs.PATCH }}
83+
SUBLEVEL: ${{ needs.validate-config.outputs.SUB }}
84+
EXTRAVERSION: ${{ needs.validate-config.outputs.EXTRA }}
85+
LOCALVERSION: ${{ needs.validate-config.outputs.LOCAL }}
86+
TAG_NAME: ${{ needs.validate-config.outputs.TAG }}
87+
# FIX 2: single source of truth for the full kernel version used in all paths
88+
FULL_VERSION: ${{ needs.validate-config.outputs.FULL_VERSION }}
7889
KBUILD_BUILD_USER: Soumalya Das
7990
KBUILD_BUILD_HOST: hyperion-ci
8091

@@ -95,31 +106,33 @@ jobs:
95106
id: cache-tar
96107
uses: actions/cache@v4
97108
with:
98-
path: linux-${{ env.KERNEL_VERSION }}.tar.xz
99-
key: kernel-tar-${{ env.KERNEL_VERSION }}
109+
# FIX 2: use FULL_VERSION so the filename matches what kernel.org actually serves
110+
path: linux-${{ env.FULL_VERSION }}.tar.xz
111+
key: kernel-tar-${{ env.FULL_VERSION }}
100112

101113
- name: Restore build cache
102114
id: cache-build
103115
uses: actions/cache@v4
104116
with:
105-
path: .cache-build/linux-${{ env.KERNEL_VERSION }}
106-
key: kernel-build-${{ env.KERNEL_VERSION }}-hyperion-${{ hashFiles('hyperion.config') }}
117+
path: .cache-build/linux-${{ env.FULL_VERSION }}
118+
key: kernel-build-${{ env.FULL_VERSION }}-hyperion-${{ hashFiles('hyperion.config') }}
107119
restore-keys: |
108-
kernel-build-${{ env.KERNEL_VERSION }}-
120+
kernel-build-${{ env.FULL_VERSION }}-
109121
110122
- name: Download kernel source if missing
111123
if: steps.cache-tar.outputs.cache-hit != 'true'
112-
run: wget -q https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${{ env.KERNEL_VERSION }}.tar.xz
124+
# FIX 2: URL uses FULL_VERSION (e.g. linux-6.14.tar.xz), not bare major version
125+
run: wget -q https://cdn.kernel.org/pub/linux/kernel/v${{ env.KERNEL_VERSION }}.x/linux-${{ env.FULL_VERSION }}.tar.xz
113126

114127
- name: Prepare build tree safely
115128
run: |
116129
mkdir -p .cache-build
117130
cd .cache-build
118-
if [ ! -d "linux-${KERNEL_VERSION}" ]; then
119-
tar -xf ../linux-${KERNEL_VERSION}.tar.xz
120-
EXTRACTED_DIR=$(tar -tf ../linux-${KERNEL_VERSION}.tar.xz | head -1 | cut -f1 -d"/")
121-
if [ "$EXTRACTED_DIR" != "linux-${KERNEL_VERSION}" ]; then
122-
mv "$EXTRACTED_DIR" "linux-${KERNEL_VERSION}"
131+
if [ ! -d "linux-${FULL_VERSION}" ]; then
132+
tar -xf ../linux-${FULL_VERSION}.tar.xz
133+
EXTRACTED_DIR=$(tar -tf ../linux-${FULL_VERSION}.tar.xz | head -1 | cut -f1 -d"/")
134+
if [ "$EXTRACTED_DIR" != "linux-${FULL_VERSION}" ]; then
135+
mv "$EXTRACTED_DIR" "linux-${FULL_VERSION}"
123136
fi
124137
fi
125138
cd ..
@@ -133,7 +146,7 @@ jobs:
133146
134147
- name: Configure kernel
135148
run: |
136-
cd .cache-build/linux-${KERNEL_VERSION}
149+
cd .cache-build/linux-${FULL_VERSION}
137150
cp ../../hyperion.config .config
138151
make olddefconfig \
139152
LOCALVERSION="${LOCALVERSION}" \
@@ -142,14 +155,22 @@ jobs:
142155
143156
- name: Apply patches
144157
run: |
145-
cd .cache-build/linux-${KERNEL_VERSION}
146-
for p in ../../patches/*.patch 2>/dev/null; do
147-
git apply "$p" || patch -p1 < "$p"
148-
done || true
158+
# FIX 3: nullglob prevents the literal glob string being passed when no patches exist
159+
shopt -s nullglob
160+
PATCHES=(../../patches/*.patch)
161+
if [ ${#PATCHES[@]} -gt 0 ]; then
162+
cd .cache-build/linux-${FULL_VERSION}
163+
for p in "${PATCHES[@]}"; do
164+
echo "Applying patch: $p"
165+
git apply "$p" || patch -p1 < "$p"
166+
done
167+
else
168+
echo "No patches to apply."
169+
fi
149170
150171
- name: Build kernel and prepend banner to build.log
151172
run: |
152-
cd .cache-build/linux-${KERNEL_VERSION}
173+
cd .cache-build/linux-${FULL_VERSION}
153174
{
154175
echo " ██╗ ██╗██╗ ██╗██████╗ ███████╗██████╗ ██╗ ██████╗ ███╗ ██╗"
155176
echo " ██║ ██║╚██╗ ██╔╝██╔══██╗██╔════╝██╔══██╗██║██╔═══██╗████╗ ██║"
@@ -162,36 +183,36 @@ jobs:
162183
LOCALVERSION="${LOCALVERSION}" \
163184
KBUILD_BUILD_USER="${KBUILD_BUILD_USER}" \
164185
KBUILD_BUILD_HOST="${KBUILD_BUILD_HOST}" \
165-
KBUILD_BUILD_TIMESTAMP="$(date -u '+%Y-%m-%d %H:%M:%S')"
186+
KBUILD_BUILD_TIMESTAMP="$(date -u '+%Y-%m-%d %H:%M:%S')"
166187
} 2>&1 | tee build.log
167188
168189
- name: Package artifacts into .tar.zst
169190
run: |
170-
cd .cache-build/linux-${KERNEL_VERSION}
171-
tar --zstd -cf ../../Hyperion-Kernel-${KERNEL_VERSION}.tar.zst \
191+
cd .cache-build/linux-${FULL_VERSION}
192+
# FIX 6: copy hyperion.config into the build dir so tar stores it without a "../../" prefix
193+
cp ../../hyperion.config hyperion.config
194+
tar --zstd -cf ../../Hyperion-Kernel-${FULL_VERSION}.tar.zst \
172195
arch/x86/boot/bzImage \
173196
Module.symvers \
174197
build.log \
175-
../../hyperion.config
198+
hyperion.config
176199
177200
- name: Generate checksum
178201
run: |
179-
sha256sum Hyperion-Kernel-${KERNEL_VERSION}.tar.zst > Hyperion-Kernel-${KERNEL_VERSION}.sha256
202+
sha256sum Hyperion-Kernel-${FULL_VERSION}.tar.zst > Hyperion-Kernel-${FULL_VERSION}.sha256
180203
181-
- name: Create GitHub Release
204+
# FIX 5: merged into a single release step — creating then uploading in two calls
205+
# is redundant and risks a race where the second call targets a non-existent release.
206+
# FIX 4: use ${{ env.FULL_VERSION }} (Actions expression syntax) in the with: block,
207+
# because shell variables like ${FULL_VERSION} are NOT expanded in YAML with: values.
208+
- name: Create GitHub Release and upload artifacts
182209
uses: softprops/action-gh-release@v2
183210
with:
184211
tag_name: ${{ env.TAG_NAME }}
185212
name: Linux ${{ env.TAG_NAME }}
186-
env:
187-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188-
189-
- name: Upload compressed archive & checksum
190-
uses: softprops/action-gh-release@v2
191-
with:
192213
files: |
193-
Hyperion-Kernel-${KERNEL_VERSION}.tar.zst
194-
Hyperion-Kernel-${KERNEL_VERSION}.sha256
214+
Hyperion-Kernel-${{ env.FULL_VERSION }}.tar.zst
215+
Hyperion-Kernel-${{ env.FULL_VERSION }}.sha256
195216
env:
196217
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
197218

0 commit comments

Comments
 (0)