Skip to content

Build buildroot

Build buildroot #205

Workflow file for this run

#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Build buildroot
on:
workflow_dispatch:
inputs:
version:
description: "format %y.%-m.$i or auto"
required: false
type: string
prerelease:
description: "pre release"
default: false
type: boolean
br2ver:
description: "buildroot version"
default: "2024.02.x"
type: string
kerver:
description: "kernel version"
default: ""
type: string
jobs:
buildroot:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Checkout
uses: actions/checkout@main
with:
repository: RROrg/buildroot
token: ${{ secrets.RRORG }}
path: buildroot
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
- name: Initialization environment
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 -y locales busybox dialog gettext sed gawk jq curl
sudo apt install -y python-is-python3 python3-pip libelf-dev qemu-utils cpio xz-utils lz4 lzma bzip2 gzip zstd
# sudo snap install yq
if ! command -v yq &>/dev/null || ! yq --version 2>/dev/null | grep -q "v4."; then
sudo curl -kL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/bin/yq && sudo chmod a+x /usr/bin/yq
fi
df -h
- 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/rr-buildroot/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: Build buildroot
run: |
cd buildroot
chmod +x ./build_rr.sh
. ./build_rr.sh "${{ inputs.br2ver }}" "${{ inputs.kerver }}"
[ -n "${BUILDROOT_VERSION}" ] && echo "BUILDROOT_VERSION=${BUILDROOT_VERSION}" >> $GITHUB_ENV || exit 1
[ -n "${KERNEL_VERSION}" ] && echo "KERNEL_VERSION=${KERNEL_VERSION}" >> $GITHUB_ENV || exit 1
- name: Zip modules
run: |
cp -f buildroot/.rr-buildroot/output/images/bzImage bzImage-rr || exit 1
cp -f buildroot/.rr-buildroot/output/images/rootfs.cpio.zst initrd-rr || exit 1
VERSION="${{ env.VERSION }}"
VERSION="${VERSION:-"test"}"
echo "${VERSION}" > "VERSION"
zip -9 ${{ github.workspace }}/buildroot-${VERSION}.zip -j bzImage-rr initrd-rr VERSION
- name: Upload artifact
if: success() && env.VERSION == ''
uses: actions/upload-artifact@v4
with:
name: buildroot
path: |
buildroot*.zip
retention-days: 5
- name: Release
if: success() && env.VERSION != ''
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
prerelease: ${{ inputs.prerelease }}
artifacts: buildroot*.zip
body: |
Buildroot version: ${{ env.BUILDROOT_VERSION }}
Kernel version: ${{ env.KERNEL_VERSION }}
owner: RROrg
repo: rr-buildroot
token: ${{ secrets.RRORG }}