action.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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"
  11. echo "Searching for ${TARGET_FILE} on branch: $BRANCH..."
  12. # 1. Download ONLY the file list (tree index) of the remote branch
  13. # This runs instantly, takes zero disk space, and requires no tokens
  14. FILE_PATH=$(git archive --remote="$REPO_URL" "$BRANCH" | tar -t | grep "${TARGET_FILE}" | head -n 1)
  15. if [ -z "$FILE_PATH" ]; then
  16. echo "::error::Could not find ${TARGET_FILE} anywhere on branch $BRANCH"
  17. exit 1
  18. fi
  19. echo "File discovered at path: $FILE_PATH"
  20. # 2. Fetch the raw file content from its dynamically discovered location
  21. RAW_URL="https://githubusercontent.com/WildKernels/Samsung_Kernels/$BRANCH/$FILE_PATH"
  22. FILE_CONTENT=$(curl -s "$RAW_URL")
  23. # 3. Extract the BRANCH= line
  24. BRANCH_LINE=$(echo "$FILE_CONTENT" | grep "^BRANCH=" | head -n 1)
  25. if [ -z "$BRANCH_LINE" ]; then
  26. echo "::error::Could not find BRANCH= line inside $FILE_PATH"
  27. exit 1
  28. fi
  29. # 4. Parse components using awk (splits by '=' and '-')
  30. ANDROID_VER=$(echo "$BRANCH_LINE" | awk -F'[=-]' '{print $2}' | tr -d '" .')
  31. KERNEL_VER=$(echo "$BRANCH_LINE" | awk -F'[=-]' '{print $3}' | tr -d '" .')
  32. echo "Parsed Android Version: $ANDROID_VER"
  33. echo "Parsed Kernel Version: $KERNEL_VER"
  34. # 5. Export directly to GitHub Environment Variables
  35. echo "ANDROID_VERSION=$ANDROID_VER" >> $GITHUB_ENV
  36. echo "KERNEL_VERSION=$KERNEL_VER" >> $GITHUB_ENV