Skip to content

Kernel Builder

Kernel Builder #299

Workflow file for this run

name: Kernel Builder
permissions:
contents: write
actions: write
on:
workflow_dispatch:
inputs:
BRANCH_OVERRIDE:
description: "Kernel branch overriding"
type: string
TG_NOTIFY:
description: "Telegram Notify"
default: true
type: boolean
CREATE_RELEASE:
description: "Create release?"
default: false
type: boolean
env:
DEBIAN_FRONTEND: noninteractive
MAN_DISABLE: true
TERM: xterm-256color
CCACHE_DIR: ${{ github.workspace }}/.ccache
jobs:
build:
runs-on: ubuntu-latest
env:
TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v6.0.1
with:
fetch-depth: 1
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq \
aria2 bc bison build-essential ccache curl debhelper dpkg-dev fakeroot flex gcc-aarch64-linux-gnu git jq just libelf-dev libfaketime libssl-dev make python3-requests tar xz-utils zip zstd
- name: Compute ccache key
run: |
echo "clang_hash=$(clang --version | sha256sum | cut -c1-10 || echo none)" >> "$GITHUB_ENV"
- name: Restore ccache
id: restore-ccache
uses: actions/cache/restore@v5.0.3
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.clang_hash }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
ccache-${{ env.clang_hash }}-${{ github.ref_name }}-
ccache-${{ env.clang_hash }}-
- name: Build
id: build
env:
BRANCH_OVERRIDE: ${{ github.event.inputs.BRANCH_OVERRIDE }}
DPKG_FLAGS: -d
TG_NOTIFY: ${{ github.event.inputs.TG_NOTIFY }}
run: |
just build
file="$GITHUB_WORKSPACE/github.json"
[[ -f "$file" ]] || { echo "::error::github.json missing"; exit 1; }
python3 - "$file" "$GITHUB_OUTPUT" <<'PY'
import json
import sys
with open(sys.argv[1]) as f:
data = json.load(f)
keys = ["name", "out_dir", "package_name", "kernel_name", "kernel_version", "toolchain", "release_repo", "release_branch"]
with open(sys.argv[2], "a") as out:
for key in keys:
out.write(f"{key}={data[key]}\n")
PY
- name: Save ccache
if: ${{ always() && steps.restore-ccache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v5.0.3
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.clang_hash }}-${{ github.ref_name }}-${{ github.sha }}
- name: Upload GitHub metadata artifact
uses: actions/upload-artifact@v6
with:
name: github-metadata
path: ${{ github.workspace }}/github.json
compression-level: 0
- name: Upload Build Log Artifact
uses: actions/upload-artifact@v6
with:
name: build-log
path: ${{ github.workspace }}/build.log
compression-level: 0
- name: Upload Kernel Package Artifact
uses: actions/upload-artifact@v6
with:
name: ${{ steps.build.outputs.name }}-package
path: ${{ steps.build.outputs.out_dir }}/${{ steps.build.outputs.package_name }}.tar.xz
compression-level: 0
- name: Generate New Tag
if: ${{ github.event.inputs.CREATE_RELEASE == 'true' }}
env:
RELEASE_REPO: ${{ steps.build.outputs.release_repo }}
run: |
TAG_PY="$GITHUB_WORKSPACE/py/tag.py"
RELEASE_TAG=$(python3 "$TAG_PY" "$RELEASE_REPO")
echo "New tag: $RELEASE_TAG"
echo "RELEASE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"
- name: Upload Builds To Release
if: ${{ github.event.inputs.CREATE_RELEASE == 'true' }}
uses: softprops/action-gh-release@v2.5.0
with:
repository: ${{ steps.build.outputs.release_repo }}
name: "${{ steps.build.outputs.kernel_name }} Kernel ${{ env.RELEASE_TAG }}"
tag_name: ${{ env.RELEASE_TAG }}
token: ${{ secrets.GH_TOKEN }}
body: |
### Build Information
| Field | Value |
|------|-------|
| **Kernel Name** | ${{ steps.build.outputs.kernel_name }} |
| **Kernel Version** | ${{ steps.build.outputs.kernel_version }} |
| **Compiler** | ${{ steps.build.outputs.toolchain }} |
generate_release_notes: false
prerelease: true
target_commitish: ${{ steps.build.outputs.release_branch }}
files: |
${{ steps.build.outputs.out_dir }}/${{ steps.build.outputs.package_name }}.tar.xz
${{ github.workspace }}/github.json
${{ github.workspace }}/build.log
- name: Notify Telegram
if: ${{ github.event.inputs.CREATE_RELEASE == 'true' && github.event.inputs.TG_NOTIFY == 'true' }}
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
run: |
TG_PY="$GITHUB_WORKSPACE/py/tg.py"
escape_md_v2() {
python3 - "$*" <<'PY'
import sys, re
s = sys.argv[1]
escaped = re.sub(r'([\\_*[\]()~`>#+\-=|{}.!])', r'\\\1', s)
print(escaped, end="")
PY
}
message=$(
cat <<EOF
📦 *$(escape_md_v2 "${{ steps.build.outputs.kernel_name }} Release Build Completed!")*
[GitHub Release]($(escape_md_v2 "https://github.com/${{ steps.build.outputs.release_repo }}/releases/tag/${{ env.RELEASE_TAG }}"))
EOF
)
printf '%s' "$message" | python3 "$TG_PY" msg