action.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: get kernel version before cloning
  2. description: get kernel version before cloning
  3. runs:
  4. using: composite
  5. steps:
  6. - name: Locate, Fetch, and Split Version Metadata
  7. shell: bash
  8. run: |
  9. TARGET_FILE="build.config.constants"
  10. REPO_URL="https://github.com/WildKernels/Samsung_Kernels.git"
  11. echo "Searching for ${TARGET_FILE} on branch: ${{ matrix.branch }}..."
  12. # 1. Use git ls-remote to find the exact file path on the remote branch without cloning
  13. FILE_PATH=$(git ls-remote -r --name-only "https://github.com/WildKernels/Samsung_Kernels" "$BRANCH" | grep "/${TARGET_FILE}$\|^${TARGET_FILE}$" | head -n 1)
  14. if [ -z "$FILE_PATH" ]; then
  15. echo "::error::Could not find ${TARGET_FILE} anywhere on branch $BRANCH"
  16. exit 1
  17. fi
  18. echo "File discovered at path: $FILE_PATH"
  19. # 2. Fetch the raw file from its dynamically discovered public URL
  20. RAW_URL="https://githubusercontent.com/WildKernels/Samsung_Kernels/$BRANCH/$FILE_PATH"
  21. FILE_CONTENT=$(curl -s "$RAW_URL")
  22. # 3. Extract the BRANCH= line
  23. BRANCH_LINE=$(echo "$FILE_CONTENT" | grep "^BRANCH=" | head -n 1)
  24. if [ -z "$BRANCH_LINE" ]; then
  25. echo "::error::Could not find BRANCH= line inside $FILE_PATH"
  26. exit 1
  27. fi
  28. # 4. Parse components using awk (splits by '=' and '-')
  29. ANDROID_VER=$(echo "$BRANCH_LINE" | awk -F'[=-]' '{print $2}' | tr -d '" .')
  30. KERNEL_VER=$(echo "$BRANCH_LINE" | awk -F'[=-]' '{print $3}' | tr -d '" .')
  31. echo "Parsed Android Version: $ANDROID_VER"
  32. echo "Parsed Kernel Version: $KERNEL_VER"
  33. # 5. Export directly to GitHub Environment Variables
  34. echo "ANDROID_VERSION=$ANDROID_VER" >> $GITHUB_ENV
  35. echo "KERNEL_VERSION=$KERNEL_VER" >> $GITHUB_ENV