From 40bb5da43d1e8ad0a4f1e8fb4383713655ebd548 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Wed, 12 Apr 2023 10:24:12 +0200 Subject: [PATCH] .github: Port linux firmware update action from old coreos-overlay --- .github/workflows/firmware-apply-patch.sh | 32 ++++++++++++++ .github/workflows/firmware-release-main.yaml | 46 ++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100755 .github/workflows/firmware-apply-patch.sh create mode 100644 .github/workflows/firmware-release-main.yaml diff --git a/.github/workflows/firmware-apply-patch.sh b/.github/workflows/firmware-apply-patch.sh new file mode 100755 index 0000000000..424d85a941 --- /dev/null +++ b/.github/workflows/firmware-apply-patch.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -euo pipefail + +source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" + +prepare_git_repo + +pushd "${SDK_OUTER_OVERLAY}" + +# Parse the Manifest file for already present source files and keep the latest version in the current series +VERSION_OLD=$(sed -n "s/^DIST linux-firmware-\([0-9]*\).*$/\1/p" sys-kernel/coreos-firmware/Manifest | sort -ruV | head -n1) +if [[ "${VERSION_NEW}" = "${VERSION_OLD}" ]]; then + echo "already the latest Linux Firmware, nothing to do" + exit 0 +fi + +EBUILD_FILENAME=$(get_ebuild_filename sys-kernel/coreos-firmware "${VERSION_OLD}") +git mv "${EBUILD_FILENAME}" "sys-kernel/coreos-firmware/coreos-firmware-${VERSION_NEW}.ebuild" + +popd + +URL="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tag/?h=${VERSION_NEW}" + +generate_update_changelog 'Linux Firmware' "${VERSION_NEW}" "${URL}" 'linux-firmware' + +commit_changes sys-kernel/coreos-firmware "${VERSION_OLD}" "${VERSION_NEW}" + +cleanup_repo + +echo "VERSION_OLD=${VERSION_OLD}" >>"${GITHUB_OUTPUT}" +echo 'UPDATE_NEEDED=1' >>"${GITHUB_OUTPUT}" diff --git a/.github/workflows/firmware-release-main.yaml b/.github/workflows/firmware-release-main.yaml new file mode 100644 index 0000000000..4d90671c81 --- /dev/null +++ b/.github/workflows/firmware-release-main.yaml @@ -0,0 +1,46 @@ +name: Get the latest Linux Firmware release for main +on: + schedule: + - cron: '0 7 * * 4' + workflow_dispatch: + +jobs: + get-firmware-release: + runs-on: ubuntu-latest + steps: + - name: Check out scripts + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: scripts + - name: Figure out latest Linux Firmware release version + id: firmware-latest-release + run: | + versionNew=$(git ls-remote --tags https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git | cut -f2 | sed -n "/refs\/tags\/[0-9]*$/s/^refs\/tags\///p" | sort -ruV | head -n1) + echo "VERSION_NEW=${versionNew}" >>"${GITHUB_OUTPUT}" + - name: Set up Flatcar SDK + id: setup-flatcar-sdk + env: + WORK_SCRIPTS_DIR: "${{ github.workspace }}/scripts" + CHANNEL: main + run: scripts/.github/workflows/setup-flatcar-sdk.sh + - name: Apply patch for main + id: apply-patch-main + env: + GHA_SCRIPTS_DIR: "${{ github.workspace }}/scripts" + WORK_SCRIPTS_DIR: "${{ github.workspace }}/scripts" + VERSION_NEW: ${{ steps.firmware-latest-release.outputs.VERSION_NEW }} + PACKAGES_CONTAINER: ${{ steps.setup-flatcar-sdk.outputs.PACKAGES_CONTAINER }} + SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} + run: scripts/.github/workflows/firmware-apply-patch.sh + - name: Create pull request for main + uses: peter-evans/create-pull-request@v5 + if: steps.apply-patch-main.outputs.UPDATE_NEEDED == 1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: scripts + branch: firmware-${{ steps.firmware-latest-release.outputs.VERSION_NEW }}-main + base: main + title: Upgrade Linux Firmware in main from ${{ steps.apply-patch-main.outputs.VERSION_OLD }} to ${{ steps.firmware-latest-release.outputs.VERSION_NEW }} + body: Subject says it all. + labels: main