action.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: 'Extract Sublevel and File Name'
  2. description: 'Reads Makefile sublevel and composes FILE_NAME'
  3. inputs:
  4. kernel_version:
  5. required: true
  6. type: string
  7. android_version:
  8. required: true
  9. type: string
  10. os_patch_level:
  11. required: true
  12. type: string
  13. variant:
  14. required: true
  15. type: string
  16. sublevel:
  17. required: true
  18. type: string
  19. outputs:
  20. file_name:
  21. value: ${{ steps.extract.outputs.file_name }}
  22. sublevel:
  23. value: ${{ steps.extract.outputs.sublevel }}
  24. runs:
  25. using: composite
  26. steps:
  27. - id: extract
  28. shell: bash
  29. env:
  30. INPUT_OS_PATCH_LEVEL: ${{ inputs.os_patch_level }}
  31. run: |
  32. set -euo pipefail
  33. SUBLEVEL="${{ inputs.sublevel }}"
  34. MAKEFILE="${{ github.workspace }}/kernel/common/Makefile"
  35. if [ "$(printf '%s' "$INPUT_OS_PATCH_LEVEL" | tr '[:upper:]' '[:lower:]')" = "lts" ]; then
  36. if [ ! -f "$MAKEFILE" ]; then
  37. echo "LTS build requires $MAKEFILE" >&2
  38. exit 1
  39. fi
  40. mapfile -t matches < <(grep -E '^[[:space:]]*SUBLEVEL[[:space:]]*=' "$MAKEFILE" || true)
  41. if [ "${#matches[@]}" -ne 1 ]; then
  42. echo "Expected exactly one SUBLEVEL assignment in $MAKEFILE; found ${#matches[@]}" >&2
  43. exit 1
  44. fi
  45. EXTRACTED="${matches[0]#*=}"
  46. EXTRACTED="$(printf '%s' "$EXTRACTED" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
  47. if ! [[ "$EXTRACTED" =~ ^[0-9]+$ ]]; then
  48. echo "Invalid numeric SUBLEVEL '$EXTRACTED' in $MAKEFILE" >&2
  49. exit 1
  50. fi
  51. SUBLEVEL="$EXTRACTED"
  52. fi
  53. FILE_NAME="${{ inputs.kernel_version }}.${SUBLEVEL}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  54. # Append variant only when it's provided and not the default 'Normal'
  55. if [ -n "${{ inputs.variant }}" ] && [ "${{ inputs.variant }}" != "Normal" ]; then
  56. FILE_NAME="${FILE_NAME}-${{ inputs.variant }}"
  57. fi
  58. echo "SUBLEVEL=$SUBLEVEL" >> "$GITHUB_ENV"
  59. echo "FILE_NAME=$FILE_NAME" >> "$GITHUB_ENV"
  60. echo "file_name=$FILE_NAME" >> "$GITHUB_OUTPUT"
  61. echo "sublevel=$SUBLEVEL" >> "$GITHUB_OUTPUT"