action.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: get kernel version before cloning
  2. description: get kernel version before cloning
  3. runs:
  4. using: composite
  5. steps:
  6. - name: Locate and extract version metadata
  7. shell: bash
  8. run: |
  9. TARGET_FILE="build.config.constants"
  10. REPO="WildKernels/Samsung_Kernels"
  11. echo "Searching for $TARGET_FILE on branch $BRANCH"
  12. # Get repository tree without cloning
  13. TREE_URL="https://api.github.com/repos/$REPO/git/trees/$BRANCH?recursive=1"
  14. FILE_PATH=$(curl -s "$TREE_URL" | \
  15. jq -r '.tree[].path' | \
  16. grep "/$TARGET_FILE$" | \
  17. head -n 1)
  18. if [ -z "$FILE_PATH" ]; then
  19. echo "::error::Could not find $TARGET_FILE"
  20. exit 1
  21. fi
  22. echo "Found: $FILE_PATH"
  23. # Download only the file
  24. RAW_URL="https://raw.githubusercontent.com/$REPO/$BRANCH/$FILE_PATH"
  25. FILE_CONTENT=$(curl -s "$RAW_URL")
  26. BRANCH_LINE=$(echo "$FILE_CONTENT" | grep "^BRANCH=" | head -n 1)
  27. if [ -z "$BRANCH_LINE" ]; then
  28. echo "::error::BRANCH= not found"
  29. exit 1
  30. fi
  31. # Extract versions
  32. VERSION=${BRANCH_LINE#*=}
  33. ANDROID_VERSION=${VERSION%-*}
  34. KERNEL_VERSION=${VERSION##*-}
  35. echo "Android: $ANDROID_VERSION"
  36. echo "Kernel: $KERNEL_VERSION"
  37. echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV"
  38. echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV"