diff --git a/.github/workflows/precompiled.yaml b/.github/workflows/precompiled.yaml index 91686ff9..5fe6bd9f 100644 --- a/.github/workflows/precompiled.yaml +++ b/.github/workflows/precompiled.yaml @@ -59,6 +59,28 @@ jobs: dist_json=$(printf '%s\n' "${DIST[@]}" | jq -R . | jq -cs .) echo "dist=$dist_json" >> $GITHUB_OUTPUT + # BASE_TARGET setup + declare -A MAP_BASE_TARGET + MAP_BASE_TARGET["ubuntu22.04"]="jammy" + MAP_BASE_TARGET["ubuntu24.04"]="noble" + BASE_TARGETS_JSON="{" + for key in "${!MAP_BASE_TARGET[@]}"; do + BASE_TARGETS_JSON+="\"$key\":\"${MAP_BASE_TARGET[$key]}\"," + done + BASE_TARGETS_JSON="${BASE_TARGETS_JSON%,}}" + echo "BASE_TARGETS=$BASE_TARGETS_JSON" >> "$GITHUB_OUTPUT" + + # LTS_KERNELS env setup + declare -A MAP_LTS_KERNELS + MAP_LTS_KERNELS["ubuntu22.04"]="5.15" + MAP_LTS_KERNELS["ubuntu24.04"]="6.8" + LTS_KERNELS_JSON="{" + for key in "${!MAP_LTS_KERNELS[@]}"; do + LTS_KERNEL_JSON+="\"$key\":\"${MAP_LTS_KERNELS[$key]}\"," + done + LTS_KERNELS_JSON="${LTS_KERNELS_JSON%,}}" + echo "LTS_KERNELS=$LTS_KERNELS_JSON" >> "$GITHUB_OUTPUT" + precompiled-build-image: needs: set-driver-version-matrix runs-on: linux-amd64-cpu4 @@ -87,13 +109,13 @@ jobs: echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV - if [ "$DIST" == "ubuntu22.04" ]; then - echo "BASE_TARGET=jammy" >> $GITHUB_OUTPUT - echo "LTS_KERNEL=5.15" >> $GITHUB_OUTPUT - elif [ "$DIST" == "ubuntu24.04" ]; then - echo "BASE_TARGET=noble" >> $GITHUB_OUTPUT - echo "LTS_KERNEL=6.8" >> $GITHUB_OUTPUT - fi + BASE_TARGETS_JSON='${{ needs.set-driver-version-matrix.outputs.BASE_TARGETS }}' + BASE_TARGET=$(echo "$BASE_TARGETS_JSON" | jq -r --arg dist "$DIST" '.[$dist]') + echo "BASE_TARGET=$BASE_TARGET" >> $GITHUB_ENV + LTS_KERNELS_JSON='${{ needs.set-driver-version-matrix.outputs.LTS_KERNELS }}' + LTS_KERNEL=$(echo "$LTS_KERNEL_JSON" | jq -r --arg dist "$DIST" '.[$dist]') + echo "LTS_KERNEL=$LTS_KERNEL" >> $GITHUB_ENV + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -109,8 +131,8 @@ jobs: env: IMAGE_NAME: ghcr.io/nvidia/driver VERSION: ${COMMIT_SHORT_SHA} - BASE_TARGET: ${{ steps.vars.outputs.BASE_TARGET }} - LTS_KERNEL: ${{ steps.vars.outputs.LTS_KERNEL }} + BASE_TARGET: ${{ env.BASE_TARGET }} + LTS_KERNEL: ${{ env.LTS_KERNEL }} run: | make DRIVER_BRANCH=${{ matrix.driver_branch }} KERNEL_FLAVOR=${{ matrix.flavor }} LTS_KERNEL=${LTS_KERNEL} build-base-${BASE_TARGET} @@ -176,19 +198,25 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Calculate build vars + id: vars + env: + DIST: ${{ matrix.dist }} + run: | + BASE_TARGETS_JSON='${{ needs.set-driver-version-matrix.outputs.BASE_TARGETS }}' + BASE_TARGET=$(echo "$BASE_TARGETS_JSON" | jq -r --arg dist "$DIST" '.[$dist]') + echo "BASE_TARGET=$BASE_TARGET" >> $GITHUB_ENV + LTS_KERNELS_JSON='${{ needs.set-driver-version-matrix.outputs.LTS_KERNELS }}' + LTS_KERNEL=$(echo "$LTS_KERNEL_JSON" | jq -r --arg dist "$DIST" '.[$dist]') + echo "LTS_KERNEL=$LTS_KERNEL" >> $GITHUB_ENV + - name: Set kernel version env: DIST: ${{ matrix.dist }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BASE_TARGET: ${{ env.BASE_TARGET }} + LTS_KERNEL: ${{ env.LTS_KERNEL }} run: | - if [ "$DIST" == "ubuntu22.04" ]; then - export BASE_TARGET="jammy" - export LTS_KERNEL="5.15" - elif [ "$DIST" == "ubuntu24.04" ]; then - export BASE_TARGET="noble" - export LTS_KERNEL="6.8" - fi - kernel_flavors_json='${{ needs.set-driver-version-matrix.outputs.kernel_flavors }}' KERNEL_FLAVORS=($(echo "$kernel_flavors_json" | jq -r '.[]')) driver_branch_json='${{ needs.set-driver-version-matrix.outputs.driver_branch }}' diff --git a/Makefile b/Makefile index 07aae4e6..21cbb239 100644 --- a/Makefile +++ b/Makefile @@ -184,6 +184,7 @@ build-signed_ubuntu20.04%: DRIVER_TAG = $(DRIVER_BRANCH) # ubuntu22.04 Precompiled Driver build-signed_ubuntu22.04%: DIST = ubuntu22.04 +build-signed_ubuntu22.04%: BASE_TARGET = jammy build-signed_ubuntu22.04%: SUBDIR = ubuntu22.04/precompiled build-signed_ubuntu22.04%: DRIVER_TAG = $(DRIVER_BRANCH) build-signed_ubuntu22.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST) @@ -191,6 +192,7 @@ build-signed_ubuntu22.04%: DOCKER_BUILD_ARGS = --build-arg KERNEL_VERSION="$(KE # ubuntu24.04 Precompiled Driver build-signed_ubuntu24.04%: DIST = ubuntu24.04 +build-signed_ubuntu24.04%: BASE_TARGET = noble build-signed_ubuntu24.04%: SUBDIR = ubuntu24.04/precompiled build-signed_ubuntu24.04%: DRIVER_TAG = $(DRIVER_BRANCH) build-signed_ubuntu24.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)