Build releases #14
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
name: Build releases | |
on: | |
workflow_dispatch: | |
inputs: | |
device: | |
description: 'Select device to build' | |
required: true | |
default: 'x86_64' | |
type: choice | |
options: | |
- 'armv8' | |
- 'nanopi-r4s' | |
- 'nanopi-r5s' | |
- 'netgear_r8500' | |
- 'x86_64' | |
build_options: | |
description: 'Build options (separate multiple options with spaces)' | |
required: false | |
default: 'KERNEL_CLANG_LTO=y BUILD_FAST=y ENABLE_LTO=y ENABLE_MOLD=y ENABLE_LRNG=y ENABLE_BPF=y USE_GCC14=y' | |
type: string | |
jobs: | |
build: | |
name: Build ${{ github.event.inputs.device }} | |
runs-on: ubuntu-24.04 | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Setup variables | |
run: | | |
sudo timedatectl set-timezone 'Asia/Shanghai' | |
git config --global user.name 'actions' | |
git config --global user.email 'action@github.com' | |
echo WORKDIR="/builder" >> "$GITHUB_ENV" | |
- name: Show system | |
run: | | |
echo -e "\n\e[1;32mCPU:\e[0m" | |
echo "$(grep 'model name' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}') ($(grep 'cpu MHz' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}')MHz) x $(grep processor /proc/cpuinfo | wc -l)" | |
echo -e "\n\e[1;32mMemory:\e[0m" | |
free -h | |
echo -e "\n\e[1;32mStorage:\e[0m" | |
df -Th / /mnt | |
echo -e "\n\e[1;32mSystem:\e[0m" | |
lsb_release -a | |
echo -e "\n\e[1;32mKernel:\e[0m" | |
uname -a | |
echo | |
- name: Free disk space | |
uses: sbwml/actions@free-disk | |
with: | |
build-mount-path: /builder | |
- name: Build System Setup | |
uses: sbwml/actions@openwrt-build-setup | |
- name: Install LLVM | |
uses: sbwml/actions@install-llvm | |
- name: Compile OpenWrt | |
working-directory: /builder | |
id: compile | |
continue-on-error: true | |
run: | | |
export GITHUB_REPO=${{ github.repository }} | |
export ${{ github.event.inputs.build_options }} | |
bash <(curl -sS https://raw.githubusercontent.com/${{ github.repository }}/master/openwrt/build.sh) rc2 ${{ github.event.inputs.device }} | |
cd openwrt | |
tags=$(git describe --abbrev=0 --tags) | |
echo "latest_release=$tags" >>$GITHUB_ENV | |
- name: Extensive logs after a failed compilation | |
working-directory: /builder | |
if: steps.compile.outcome == 'failure' | |
run: | | |
cd openwrt | |
make V=s | |
- name: Prepare Firmware Files | |
working-directory: /builder | |
run: | | |
mkdir -p rom info | |
if [ "${{ github.event.inputs.device }}" = "nanopi-r4s" ]; then | |
cp -a openwrt/bin/targets/rockchip/*/*.img.gz rom/ | |
cp -a openwrt/bin/targets/rockchip/*/*-r4s.manifest info/manifest.txt | |
cp -a openwrt/bin/targets/rockchip/*/config.buildinfo info/config.buildinfo | |
cd rom && sha256sum *gz > ../info/sha256sums.txt | |
elif [ "${{ github.event.inputs.device }}" = "nanopi-r5s" ]; then | |
cp -a openwrt/bin/targets/rockchip/*/*.img.gz rom/ | |
cp -a openwrt/bin/targets/rockchip/*/*.manifest info/manifest.txt | |
cp -a openwrt/bin/targets/rockchip/*/config.buildinfo info/config.buildinfo | |
cd rom && sha256sum *gz > ../info/sha256sums.txt | |
elif [ "${{ github.event.inputs.device }}" = "x86_64" ]; then | |
cp -a openwrt/bin/targets/x86/*/*-ext4-combined-efi.img.gz rom/ | |
cp -a openwrt/bin/targets/x86/*/*-squashfs-combined-efi.img.gz rom/ | |
cp -a openwrt/bin/targets/x86/*/*-generic-rootfs.tar.gz rom/ | |
cp -a openwrt/bin/targets/x86/*/*-x86-64-generic.manifest info/manifest.txt | |
cp -a openwrt/bin/targets/x86/*/config.buildinfo info/config.buildinfo | |
cd rom && sha256sum *gz > ../info/sha256sums.txt | |
elif [ "${{ github.event.inputs.device }}" = "armv8" ]; then | |
tar zcf rom/u-boot-qemu_armv8.tar.gz -C openwrt/bin/targets/armsr/armv8*/ ./u-boot-qemu_armv8 | |
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-initramfs-kernel.bin rom/ | |
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-kernel.bin rom/ | |
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-ext4-combined-efi.img.gz rom/ | |
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-squashfs-combined-efi.img.gz rom/ | |
cp -a openwrt/bin/targets/armsr/armv8*/*-rootfs.tar.gz rom/ | |
cp -a openwrt/bin/targets/armsr/armv8*/*.manifest info/manifest.txt | |
cp -a openwrt/bin/targets/armsr/armv8*/config.buildinfo info/config.buildinfo | |
cd rom && sha256sum * > ../info/sha256sums.txt | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.event.inputs.device }}-openwrt-${{ env.latest_release }} | |
path: ${{ env.WORKDIR }}/rom/* | |
- name: Create release | |
continue-on-error: true | |
uses: sbwml/release-action@main | |
with: | |
name: OpenWrt-${{ env.latest_release }} | |
allowUpdates: true | |
tag: ${{ env.latest_release }} | |
commit: master | |
replacesArtifacts: true | |
token: ${{ secrets.OP_REPO }} | |
artifacts: ${{ env.WORKDIR }}/rom/* |