Skip to content

Commit 1482694

Browse files
authored
feat: migrate to fully dynamic, JSON-driven device configuration (#77)
Replace the hardcoded matrix and fragmented device inputs with a unified, extensible JSON-based configuration system. Each device is now defined by a single JSON file in configs/, enabling: - Dynamic workflow matrix generation from JSON configs - Automatic parsing of all fields (including booleans like "hmbird") via jq - Export of config values as OP_* environment variables (e.g., $OP_MODEL) - Flexible workflow_dispatch with options to build one, all, or filtered devices - No need to modify workflow or action code when adding new devices or fields All 26 device configs updated accordingly. This change dramatically improves maintainability, scalability, and onboarding of new devices.
1 parent e18145f commit 1482694

28 files changed

+363
-191
lines changed

.github/actions/action.yml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,8 @@ permissions:
55
actions: write
66

77
inputs:
8-
model:
9-
required: true
10-
type: string
11-
soc:
12-
required: true
13-
type: string
14-
branch:
15-
required: true
16-
type: string
17-
manifest:
8+
op_config_json:
9+
description: 'JSON string containing full device config'
1810
required: true
1911
type: string
2012
ksun_branch:
@@ -45,15 +37,24 @@ outputs:
4537
runs:
4638
using: composite
4739
steps:
40+
- name: Parse op_config_json
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
echo '${{ inputs.op_config_json }}' > /tmp/config.json
45+
jq -r 'to_entries[] | "OP_\(.key | ascii_upcase)=\(.value)"' /tmp/config.json >> "$GITHUB_ENV"
46+
echo "Parsed config:"
47+
jq '.' /tmp/config.json
48+
4849
- name: Validate Inputs
4950
shell: bash
5051
run: |
5152
set -euo pipefail
5253
echo "::group::Validate inputs"
53-
model='${{ inputs.model }}'
54-
soc='${{ inputs.soc }}'
55-
branch='${{ inputs.branch }}'
56-
manifest='${{ inputs.manifest }}'
54+
model="$OP_MODEL"
55+
soc="$OP_SOC"
56+
branch="$OP_BRANCH"
57+
manifest="$OP_MANIFEST"
5758
optimize='${{ inputs.optimize_level }}'
5859
5960
# Non-empty checks
@@ -113,7 +114,7 @@ runs:
113114
run: |
114115
set -euo pipefail
115116
# Derive a unique build directory name
116-
CONFIG="${{ inputs.model }}"
117+
CONFIG="$OP_MODEL"
117118
echo "CONFIG=$CONFIG" >> "$GITHUB_ENV"
118119
# Install repo tool if missing
119120
REPO="/usr/local/bin/repo"
@@ -131,12 +132,12 @@ runs:
131132
mkdir -p "$CONFIG"
132133
cd "$CONFIG"
133134
echo "Initializing and syncing kernel source..."
134-
if [[ "${{ inputs.manifest }}" == https://* ]]; then
135+
if [[ "$OP_MANIFEST" == https://* ]]; then
135136
mkdir -p .repo/manifests
136-
curl --fail --show-error --location --proto '=https' "${{ inputs.manifest }}" -o .repo/manifests/temp_manifest.xml
137+
curl --fail --show-error --location --proto '=https' "$OP_MANIFEST" -o .repo/manifests/temp_manifest.xml
137138
"$REPO" init -u https://github.com/OnePlusOSS/kernel_manifest.git -b oneplus/sm8650 -m temp_manifest.xml --repo-rev=v2.16 --depth=1 --no-clone-bundle --no-tags
138139
else
139-
"$REPO" init -u https://github.com/OnePlusOSS/kernel_manifest.git -b "${{ inputs.branch }}" -m "${{ inputs.manifest }}" --repo-rev=v2.16 --depth=1 --no-clone-bundle --no-tags
140+
"$REPO" init -u https://github.com/OnePlusOSS/kernel_manifest.git -b "$OP_BRANCH" -m "$OP_MANIFEST" --repo-rev=v2.16 --depth=1 --no-clone-bundle --no-tags
140141
fi
141142
"$REPO" --version
142143
success=false
@@ -181,7 +182,7 @@ runs:
181182
SUBLEVEL=$(grep '^SUBLEVEL *=' Makefile | awk '{print $3}')
182183
FULL_VERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
183184
cd "$ARTIFACTS_DIR"
184-
echo "$ANDROID_VERSION-$FULL_VERSION" > "${{ inputs.model }}.txt"
185+
echo "$ANDROID_VERSION-$FULL_VERSION" > "${OP_MODEL}.txt"
185186
echo "ANDROID_VER=$ANDROID_VERSION" >> "$GITHUB_ENV"
186187
echo "KERNEL_VER=$VERSION.$PATCHLEVEL" >> "$GITHUB_ENV"
187188
echo "KERNEL_FULL_VER=$ANDROID_VERSION-$FULL_VERSION" >> "$GITHUB_ENV"
@@ -349,7 +350,7 @@ runs:
349350
else
350351
echo "Kernel >= $MIN_VERSION, skipping ptrace patch"
351352
fi
352-
if [ "${{ inputs.model }}" == "OPAce5Pro" ] || [ "${{ inputs.model }}" == "OP13-PJZ" ] || [ "${{ inputs.model }}" == "OP13-CPH" ]; then
353+
if [ "$OP_HMBIRD" = true ]; then
353354
echo "Patching hmbird!"
354355
echo 'obj-y += hmbird_patch.o' >> ./drivers/Makefile
355356
patch -p1 -F 3 < "../../../kernel_patches/oneplus/hmbird/hmbird_kernel_patch.patch"
@@ -358,7 +359,7 @@ runs:
358359
rm -rf ext.c ext.h build_policy.c slim.h slim_sysctl.c
359360
patch -p1 -F 3 < "../../../../../kernel_patches/oneplus/hmbird/hmbird_files_patch.patch"
360361
else
361-
echo "Not OPAce5Pro / OP13-PJZ / OP13-CPH , skipping fengchi patch"
362+
echo "Not OP-ACE-5-PRO / OP13-PJZ / OP13-CPH , skipping fengchi patch"
362363
fi
363364
364365
- name: Apply KSUN Hooks
@@ -619,20 +620,20 @@ runs:
619620
cd "$GITHUB_WORKSPACE/AnyKernel3"
620621

621622
# Optional hmbird patch logic
622-
if [ "${{ inputs.model }}" == "OPAce5Pro" ] || [ "${{ inputs.model }}" == "OP13-PJZ" ] || [ "${{ inputs.model }}" == "OP13-CPH" ]; then
623+
if [ "$OP_HMBIRD" = true ]; then
623624
cp "$GITHUB_WORKSPACE/kernel_patches/oneplus/hmbird/bins/"* ./tools/ 2>/dev/null || true
624625
patch -F 3 < "$GITHUB_WORKSPACE/kernel_patches/oneplus/hmbird/ak3_hmbird_patch.patch"
625626
fi
626627

627-
ZIP_NAME="AnyKernel3_${{ inputs.model }}_${{ env.KERNEL_FULL_VER }}_Next_${KSUVER}_${SUSVER}.zip"
628+
ZIP_NAME="AnyKernel3_${OP_MODEL}_${{ env.KERNEL_FULL_VER }}_Next_${KSUVER}_${SUSVER}.zip"
628629
ARTIFACTS_DIR="$CONFIG_DIR/artifacts"
629630
mkdir -p "$ARTIFACTS_DIR"
630631

631632
echo "Creating flashable zip: $ZIP_NAME"
632633
( cd "$GITHUB_WORKSPACE/AnyKernel3" && zip -r "$ARTIFACTS_DIR/$ZIP_NAME" ./* >/dev/null )
633634

634635
# Keep only the flashable zip and the model metadata file (assumed already created earlier)
635-
find "$ARTIFACTS_DIR" -maxdepth 1 -type f ! -name "$ZIP_NAME" ! -name "${{ inputs.model }}.txt" -delete
636+
find "$ARTIFACTS_DIR" -maxdepth 1 -type f ! -name "$ZIP_NAME" ! -name "${OP_MODEL}.txt" -delete
636637

637638
# Output for later steps (optional)
638639
echo "zip_name=$ZIP_NAME" >> "$GITHUB_OUTPUT"
@@ -642,7 +643,7 @@ runs:
642643
run: |
643644
set -euo pipefail
644645
{
645-
echo "Model: ${{ inputs.model }}"
646+
echo "Model: ${OP_MODEL}"
646647
echo "Android: ${{ env.ANDROID_VER }}"
647648
echo "Kernel base: ${{ env.KERNEL_VER }}"
648649
echo "Kernel full: ${{ env.KERNEL_FULL_VER }}"
@@ -659,7 +660,7 @@ runs:
659660
{
660661
echo "### Kernel Build Summary"
661662
echo ""
662-
echo "- Model: ${{ inputs.model }}"
663+
echo "- Model: ${OP_MODEL}"
663664
echo "- Android: ${{ env.ANDROID_VER }}"
664665
echo "- Kernel Version: ${{ steps.save_metadata.outputs.kernel_version }}"
665666
echo "- Kernel Uname: ${{ env.KERNEL_UNAME }}"

0 commit comments

Comments
 (0)