Procházet zdrojové kódy

ci: anchor KSU_VERSION_FALLBACK, release version and tag to official sync point

Count KSU_VERSION_FALLBACK from the merge-base with origin/<base-branch>
(falling back to origin/main, then HEAD) instead of HEAD, matching
pershoot's Kbuild and the official manager's versionCode, and extract
KSU_VERSION and KSU_GIT_TAG from STOCK_COMMIT (the official KernelSU-Next
dev commit the fork syncs with) instead of the fork's HEAD, so release
notes and kernel runtime version match the manager display.
TheWildJames před 1 měsícem
rodič
revize
f4bc3a0578
2 změnil soubory, kde provedl 22 přidání a 11 odebrání
  1. 10 3
      .github/actions/kernelsu/action.yml
  2. 12 8
      .github/workflows/main.yml

+ 10 - 3
.github/actions/kernelsu/action.yml

@@ -48,13 +48,20 @@ runs:
         fi
 
         cd KernelSU-Next/kernel
-        
-        COMMITS_COUNT=$(/usr/bin/git rev-list --count HEAD)
+
+        # Anchor the version to the upstream sync point (merge-base with
+        # origin/<base-branch>) exactly like the official manager's
+        # versionCode and pershoot's Kbuild (c0a2c5fd), so the kernel's
+        # KSU_VERSION_FALLBACK matches the manager version the kernel
+        # reports at runtime. Fall back to origin/main, then HEAD.
+        BASE_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's:-.*::' 2>/dev/null)
+        BASE_COMMIT=$(git merge-base HEAD refs/remotes/origin/$BASE_BRANCH 2>/dev/null || git merge-base HEAD refs/remotes/origin/main 2>/dev/null || echo HEAD)
+        COMMITS_COUNT=$(/usr/bin/git rev-list --count $BASE_COMMIT)
         BASE_VERSION=30000
         KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
         sed -i "s/^KSU_VERSION_FALLBACK := 1$/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" Kbuild
 
-        KSU_GIT_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")"
+        KSU_GIT_TAG="$(git describe --tags --abbrev=0 $BASE_COMMIT 2>/dev/null || echo "v0.0.1")"
         sed -i "s/^KSU_VERSION_TAG_FALLBACK := v0.0.1$/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" Kbuild
     
     - name: Extract KSU Version Info

+ 12 - 8
.github/workflows/main.yml

@@ -516,14 +516,6 @@ jobs:
           KSUN_COMMIT="$KSU_INPUT"
         fi
 
-        # Extract version info
-        COMMITS_COUNT=$(git rev-list --count HEAD)
-        BASE_VERSION=30000
-        KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
-
-        # Extract git tag
-        KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "no-tag")
-
         # The manager is built on the OFFICIAL KernelSU-Next repo
         # (pershoot's workflows are all disabled). Find the official dev
         # commit this fork's branch is synced with (merge-base of our
@@ -545,6 +537,18 @@ jobs:
         STOCK_COMMIT=$(git merge-base HEAD FETCH_HEAD)
         echo "KSU Stock Commit (official sync point): $STOCK_COMMIT"
 
+        # Extract version info — anchored to the official sync point
+        # (STOCK_COMMIT), i.e. the commit the linked manager is built from.
+        # Mirrors pershoot c0a2c5fd: count the merge-base with origin, not
+        # the fork's extra commits, so the version shown in the release
+        # notes matches what the kernel reports and the manager displays.
+        COMMITS_COUNT=$(git rev-list --count "$STOCK_COMMIT")
+        BASE_VERSION=30000
+        KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
+
+        # Extract git tag at the sync point
+        KSU_GIT_TAG=$(git describe --tags --abbrev=0 "$STOCK_COMMIT" 2>/dev/null || echo "no-tag")
+
         MANAGER_RUN_ID=$(curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml/runs?head_sha=${STOCK_COMMIT}" | jq -r '.workflow_runs[0].id // empty')
         if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
           KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"