Skip to content

Build releases

Build releases #629

Workflow file for this run

name: Build releases
on:
workflow_dispatch:
repository_dispatch:
types: [release]
jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id
name: Build ${{ matrix.model }}-${{ matrix.tag.version }}
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
model:
- armv8
- nanopi-r4s
- nanopi-r5s
- x86_64
- netgear_r8500
tag:
- type: rc2
version: openwrt-23.05
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set time zone
run: sudo timedatectl set-timezone 'Asia/Shanghai'
- name: Show system
run: |
lscpu
free -h
df -Th
uname -a
- name: Set release env
run: |
echo WORKDIR="/builder" >> "$GITHUB_ENV"
if [[ ${{ matrix.model }} != "nanopi-r4s" ]]; then
echo "release_kmod=true" >> "$GITHUB_ENV"
fi
if [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
echo "kmod_repo=kmod-aarch64" >> "$GITHUB_ENV"
elif [ "${{ matrix.model }}" = "x86_64" ]; then
echo "kmod_repo=kmod-x86_64" >> "$GITHUB_ENV"
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
echo "kmod_repo=kmod-bcm53xx" >> "$GITHUB_ENV"
elif [ "${{ matrix.model }}" = "armv8" ]; then
echo "kmod_repo=kmod-armsr-armv8" >> "$GITHUB_ENV"
fi
- name: Free disk space
run: |
sudo rm -rf /etc/apt/sources.list.d
sudo bash -c "curl -s https://us.cooluc.com/ubuntu-apt/sources-22.04.list > /etc/apt/sources.list"
sudo swapoff -a
sudo rm -f /swapfile /mnt/swapfile
sudo docker image prune -a -f
sudo systemctl stop docker
sudo snap set system refresh.retain=2
sudo apt-get -y purge firefox clang* ghc* google* llvm* mono* mongo* mysql* php*
sudo apt-get -y autoremove --purge
sudo apt-get clean
sudo rm -rf /etc/mysql /etc/php /usr/lib/jvm /usr/libexec/docker /usr/local /usr/src/* /var/lib/docker /var/lib/gems /var/lib/mysql /var/lib/snapd /etc/skel /opt/{microsoft,az,hostedtoolcache,cni,mssql-tools,pipx} /usr/share/{az*,dotnet,swift,miniconda,gradle*,java,kotlinc,ri,sbt} /root/{.sbt,.local,.npm}
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
rm -rf ~/{.cargo,.dotnet,.rustup}
df -Th
- name: Create Swap
run: |
sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=8192
sudo chmod 600 /mnt/swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
free -h | grep -i swap
- name: Build System Setup
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y build-essential flex bison cmake g++ gawk gcc-multilib g++-multilib gettext git libfuse-dev libncurses5-dev libssl-dev python3 python3-pip python3-ply python3-distutils python3-pyelftools rsync unzip zlib1g-dev file wget subversion patch upx-ucl autoconf automake curl asciidoc binutils bzip2 lib32gcc-s1 libc6-dev-i386 uglifyjs msmtp texinfo libreadline-dev libglib2.0-dev xmlto libelf-dev libtool autopoint antlr3 gperf ccache swig coreutils haveged scons libpython3-dev rename qemu-utils
sudo apt-get clean
git config --global user.name 'GitHub Actions' && git config --global user.email 'noreply@github.com'
- name: Create VG & LV
run: |
mnt_size=$(df -h /mnt | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//')
root_size=$(expr $(df -h / | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 2)
sudo truncate -s "$mnt_size"G /mnt/mnt.img
sudo truncate -s "$root_size"G /root.img
sudo losetup /dev/loop6 /mnt/mnt.img
sudo losetup /dev/loop7 /root.img
sudo pvcreate /dev/loop6
sudo pvcreate /dev/loop7
sudo vgcreate github /dev/loop6 /dev/loop7
sudo lvcreate -n runner -l 100%FREE github
sudo mkfs.xfs /dev/github/runner
- name: Mount LV
run: |
sudo mkdir -p /builder
sudo mount /dev/github/runner /builder
sudo chown -R runner.runner /builder
df -Th
- name: Install LLVM
run: |
export PATH="/opt/clang/bin:$PATH"
mkdir /opt/clang
curl -LO https://github.com/sbwml/redhat-llvm-project/releases/download/18.1.6/clang-18.1.6-x86_64-redhat-linux.tar.xz --progress-bar
sudo tar --strip-components=1 -C /opt/clang -xf clang-18.1.6-x86_64-redhat-linux.tar.xz
rm -rf clang-18.1.6-x86_64-redhat-linux.tar.xz
clang --version
- name: Compile OpenWrt
id: compile
continue-on-error: true
working-directory: /builder
run: |
export PATH="/opt/clang/bin:$PATH"
[ "${{ matrix.model }}" != "netgear_r8500" ] && export KERNEL_CLANG_LTO=y
BUILD_FAST=y ENABLE_OTA=y ENABLE_BPF=y ENABLE_LTO=y ENABLE_LRNG=y USE_GCC15=y USE_MOLD=y bash <(curl -sS ${{ secrets.script_url_general }}) ${{ matrix.tag.type }} ${{ matrix.model }}
cd openwrt
tags=$(git describe --abbrev=0 --tags)
echo "latest_release=$tags" >>$GITHUB_ENV
- name: Extensive logs after a failed compilation
if: steps.compile.outcome == 'failure'
working-directory: /builder
run: |
export PATH="/opt/clang/bin:$PATH"
cd openwrt
make V=s
- name: Prepare Firmware Files
working-directory: /builder
run: |
mkdir -p rom info
if [ "${{ matrix.model }}" = "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 * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "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 * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "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 * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
cp -a openwrt/bin/targets/bcm53xx/generic/*-bcm53xx-generic-netgear_r8500-squashfs.chk rom/
cp -a openwrt/bin/targets/bcm53xx/generic/*.manifest info/manifest.txt
cp -a openwrt/bin/targets/bcm53xx/generic/config.buildinfo info/config.buildinfo
cd rom && sha256sum * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "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
cd ..
tar zcf rom/buildinfo_${{ matrix.model }}.tar.gz info
- name: Create virtual machine images
if: ${{ matrix.model == 'x86_64' }}
working-directory: /builder
run: |
mkdir -p virtual_images
cp -a openwrt/bin/targets/x86/*/*-generic-squashfs-combined-efi.img.gz virtual_images/
gzip -dq virtual_images/*-generic-squashfs-combined-efi.img.gz || true
cd virtual_images
image_name=$(basename -s .img *.img)
qemu-img convert -f raw -O qcow2 *.img $image_name.qcow2
qemu-img convert -f raw -O vpc *.img $image_name.vhd
qemu-img convert -f raw -O vmdk *.img $image_name.vmdk
rm -f *.img
sha256sum * > sha256sums.txt
echo "<center><h1>x86_64 虚拟机平台镜像</h1></center>" > README.md
- name: Create release
uses: sbwml/release-action@main
with:
name: OpenWrt-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: master
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: ${{ env.WORKDIR }}/rom/*
- name: Release kmods
if: env.release_kmod == 'true'
uses: sbwml/release-action@main
with:
name: OpenWrt-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: master
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: ${{ env.WORKDIR }}/openwrt/*-*.tar.gz
- name: Sync kernel modules
if: env.release_kmod == 'true'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.workflow_token }}
repository: sbwml/${{ env.kmod_repo }}
event-type: sync
- name: Install aliyunpan & login
if: ${{ matrix.model != 'armv8' }}
continue-on-error: true
working-directory: /builder
run: |
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
device_id=${{ secrets.device_id_r4s }}
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
device_id=${{ secrets.device_id_r5s }}
elif [ "${{ matrix.model }}" = "x86_64" ]; then
device_id=${{ secrets.device_id_x86 }}
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
device_id=${{ secrets.device_id_netgear }}
fi
sudo curl -L ${{ secrets.aliyunpan_go }} -o /bin/aliyunpan --progress-bar
sudo chmod 0755 /bin/aliyunpan
sudo sh -c 'echo "${{ secrets.aliyunpan_us_node }} api.alipan.com auth.alipan.com www.alipan.com" >> /etc/hosts'
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan"
aliyun_token=`curl -s ${{ secrets.aliyun_token }} | openssl enc -aes-256-cfb -pbkdf2 -a -d -k ${{ secrets.token_dec }}`
aliyunpan config set -device_id=$device_id >/dev/null 2>&1
echo
echo $aliyun_token | aliyunpan login
- name: Upload Firmware - releases
if: ${{ matrix.model != 'armv8' }}
id: upload
continue-on-error: true
working-directory: /builder
run: |
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan"
version=$(cat openwrt/version.txt)
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
aliyunpan upload --timeout 30 --retry 10 --ow info/config.buildinfo openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/manifest.txt openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/sha256sums.txt openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-r4s-ext4-sysupgrade.img.gz openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-r4s-squashfs-sysupgrade.img.gz openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
aliyunpan upload --timeout 30 --retry 10 --ow info/config.buildinfo openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/manifest.txt openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/sha256sums.txt openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-r5c-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-r5c-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-r5s-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-r5s-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
elif [ "${{ matrix.model }}" = "x86_64" ]; then
aliyunpan upload --timeout 30 --retry 10 --ow info/config.buildinfo openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/manifest.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/sha256sums.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-generic-rootfs.tar.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-ext4-combined-efi.img.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-squashfs-combined-efi.img.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
# virtual machine images
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/README.md openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/sha256sums.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/*.vmdk openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/*.vhd openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/*.qcow2 openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
aliyunpan upload --timeout 30 --retry 10 --ow info/config.buildinfo openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/manifest.txt openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/sha256sums.txt openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*.chk openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
fi
aliyunpan recycle delete -all
echo y | aliyunpan logout
- name: Retry Upload Firmware - releases
if: steps.upload.outcome == 'failure' && ${{ matrix.model != 'armv8' }}
run: |
sshpass -p ${{ secrets.user_password }} ssh -o StrictHostKeyChecking=no ${{ secrets.user_name }}@${{ secrets.ftp_address }} >/dev/null 2>&1
sshpass -p ${{ secrets.user_password }} ssh ${{ secrets.user_name }}@${{ secrets.ftp_address }} "/opt/sbin/fw-upload ${{ matrix.model }}"
- name: Release OTA
uses: sbwml/FTP-Deploy-Action@master
with:
server: ${{ secrets.ftp_address }}
username: ${{ matrix.model }}
password: ${{ secrets.ftp_password }}
local-dir: ${{ env.WORKDIR }}/openwrt/ota/
dangerous-clean-slate: true