Build modules main #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (C) 2022 Ing <https://github.com/wjz304> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
name: Build modules main | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "format %y.%-m.$i or auto" | |
required: false | |
type: string | |
prerelease: | |
description: "pre release" | |
default: false | |
type: boolean | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- arch: x86_64 | |
qver: 4.5.4 | |
#- arch: x86_64 | |
# qver: 5.0.0 | |
#- arch: x86_64 | |
# qver: 5.1.0 | |
- arch: x86_64 | |
qver: 5.2.0 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
repository: RROrg/qr-modules | |
token: ${{ secrets.RRORG }} | |
path: qr-modules | |
- name: Init Env | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
sudo apt update | |
sudo apt install libelf-dev | |
- name: Make modules | |
run: | | |
sudo -s # use root to compile | |
ROOT_PATH=${{ github.workspace }} | |
ARCH=${{ matrix.arch }} | |
QVER=${{ matrix.qver }} | |
DEVICE="TS-X89" | |
. qr-modules/compile.sh | |
echo "makeEnvDeploy" | |
makeEnvDeploy "${ROOT_PATH}" "${ARCH}" "${QVER}" "${DEVICE}" | |
echo "makemodules" | |
KVER=$(getKver "${ROOT_PATH}" "${ARCH}" "${QVER}" "${DEVICE}") | |
mkdir -p "output/modules/${KVER}-qnap" | |
makemodules "${ROOT_PATH}" "${ARCH}" "${QVER}" "${DEVICE}" "qr-modules/src/${KVER}" "output/modules/${KVER}-qnap" | |
- name: firmware | |
run: | | |
sudo -s # use root to compile | |
ROOT_PATH=${{ github.workspace }} | |
ARCH=${{ matrix.arch }} | |
QVER=${{ matrix.qver }} | |
DEVICE="TS-X89" | |
. qr-modules/compile.sh | |
KVER=$(getKver "${ROOT_PATH}" "${ARCH}" "${QVER}" "${DEVICE}") | |
mkdir -p "output/firmware" | |
echo "get firmware" | |
SOURCE=/tmp/linux-firmware | |
git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git ${SOURCE} | |
while read L; do | |
[ -z "${L}" ] && continue | |
if [ -e "${SOURCE}/${L}" ]; then | |
mkdir -p "$(dirname output/firmware/${L})" | |
cp -f "${SOURCE}/${L}" "output/firmware/${L}" | |
else | |
[ ! -e "output/firmware/${L}" ] && echo "Missing ${L}" | |
fi | |
done <<<$(find output/modules/${KVER}-qnap -name \*.ko -exec sh -c 'modinfo {} | grep ^firmware' \; | awk '{print $2}') | |
tar -zcf ${ARCH}-${KVER}.tgz -C output . | |
- name: Upload to Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: modules-${{ matrix.arch }}-${{ matrix.qver }} | |
path: | | |
${{ matrix.arch }}-*.tgz | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Init Env | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
- name: Calculate version | |
run: | | |
# Calculate version | |
VERSION="" | |
if [ -n "${{ inputs.version }}" ]; then | |
if [ "$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then | |
VERSION="${{ inputs.version }}" | |
else | |
LATEST_TAG="$(curl -skLH "Authorization: token ${{ secrets.RRORG }}" "https://api.github.com/repos/RROrg/qr-modules/releases" | jq -r ".[0].tag_name" 2>/dev/null)" | |
if [ -n "${LATEST_TAG}" ] && [ "$(echo ${LATEST_TAG} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then # format %y.%-m.$i | |
VERSION="$(echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.')" | |
else | |
VERSION="$(date +'%y.%-m').0" | |
fi | |
fi | |
else | |
VERSION="" | |
fi | |
echo "VERSION: ${VERSION}" | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: download to artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: output | |
pattern: modules-* | |
merge-multiple: true | |
- name: delete-artifact | |
uses: geekyeggo/delete-artifact@v5 | |
with: | |
name: | | |
modules-* | |
- name: Zip modules | |
run: | | |
VERSION="${{ env.VERSION }}" | |
VERSION="${VERSION:-"test"}" | |
echo "${VERSION}" > "output/VERSION" | |
zip -9 modules-${VERSION}.zip -j output/* | |
- name: Upload to Artifacts | |
if: success() && env.VERSION == '' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: modules | |
path: | | |
modules*.zip | |
retention-days: 5 | |
- name: Release | |
if: success() && env.VERSION != '' | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ env.VERSION }} | |
prerelease: ${{ inputs.prerelease }} | |
artifacts: modules*.zip | |
owner: RROrg | |
repo: qr-modules | |
token: ${{ secrets.RRORG }} |