Skip to content

sunxi_cortexa53

sunxi_cortexa53 #5914

#=================================================
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: P3TERX
# Blog: https://p3terx.com
#=================================================
name: Build OpenWrt
on:
repository_dispatch:
env:
REPO_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}
PPPOE_USERNAME: ${{ secrets.PPPOE_USERNAME }}
PPPOE_PASSWD: ${{ secrets.PPPOE_PASSWD }}
SCKEY: ${{ secrets.SCKEY }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOCKER_ID: ${{ secrets.DOCKER_ID }}
DOCKER_PASSWD: ${{ secrets.DOCKER_PASSWD }}
TZ: Asia/Shanghai
jobs:
build:
runs-on: Ubuntu-22.04
name: Build ${{matrix.target}}
strategy:
fail-fast: false
matrix:
target: ["${{ github.event.client_payload.target }}"]
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
# - name: Set up secret file
# run: |
# echo ${{ secrets.TELEGRAM_CHAT_ID }} | sed 's/./& /g'
# echo ${{ secrets.TELEGRAM_TOKEN }} | sed 's/./& /g'
- name: Load Settings.ini
run: |
echo ${{matrix.target}}
source "${GITHUB_WORKSPACE}/devices/common/settings.ini"
if [ -f "devices/${{matrix.target}}/settings.ini" ]; then
source "${GITHUB_WORKSPACE}/devices/${{matrix.target}}/settings.ini"
fi
echo "REPO_URL=${REPO_URL}" >> $GITHUB_ENV
echo "REPO_BRANCH=${REPO_BRANCH}" >> $GITHUB_ENV
echo "CONFIG_FILE=${CONFIG_FILE}" >> $GITHUB_ENV
echo "DIY_SH=${DIY_SH}" >> $GITHUB_ENV
echo "FREE_UP_DISK=${FREE_UP_DISK}" >> $GITHUB_ENV
echo "UPLOAD_BIN_DIR_FOR_ARTIFACT=${UPLOAD_BIN_DIR_FOR_ARTIFACT}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_FOR_ARTIFACT=${UPLOAD_FIRMWARE_FOR_ARTIFACT}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_FOR_RELEASE=${UPLOAD_FIRMWARE_FOR_RELEASE}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_TO_COWTRANSFER=${UPLOAD_FIRMWARE_TO_COWTRANSFER}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_TO_WETRANSFER=${UPLOAD_FIRMWARE_TO_WETRANSFER}" >> $GITHUB_ENV
sed -i "1a REPO_TOKEN=${{ secrets.TOKEN_KIDDIN9 }}" ${GITHUB_WORKSPACE}/devices/common/diy.sh
sed -i "1a TARGET=${{matrix.target}}" ${GITHUB_WORKSPACE}/devices/common/diy.sh
if [ ${{matrix.target}} == "x86_64" ]; then
echo "ARCH=linux/amd64" >> $GITHUB_ENV
echo "MTARGET=x86_64" >> $GITHUB_ENV
elif [ ${{matrix.target}} == "x86_generic" ]; then
echo "ARCH=linux/amd32" >> $GITHUB_ENV
echo "MTARGET=x86_generic" >> $GITHUB_ENV
elif [[ ${{matrix.target}} =~ (armsr_armv8|qualcommax_ipq807x|mediatek_mt7622|mediatek_mt7981|mediatek_filogic|bcm27xx_bcm2710|qualcommax_ipq60xx|bcm4908_generic|sunxi_cortexa53) ]]; then
echo "MTARGET=aarch64_cortex-a53" >> $GITHUB_ENV
elif [[ ${{matrix.target}} =~ (ramips_mt7621|ramips_mt7620|ramips_mt76x8) ]]; then
echo "MTARGET=mipsel_24kc" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "ath79_nand" ]]; then
echo "MTARGET=mips_24kc" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "ipq50xx_arm" ]]; then
echo "MTARGET=arm_cortex-a7" >> $GITHUB_ENV
elif [[ ${{matrix.target}} =~ (ipq40xx_generic|bcm27xx_bcm2709|sunxi_cortexa7) ]]; then
echo "MTARGET=arm_cortex-a7_neon-vfpv4" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "amlogic_meson8b" ]]; then
echo "MTARGET=arm_cortex-a5_vfpv4" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "bcm53xx" ]]; then
echo "MTARGET=arm_cortex-a9" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "mvebu_cortexa9" ]]; then
echo "MTARGET=arm_cortex-a9_vfpv3-d16" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "ipq806x_generic" ]]; then
echo "MTARGET=arm_cortex-a15_neon-vfpv4" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == "bcm27xx_bcm2708" ]]; then
echo "MTARGET=arm_arm1176jzf-s_vfp" >> $GITHUB_ENV
else
echo "ARCH=linux/arm64" >> $GITHUB_ENV
if [[ ${{matrix.target}} == "bcm27xx_bcm2711" ]]; then
echo "MTARGET=aarch64_cortex-a72" >> $GITHUB_ENV
elif [[ ${{matrix.target}} == rockchip* ]]; then
echo "MTARGET=aarch64_generic" >> $GITHUB_ENV
fi
fi
- name: Trigger Packages Update
continue-on-error: true
run: |
status=$(curl -H "Authorization: token ${{ secrets.TOKEN_KIDDIN9 }} -s "https://api.github.com/repos/kiddin9/openwrt-packages/actions/runs" | jq -r '.workflow_runs[0].status')
if [[ "$status" == "completed" ]]; then
curl -X POST https://api.github.com/repos/kiddin9/openwrt-packages/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.TOKEN_KIDDIN9 }}" \
--data '{"event_type": "update"}'
fi
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential clang llvm flex g++ gawk gcc-multilib gettext \
git libncurses5-dev libssl-dev python3-distutils python3-pyelftools python3-setuptools \
libpython3-dev rsync unzip zlib1g-dev swig aria2 jq subversion qemu-utils ccache rename \
libelf-dev device-tree-compiler libgnutls28-dev coccinelle libgmp3-dev libmpc-dev libfuse-dev
sudo -E apt-get -qq purge azure-cli ghc* zulu* firefox powershell openjdk* dotnet* google* mysql* php* android*
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Get current date
id: date
run: |
echo "date=$(date +'%m/%d_%Y_%H/%M')" >> $GITHUB_ENV
echo "date2=$(date +'%m/%d %Y')" >> $GITHUB_ENV
VERSION="$(echo "${{github.event.action}}" | grep -Eo " [0-9.]+" | sed -e 's/ //')" || true
[ "$VERSION" ] && echo "VERSION=$VERSION" >> $GITHUB_ENV || echo "VERSION=$(date +'%m.%d')" >> $GITHUB_ENV
- name: Clone source code
run: |
REPO_BRANCH="$((curl -gs -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${{ secrets.TOKEN_KIDDIN9 }}" \
-X POST -d '{ "query": "query {repository(owner: \"openwrt\", name: \"openwrt\") {refs(refPrefix: \"refs/tags/\", last: 4, orderBy: {field: TAG_COMMIT_DATE, direction: ASC}) {edges {node {name}}}}}"}' https://api.github.com/graphql) | jq -r '.data.repository.refs.edges[].node.name' | grep v23 | tail -n 1)"
REPO_BRANCH="openwrt-23.05"
#echo "CONFIG_VERSION_REPO=\"https://dl.openwrt.ai/`echo $REPO_BRANCH | cut -d . -f 1,2 | sed -e 's/^v//'`\"">>devices/common/.config
echo "CONFIG_VERSION_REPO=\"https://dl.openwrt.ai/23.05\"">>devices/common/.config
if [[ ! "${{ env.REPO_BRANCH }}" && "$REPO_URL" == "https://github.com/openwrt/openwrt" ]]; then
git clone $REPO_URL -b $REPO_BRANCH openwrt
elif [[ ! "${{ env.REPO_BRANCH }}" ]]; then
git clone $REPO_URL openwrt
else
git clone $REPO_URL -b ${{ env.REPO_BRANCH }} openwrt
echo "git clone $REPO_URL -b ${{ env.REPO_BRANCH }} openwrt"
fi
- name: Free up disk space
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo mkdir -p -m 777 /mnt/openwrt/dl /mnt/openwrt/staging_dir /mnt/openwrt/build_dir
ln -sf /mnt/openwrt/dl openwrt/dl
ln -sf /mnt/openwrt/staging_dir openwrt/staging_dir
ln -sf /mnt/openwrt/build_dir openwrt/build_dir
- name: Load custom configuration
run: |
function git_clone_path() {
branch="$1" rurl="$2" localdir="gitemp" mv="$3"
[[ "$mv" != "mv" ]] && shift 2 || shift 3
git clone -b $branch --depth 1 --filter=blob:none --sparse $rurl $localdir
if [ "$?" != 0 ]; then
echo "error on $rurl"
return 0
fi
cd $localdir
git sparse-checkout init --cone
git sparse-checkout set $@
[[ "$mv" != "mv" ]] && cp -rn ./* ../ || mv -n $@/* ../$@/
cd ..
rm -rf gitemp
}
export -f git_clone_path
cp -rf devices/common/. openwrt/
cp -rf devices/${{matrix.target}}/. openwrt/
cp -rf devices openwrt/
cd openwrt
chmod +x devices/common/$DIY_SH
/bin/bash "devices/common/$DIY_SH"
cp -f devices/common/$CONFIG_FILE .config
if [ -f "devices/${{matrix.target}}/$CONFIG_FILE" ]; then
echo >> .config
cat devices/${{matrix.target}}/$CONFIG_FILE >> .config
fi
if [ -f "devices/${{matrix.target}}/$DIY_SH" ]; then
chmod +x devices/${{matrix.target}}/$DIY_SH
echo "/bin/bash devices/${{matrix.target}}/$DIY_SH"
/bin/bash "devices/${{matrix.target}}/$DIY_SH"
fi
cp -Rf ./diy/* ./ || true
- name: Apply patches
run: |
cd openwrt
cp -rn devices/common/patches devices/${{matrix.target}}/
if [ -n "$(ls -A devices/${{matrix.target}}/*.bin.patch 2>/dev/null)" ]; then
git apply devices/${{matrix.target}}/patches/*.bin.patch
fi
find "devices/${{matrix.target}}/patches" -maxdepth 1 -type f -name '*.revert.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -R -B --merge -p1 -E --forward"
find "devices/${{matrix.target}}/patches" -maxdepth 1 -type f -name '*.patch' ! -name '*.revert.patch' ! -name '*.bin.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -B --merge -p1 -E --forward"
sed -i '$a \
CONFIG_CPU_FREQ_GOV_POWERSAVE=y \
CONFIG_CPU_FREQ_GOV_USERSPACE=y \
CONFIG_CPU_FREQ_GOV_ONDEMAND=y \
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y \
CONFIG_CRYPTO_CHACHA20_NEON=y \
CONFIG_CRYPTO_CHACHA20POLY1305=y \
CONFIG_FAT_DEFAULT_IOCHARSET="utf8" \
' `find target/linux -path "target/linux/*/config-*"`
- name: Defconfig
run: |
cd openwrt
make defconfig
if [[ ! "${{matrix.target}}" =~ (armsr_armv8|bcm27xx_*|rockchip_*|sunxi_*|x86_*) ]]; then
sed -n '/# Wireless Drivers/,/# end of Wireless Drivers/p' .config | sed -e 's/=m/=n/' >>.config
sed -i "s/\(kmod-qca.*\)=m/\1=n/" .config
make defconfig
fi
cat .config
- name: Download package
id: package
run: |
cd openwrt
make download -j$(($(nproc)+1)) &
sleep 5
- name: Cache
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
mixkey: ${{ matrix.target }}
clean: ${{ contains(github.event.action, 'nocache') }}
prefix: ${{ github.workspace }}/openwrt
- name: Check space usage
run: |
shopt -s extglob
cd openwrt
if [[ -f staging_dir/*${{ env.MTARGET }}*/bin ]]; then
rm -rf staging_dir/!(*${{ env.MTARGET }}*|host|hostpkg) build_dir/!(*${{ env.MTARGET }}*|host|hostpkg)
fi
df -hT
- name: SSH connection to Actions
uses: kiddin9/debugger-action@master
if: contains(github.event.action, 'ssh')
- name: Compile the firmware
id: compile
run: |
shopt -s extglob
cd openwrt
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make V=s &>build.log || (tail -50 build.log; curl -k --data chat_id="${{ env.TELEGRAM_CHAT_ID }}" --data "text=❌ OpenWrt ${{ env.VERSION }} ${{matrix.target}} 编译失败 😂" "https://api.telegram.org/bot${{ env.TELEGRAM_TOKEN }}/sendMessage";df -hT;exit 1)
sed -i "s/# CONFIG_IB is not set/CONFIG_IB=y/" .config
rm -rf staging_dir/toolchain-*/bin/*openwrt-linux-musl-lto-dump
rm -rf staging_dir/toolchain-*/initial
df -hT
- name: Organize files
id: organize
continue-on-error: true
run: |
shopt -s extglob
mkdir -p firmware/${{matrix.target}}
cp -rf openwrt/bin/targets/*/*/*{combined,sysupgrade}* ./firmware/${{matrix.target}}/ || true
cd openwrt/bin/targets/*/*/
cp $GITHUB_WORKSPACE/openwrt/.config ${{matrix.target}}.config || true
cp $GITHUB_WORKSPACE/openwrt/build_dir/target-*/linux-*/linux-*/.config ${{matrix.target}}_kernel.config || true
cd -
rename -v "s/openwrt-/${{ env.VERSION }}-openwrt-/" ./firmware/*/* || true
Emoji=("🎉" "🤞" "✨" "🎁" "🎈" "🎄" "🎨" "💋" "🍓" "🍕" "🍉" "💐" "🌴" "🚀" "🛸" "🗽" "⛅" "🌈" "🔥" "⛄" "🐶" "🏅" "🦄" "🐤")
echo "EMOJI=${Emoji[$[$RANDOM % ${#Emoji[@]}]]}" >> $GITHUB_ENV
if [ ${{matrix.target}} == "x86_64" ]; then
echo "DOCKERTAG=${{ secrets.DOCKER_ID }}/openwrt-nginx:latest" >> $GITHUB_ENV
echo "NOTICE=请分配不少于1G的存储容量" >> $GITHUB_ENV
fi
- name: Deploy imagebuilder to server
uses: easingthemes/ssh-deploy@main
continue-on-error: true
if: env.SSH_PRIVATE_KEY && ! contains(github.event.action, 'noser')
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-avzr"
SOURCE: openwrt/bin/targets
REMOTE_HOST: ${{ secrets.SERVER_HOST }}
REMOTE_PORT: ${{ secrets.SERVER_PORT }}
REMOTE_USER: root
TARGET: "/www/wwwroot/dl.openwrt.ai/releases/tmp/"
- name: Upload firmware for artifact
uses: actions/upload-artifact@main
if: env.UPLOAD_FIRMWARE_FOR_ARTIFACT == 'true'
with:
name: ${{ env.VERSION }}_${{matrix.target}}
path: |
openwrt/bin/targets/
- name: Create release
id: create_release
if: env.REPO_TOKEN && env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true'
continue-on-error: true
run: |
echo -e "墙内加速下载 🚀:\n" >> release.txt
echo -e "[腾讯云] (https://dl.openwrt.ai/firmware/${{matrix.target}}/ ☁)\n" >> release.txt
[ ${{ env.WETRANS }} ] && echo -e "[WeTransfer] (${{ env.WETRANS }} 🗽)\n" >> release.txt
[ ${{ env.COWURL }} ] && echo -e "[奶牛上传] (${{ env.COWURL }} 🐮)\n" >> release.txt
[ ${{ env.NOTICE }} ] && echo -e "${{ env.NOTICE }}" >> release.txt || true
- name: Upload firmware for release
uses: softprops/action-gh-release@master
continue-on-error: true
if: env.REPO_TOKEN && env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true'
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}
with:
files: "${{ env.FIRMWARE }}/*"
name: ${{ env.date2 }} ${{matrix.target}} ${{ env.EMOJI }}
tag_name: ${{ env.date }}_${{matrix.target}}
body_path: release.txt
- name: WeChat notification
continue-on-error: true
if: env.SCKEY
run: |
# [ steps.compile.outputs.status == 'success' ] && curl https://sctapi.ftqq.com/${{ secrets.SCKEY }}.send?text=🎉OpenWrt_${{ env.VERSION }}_${{matrix.target}}编译完成😋|| curl https://sctapi.ftqq.com/${{ secrets.SCKEY }}.send?text=❌OpenWrt_${{ env.VERSION }}_${{matrix.target}}编译失败😂
- name: Telegram notification
if: env.TELEGRAM_TOKEN && ! contains(github.event.action, 'notg')
continue-on-error: true
run: |
curl -k --data chat_id="${{ env.TELEGRAM_CHAT_ID }}" --data "text=🎉 OpenWrt ${{ env.VERSION }} ${{matrix.target}} 编译成功 😋 https://dl.openwrt.ai/firmware/${{matrix.target}}/ ${{ env.COWURL }} ${{ env.WETRANS }} 🚀" "https://api.telegram.org/bot${{ env.TELEGRAM_TOKEN }}/sendMessage"
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
continue-on-error: true
with:
retain_days: 100
keep_minimum_runs: 0
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
continue-on-error: true
if: env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true' && !cancelled()
with:
keep_latest: 15
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}