Add workflow for updating kernel branch

This change adds a Github Actions workflow for updating a kernel branch
and creating a pull request with the change.
This commit is contained in:
Fabian Mastenbroek 2020-09-17 17:24:01 +02:00
parent c5d857229c
commit 228a71465f
No known key found for this signature in database
GPG key ID: 405FC6F81F0A7B85
3 changed files with 88 additions and 8 deletions

71
.github/workflows/update.yml vendored Normal file
View file

@ -0,0 +1,71 @@
name: Kernel Update
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag of the Linux Kernel to update to'
required: true
version:
description: 'Custom version number'
required: false
release:
description: 'Custom release number'
required: false
jobs:
update:
name: Update
runs-on: [ubuntu-latest]
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
submodules: recursive
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Setup System Dependencies
run: sudo apt install devscripts
- name: Update Kernel
id: update
run: |
TAG=${{ github.event.inputs.tag }}
VERSION=${{ github.event.inputs.version }}
RELEASE=${{ github.event.inputs.release }}
VERSION_OPT=${VERSION:+-v ${VERSION}}
RELEASE_OPT=${RELEASE:+-r ${RELEASE}}
./scripts/update.sh -t ${{ github.event.inputs.tag }} $VERSION_OPT $RELEASE_OPT
echo "::set-output name=version::$(scripts/version.sh -L)"
echo "::set-output name=full::$(scripts/version.sh)"
changelog=$(dpkg-parsechangelog -c 1 -l debian/changelog)
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/'%0A'}"
changelog="${changelog//$'\r'/'%0D'}"
echo "::set-output name=changelog::$changelog"
base=$(scripts/version.sh -B)
echo "::set-output name=base::$base"
echo "::set-output name=branch::${GITHUB_REF##*/}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ steps.generate-token.outputs.token }} # Custom token needed to recursively trigger workflows
commit-message: |
Add Linux ${{ steps.update.outputs.version }}
This change updates the kernel to Linux ${{ steps.update.outputs.version }} based on Ubuntu ${{ steps.update.output.base }}.
branch: staging/v${{ steps.update.outputs.full }}
branch-suffix: short-commit-hash
delete-branch: true
title: "Add Linux ${{ steps.update.outputs.version }}"
body: |
Automated pull request to update the kernel to Linux ${{ steps.update.outputs.version }}.
**Changelog:**
```
${{ steps.update.outputs.changelog }}
```
labels: |
release

View file

@ -5,9 +5,9 @@ set -o pipefail
LINUX_REPOSITORY=submodules/ubuntu-mainline
while getopts "r:t:b:v:h" OPTION; do
while getopts "R:t:b:v:r:h" OPTION; do
case $OPTION in
r)
R)
LINUX_REPOSITORY=$OPTARG
;;
t)
@ -19,13 +19,16 @@ while getopts "r:t:b:v:h" OPTION; do
v)
LINUX_VERSION=$OPTARG
;;
r)
LINUX_PACKAGE_RELEASE=$OPTARG
;;
h)
echo "update.sh -rtbh"
echo " -r path to Linux Git repository"
echo " -R path to Linux Git repository"
echo " -t tag in Linux Git repository to pick"
echo " -b manual basis for this kernel"
echo " -v manual version for this kernel"
echo " -r manual release version for this kernel"
echo " -h this help message"
exit 1
;;
@ -66,7 +69,9 @@ LINUX_VERSION_PATCH=${LINUX_VERSION_PATCH:-0} # Default to 0
LINUX_PACKAGE_RELEASE_PREVIOUS=$(scripts/version.sh -r)
# Check whether we need to increment the package release
if [[ $LINUX_VERSION == "$(scripts/version.sh -L)" ]]; then
if [[ -n $LINUX_PACKAGE_RELEASE ]]; then
echo "Using custom package release $LINUX_PACKAGE_RELEASE"
elif [[ $LINUX_VERSION == "$(scripts/version.sh -L)" ]]; then
LINUX_PACKAGE_RELEASE=$((LINUX_PACKAGE_RELEASE_PREVIOUS + 1))
echo "Incrementing package release to $LINUX_PACKAGE_RELEASE"
else

View file

@ -3,6 +3,7 @@
set -e
set -o pipefail
LINUX_REPOSITORY=submodules/ubuntu-mainline
LINUX_VERSION_MAJOR=$(sed -n "s/^KERNEL_MAJ=\([0-9]*$\)/\1/p" < Makefile | xargs)
LINUX_VERSION_MINOR=$(sed -n "s/^KERNEL_MIN=\([0-9]*$\)/\1/p" < Makefile | xargs)
LINUX_VERSION_PATCHLEVEL=$(sed -n "s/^KERNEL_PATCHLEVEL=\([0-9]*$\)/\1/p" < Makefile | xargs)
@ -11,8 +12,7 @@ LINUX_VERSION=$LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR.$LINUX_VERSION_PATCHLEVE
LINUX_PACKAGE_RELEASE=$(sed -n "s/^PKGREL=\([0-9]*$\)/\1/p" < Makefile | xargs)
LINUX_FLAVOR=$(sed -n "s/^PVE_BUILD_TYPE ?=\(.*\)$/\1/p" < Makefile | xargs)
while getopts "MmprfdLh" OPTION; do
while getopts "MmprfdLBh" OPTION; do
case $OPTION in
M)
echo $LINUX_VERSION_MAJOR
@ -42,7 +42,11 @@ while getopts "MmprfdLh" OPTION; do
L)
echo $LINUX_VERSION
exit 0
;;
;;
B)
echo $(git --git-dir $LINUX_REPOSITORY/.git log -1 --pretty=%B | sed -n "s/^.*Ubuntu-\([0-9.-]*\).*$/\1/p")
exit 0
;;
h)
echo "commit.sh [-Mmprfh]]"
echo " -M major version"