lienol [x86_64] #2
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
# | |
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
# https://github.com/P3TERX/Actions-OpenWrt | |
# Description: Build OpenWrt using GitHub Actions | |
# | |
# | |
# 定时触发开始编译(UTC时间)(5组数为 分-时-日-月-周,简单说明符号《*每》《/隔》《,分别》《-至》) | |
# schedule: | |
# - cron: 30 8 * * * 表示每天编译一次,编译时间为utc时间8点30分开始(中国时间16:30) | |
# - cron: 30 8 * * 1 表示每个星期一编译,编译时间为utc时间8点30分开始(中国时间16:30) | |
# - cron: 30 8 */9 * * 1号开始算,每隔9天编译一次,一个月可以编译4次了,编译时间为utc时间8点30分开始(中国时间16:30) | |
# - cron: 30 8 5,15,25 * * 表示每个月按你指定日期编译,现设的是5号-15号-25号编译,可设N天,编译时间为utc时间8点30分开始(中国时间16:30) | |
# - cron: 30 8 1-10 * * 这样表示每个月1至10号的每天编译一次,编译时间为UTC时间8点30分开始(中国时间16:30) | |
# | |
name: lienol [x86_64] | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
env: | |
REPO_URL: https://github.com/Lienol/openwrt | |
REPO_BRANCH: 21.02 | |
CONFIG_FILE: config/lienol_x86-64.config | |
DIY_SH: scripts/lienol.sh | |
TZ: Asia/Shanghai | |
# 开启:true | |
# 关闭:false | |
# 上传config | |
UPLOAD_CONFIG: false | |
# 上传固件GitHub | |
UPLOAD_FIRMWARE: true | |
# 上传固件WeTransfer | |
UPLOAD_WETRANSFER: true | |
# 发布固件 | |
UPLOAD_RELEASE: false | |
jobs: | |
build: | |
name: lienol [x86_64] | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: 准备结束 | |
uses: actions/checkout@main | |
- name: 初始化环境 | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo -E apt-get -qq update | |
sudo -E apt-get -qq install $(curl -fsSL git.io/depends-ubuntu-2204) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /workdir | |
sudo chown $USER:$GROUPS /workdir | |
- name: 下载源代码 | |
working-directory: /workdir | |
run: | | |
df -hT $PWD | |
git clone $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: 安装组件 | |
working-directory: ./openwrt | |
run: | | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: 自定义配置 | |
run: | | |
[ -e files ] && mv files openwrt/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
chmod +x $DIY_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_SH | |
- name: 下载DL文件 | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j$(nproc) | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: 编译固件 | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
echo "date=$(date "+%Y-%m-%d")" >> $GITHUB_ENV | |
- name: 检查空间使用情况 | |
if: (!cancelled()) | |
run: df -hT | |
- name: 整理文件 | |
id: organize | |
run: | | |
rm -rf config && mkdir config | |
find openwrt/bin/targets/ -name "*config.buildinfo*" | xargs -i mv -f {} config | |
cd openwrt/bin/targets/*/* | |
rm -rf packages && mkdir packages | |
find -name "*.buildinfo*" | xargs -i mv -f {} packages | |
find -name "*sha256sums*" | xargs -i mv -f {} packages | |
find -name "*kernel.bin*" | xargs -i mv -f {} packages | |
find -name "*kernel1.bin*" | xargs -i mv -f {} packages | |
find -name "*rootfs*" | xargs -i mv -f {} packages | |
find -name "*.manifest*" | xargs -i mv -f {} packages | |
find -name "*vmlinuz*" | xargs -i mv -f {} packages | |
rm -rf packages | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: 上传config | |
uses: actions/upload-artifact@main | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_CONFIG == 'true' && !cancelled() | |
with: | |
name: config_lienol_x86-64 | |
path: ./config | |
- name: 上传固件GitHub | |
uses: actions/upload-artifact@main | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
with: | |
name: lienol_x86-64_${{ env.date }} | |
path: ${{ env.FIRMWARE }} | |
- name: 上传固件WeTransfer | |
id: wetransfer | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled() | |
run: | | |
curl -fsSL git.io/file-transfer | sh | |
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log | |
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)" | |
echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT | |
- name: 发布链接 | |
id: tag | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
run: | | |
echo "release_tag=lienol_x86-64_$(date "+%Y-%m-%d")" >> $GITHUB_OUTPUT | |
touch release.txt | |
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: 发布固件 | |
uses: softprops/action-gh-release@master | |
if: steps.tag.outputs.status == 'success' && !cancelled() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.release_tag }} | |
body_path: release.txt | |
files: ${{ env.FIRMWARE }}/* | |
- name: 删除工作流 | |
uses: Mattraks/delete-workflow-runs@main | |
with: | |
retain_days: 1 | |
keep_minimum_runs: 3 | |
- name: 删除旧固件 | |
uses: dev-drprasad/delete-older-releases@master | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
with: | |
keep_latest: 3 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |