-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
170 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
name: Build minimal | ||
|
||
on: workflow_dispatch | ||
|
||
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 | ||
working-directory: /home/runner | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
model: | ||
- nanopi-r4s | ||
- nanopi-r5s | ||
- x86_64 | ||
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="/home/runner" >> "$GITHUB_ENV" | ||
- 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 | ||
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: Build System Setup | ||
env: | ||
DEBIAN_FRONTEND: noninteractive | ||
run: | | ||
sudo sh -c 'echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" >> /etc/apt/sources.list' | ||
sudo sh -c 'echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" >> /etc/apt/sources.list' | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential flex bison clang-17 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 '[email protected]' | ||
df -Th | ||
- name: Compile OpenWrt | ||
id: compile | ||
continue-on-error: true | ||
run: | | ||
BUILD_FAST=y ENABLE_OTA=y ENABLE_BPF=y MINIMAL_BUILD=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' | ||
run: | | ||
cd openwrt | ||
make V=s | ||
- name: Prepare Firmware Files | ||
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 | ||
fi | ||
cd .. | ||
tar zcf rom/buildinfo_${{ matrix.model }}.tar.gz info | ||
- name: Install aliyunpan & login | ||
run: | | ||
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then | ||
device_id=${{ secrets.device_id_r4s_minimal }} | ||
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then | ||
device_id=${{ secrets.device_id_r5s_minimal }} | ||
elif [ "${{ matrix.model }}" = "x86_64" ]; then | ||
device_id=${{ secrets.device_id_x86_minimal }} | ||
fi | ||
sudo curl -L ${{ secrets.aliyunpan_go }} -o /bin/aliyunpan --progress-bar | ||
sudo chmod 0755 /bin/aliyunpan | ||
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 artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.model }}-${{ matrix.tag.version }} | ||
path: ${{ env.WORKDIR }}/rom/*.gz | ||
|
||
- name: Upload Firmware - Minimal | ||
run: | | ||
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan" | ||
version=$(cat openwrt/version.txt) | ||
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then | ||
aliyunpan upload -ow info/manifest.txt openwrt/nanopi-r4s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow info/config.buildinfo openwrt/nanopi-r4s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow info/sha256sums.txt openwrt/nanopi-r4s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-r4s-ext4-sysupgrade.img.gz openwrt/nanopi-r4s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-r4s-squashfs-sysupgrade.img.gz openwrt/nanopi-r4s/minimal/${{ matrix.tag.version }}/$version/ | ||
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then | ||
aliyunpan upload -ow info/manifest.txt openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow info/config.buildinfo openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow info/sha256sums.txt openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-r5c-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-r5c-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-r5s-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-r5s-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/minimal/${{ matrix.tag.version }}/$version/ | ||
elif [ "${{ matrix.model }}" = "x86_64" ]; then | ||
aliyunpan upload -ow info/manifest.txt openwrt/x86_64/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow info/config.buildinfo openwrt/x86_64/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow info/sha256sums.txt openwrt/x86_64/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-generic-rootfs.tar.gz openwrt/x86_64/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-ext4-combined-efi.img.gz openwrt/x86_64/minimal/${{ matrix.tag.version }}/$version/ | ||
aliyunpan upload -ow rom/*-squashfs-combined-efi.img.gz openwrt/x86_64/minimal/${{ matrix.tag.version }}/$version/ | ||
fi | ||
echo y | aliyunpan logout | ||
- name: Release OTA | ||
uses: sbwml/FTP-Deploy-Action@master | ||
with: | ||
server: ${{ secrets.ftp_address }} | ||
username: ${{ secrets.ftp_minimal }} | ||
password: ${{ secrets.ftp_password }} | ||
local-dir: ${{ env.WORKDIR }}/openwrt/ota/ | ||
dangerous-clean-slate: true |