| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- name: 'Extract Sublevel and File Name'
- description: 'Reads Makefile sublevel and composes FILE_NAME'
- inputs:
- kernel_version:
- required: true
- type: string
- android_version:
- required: true
- type: string
- os_patch_level:
- required: true
- type: string
- variant:
- required: true
- type: string
- sublevel:
- required: true
- type: string
- outputs:
- file_name:
- value: ${{ steps.extract.outputs.file_name }}
- sublevel:
- value: ${{ steps.extract.outputs.sublevel }}
- runs:
- using: composite
- steps:
- - id: extract
- shell: bash
- env:
- INPUT_OS_PATCH_LEVEL: ${{ inputs.os_patch_level }}
- run: |
- set -euo pipefail
- SUBLEVEL="${{ inputs.sublevel }}"
- MAKEFILE="${{ github.workspace }}/kernel/common/Makefile"
- if [ "$(printf '%s' "$INPUT_OS_PATCH_LEVEL" | tr '[:upper:]' '[:lower:]')" = "lts" ]; then
- if [ ! -f "$MAKEFILE" ]; then
- echo "LTS build requires $MAKEFILE" >&2
- exit 1
- fi
- mapfile -t matches < <(grep -E '^[[:space:]]*SUBLEVEL[[:space:]]*=' "$MAKEFILE" || true)
- if [ "${#matches[@]}" -ne 1 ]; then
- echo "Expected exactly one SUBLEVEL assignment in $MAKEFILE; found ${#matches[@]}" >&2
- exit 1
- fi
- EXTRACTED="${matches[0]#*=}"
- EXTRACTED="$(printf '%s' "$EXTRACTED" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
- if ! [[ "$EXTRACTED" =~ ^[0-9]+$ ]]; then
- echo "Invalid numeric SUBLEVEL '$EXTRACTED' in $MAKEFILE" >&2
- exit 1
- fi
- SUBLEVEL="$EXTRACTED"
- fi
- FILE_NAME="${{ inputs.kernel_version }}.${SUBLEVEL}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
- # Append variant only when it's provided and not the default 'Normal'
- if [ -n "${{ inputs.variant }}" ] && [ "${{ inputs.variant }}" != "Normal" ]; then
- FILE_NAME="${FILE_NAME}-${{ inputs.variant }}"
- fi
- echo "SUBLEVEL=$SUBLEVEL" >> "$GITHUB_ENV"
- echo "FILE_NAME=$FILE_NAME" >> "$GITHUB_ENV"
- echo "file_name=$FILE_NAME" >> "$GITHUB_OUTPUT"
- echo "sublevel=$SUBLEVEL" >> "$GITHUB_OUTPUT"
|