X-OpenWrt/.github/workflows/X-x86_64_X.yml

430 lines
17 KiB
YAML
Raw Normal View History

2022-09-13 07:26:34 +00:00
###########################################################
# Description: Compile OpenWrt by GitHub Actions #
# Based on: https://github.com/P3TERX/Actions-OpenWrt #
# Author: Xinb #
###########################################################
name: x86_64_X
### 以下内容请保持不变 (请修改下方的 环境变量设置)
on:
repository_dispatch:
workflow_dispatch:
inputs:
Release:
description: '是否上传到Github'
default: 'true'
SharePoint:
description: '是否上传到SharePoint'
default: 'true'
Tempoary_IP:
description: '固件 IP 地址 [可选]'
default: '192.168.2.200'
Tempoary_CONFIG:
description: '配置文件 [可选]'
default: 'x86_64-X'
Tempoary_FLAG:
description: '固件名称后缀 [可选]'
default: 'X'
### 结束
#push:
# branches:
# - master
#schedule:
# - cron: 0 8 * * 5
#watch:
# types: [started]
### 环境变量设置
env:
# 编译时调用的 [.config] 文件名称
CONFIG_FILE: x86_64-X
# 源码仓库:分支
DEFAULT_SOURCE: coolsnowwolf/lede:master
# 上传固件到 Github Releases
UPLOAD_RELEASES: true
# 上传固件到 Github Artifacts
UPLOAD_ARTIFACTS: false
# 上传 bin 文件夹到 Github Artifacts
UPLOAD_BIN_ARTIFACTS: false
# 删除无用文件以增加编译空间
DELETE_USELESS_FILES: true
# 删除早期的 workflow 任务
DELETE_OLD_WORKFLOW: true
2022-09-13 13:20:23 +00:00
# Cache 加速编译
CACHE_ACCELERATE: true
2022-09-13 07:26:34 +00:00
### 结束
jobs:
Compile:
2022-09-13 07:39:43 +00:00
runs-on: ubuntu-20.04
2022-09-13 07:26:34 +00:00
steps:
- name: Get current date & Set env
id: date
run: |
echo "::set-output name=date::$(date +'%Y-%m-%d')"
echo "Release=${{ github.event.inputs.Release }}" >> $GITHUB_ENV
echo "SharePoint=${{ github.event.inputs.SharePoint }}" >> $GITHUB_ENV
2023-12-17 16:49:45 +00:00
echo "data2=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "NOW_DATA_VERSION=v$(date +'%Y-%m-%d')" >> $GITHUB_ENV
2022-09-14 07:04:45 +00:00
if [ "${{ env.DELETE_USELESS_FILES }}" == true ]
then
2024-01-19 14:10:15 +00:00
docker rmi node:18 node:18-alpine node:16-alpine alpine:3.16 alpine:3.17 alpine:3.18 moby/buildkit:latest node:16 ubuntu:20.04 debian:9 debian:10 debian:11
2022-09-14 07:04:45 +00:00
sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
fi
2022-09-13 07:26:34 +00:00
2022-09-14 07:03:14 +00:00
- name: Maximize Build Space
uses: easimon/maximize-build-space@master
with:
2022-10-04 12:20:18 +00:00
root-reserve-mb: 3500
2022-09-14 07:03:14 +00:00
swap-size-mb: 100
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
2023-12-17 16:55:21 +00:00
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
2023-12-17 16:49:45 +00:00
- name: Set env & Echo System Info
id: date2
run: |
export NOW_DATA_VERSION=${{env.NOW_DATA_VERSION}}
export GITHUB_WORKSPACE=$GITHUB_WORKSPACE
chmod +x $GITHUB_WORKSPACE/Scripts/AutoBuild_*.sh
source $GITHUB_WORKSPACE/Scripts/AutoBuild_Getenv.sh
Get_Action_Info
2023-12-17 17:00:54 +00:00
2023-12-17 16:49:45 +00:00
2023-12-17 16:55:21 +00:00
2022-09-13 07:26:34 +00:00
2022-09-13 07:39:43 +00:00
- name: Load Custom Variables
2022-09-13 07:26:34 +00:00
run: |
echo "Free space:"
df -h
if [ -n "${{ github.event.inputs.Tempoary_CONFIG }}" ]
then
if [ -f "$GITHUB_WORKSPACE/Configs/${{ github.event.inputs.Tempoary_CONFIG }}" ]
then
CONFIG_FILE=${{ github.event.inputs.Tempoary_CONFIG }}
else
CONFIG_FILE=${{ env.CONFIG_FILE }}
fi
else
CONFIG_FILE=${{ env.CONFIG_FILE }}
fi
if [ ! -f "$GITHUB_WORKSPACE/Configs/$CONFIG_FILE" ]
then
2022-09-13 07:39:43 +00:00
echo "CONFIG_FILE: [/Config/$CONFIG_FILE] is not detected ..."
2022-09-13 07:26:34 +00:00
exit 1
else
echo "CONFIG_FILE: [/Config/$CONFIG_FILE]"
echo "CONFIG_FILE=$CONFIG_FILE" >> $GITHUB_ENV
fi
if [ -n "${{ github.event.inputs.Tempoary_IP }}" ]
then
echo "IP: [${{ github.event.inputs.Tempoary_IP }}]"
echo "Tempoary_IP=${{ github.event.inputs.Tempoary_IP }}" >> $GITHUB_ENV
fi
if [ -n "${{ github.event.inputs.Tempoary_FLAG }}" ]
then
echo "FLAG: [${{ github.event.inputs.Tempoary_FLAG }}]"
echo "Tempoary_FLAG=${{ github.event.inputs.Tempoary_FLAG }}" >> $GITHUB_ENV
fi
2022-09-13 07:39:43 +00:00
REPO_URL="https://github.com/$(cut -d \: -f 1 <<< ${{ env.DEFAULT_SOURCE }})"
REPO_BRANCH=$(cut -d \: -f 2 <<< ${{ env.DEFAULT_SOURCE }})
2022-09-13 07:26:34 +00:00
echo "REPO_URL=$REPO_URL" >> $GITHUB_ENV
echo "REPO_BRANCH=$REPO_BRANCH" >> $GITHUB_ENV
echo "Compile_Date=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "Display_Date=$(date +%Y/%m/%d)" >> $GITHUB_ENV
- name: Initialization Environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get update
sudo -E apt-get -y install build-essential cmake asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python2.7 python3 python3-pip python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf intltool mkisofs rsync
2024-03-02 15:39:40 +00:00
sudo -E apt-get -y install llvm clang
2022-09-13 07:26:34 +00:00
sudo timedatectl set-timezone "Asia/Shanghai"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: Clone Openwrt Source Code
run: |
git clone -b $REPO_BRANCH $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
2022-09-13 07:39:43 +00:00
- name: Accelerate
if: env.CACHE_ACCELERATE == 'true'
2022-09-13 07:26:34 +00:00
uses: klever1988/cachewrtbuild@main
with:
2022-09-13 07:39:43 +00:00
ccache: false
2022-09-13 07:26:34 +00:00
toolchain: true
2022-09-13 07:39:43 +00:00
skip: true
clean: false
2022-09-13 07:26:34 +00:00
prefix: ${{ github.workspace }}/openwrt
- name: Feeds install
run: |
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
./scripts/feeds uninstall luci-theme-argon
2024-03-02 07:57:26 +00:00
# Update golang to 1.22 for xray-core build
rm -rf feeds/packages/lang/golang
git clone https://github.com/sbwml/packages_lang_golang -b 22.x feeds/packages/lang/golang
2022-09-13 07:39:43 +00:00
# sed -i 's/^\s*$[(]call\sEnsureVendoredVersion/#&/' $GITHUB_WORKSPACE/openwrt/feeds/packages/utils/dockerd/Makefile
2022-09-13 07:26:34 +00:00
#fix dockerd bug
2022-09-13 07:39:43 +00:00
- name: Run Diy Scripts
2022-09-13 07:26:34 +00:00
run: |
chmod +x Scripts/AutoBuild_*.sh
cd openwrt
2022-09-13 07:39:43 +00:00
if [ "${{ env.CACHE_ACCELERATE }}" == true ]
then
echo -e "\nCONFIG_DEVEL=y\nCONFIG_CCACHE=y\n" >> $GITHUB_WORKSPACE/Configs/$CONFIG_FILE
fi
cp $GITHUB_WORKSPACE/Configs/$CONFIG_FILE .config
2022-09-13 07:26:34 +00:00
source $GITHUB_WORKSPACE/Scripts/AutoBuild_DiyScript.sh
source $GITHUB_WORKSPACE/Scripts/AutoBuild_Function.sh
2022-09-13 07:39:43 +00:00
make defconfig
2022-09-13 07:26:34 +00:00
Firmware_Diy_Before
2022-09-13 07:39:43 +00:00
rm -f .config && cp $GITHUB_WORKSPACE/Configs/$CONFIG_FILE .config
2022-09-13 07:26:34 +00:00
Firmware_Diy_Main
Firmware_Diy
2022-09-13 07:39:43 +00:00
Firmware_Diy_Other
2022-09-13 07:26:34 +00:00
2022-09-13 07:39:43 +00:00
- name: Pre-download Libraries
2022-09-13 07:26:34 +00:00
run: |
cd openwrt
2022-09-13 07:39:43 +00:00
./scripts/feeds install -a
2022-09-13 07:26:34 +00:00
make defconfig
2024-02-11 17:34:35 +00:00
make download -j32
2022-09-13 07:39:43 +00:00
- name: Build OpenWrt
run: |
cd openwrt
2023-10-29 14:49:25 +00:00
rm package/feeds/packages/adguardhome -rf
rm feeds/packages/net/adguardhome -rf
ln -s ../../../package/other/AutoBuild-Packages/adguardhome package/feeds/packages/adguardhome
2024-03-03 12:18:16 +00:00
# 2024.03.03 mosdns build fail by golang 1.22
sed -i 's/CGO_ENABLED=0/CGO_ENABLED=1/g' feeds/packages/net/mosdns/Makefile
2024-03-03 15:12:51 +00:00
make -j1 V=s
2022-09-13 10:23:32 +00:00
[ "$?" == 0 ] && echo "Result=true" >> $GITHUB_ENV || echo "Result=false" >> $GITHUB_ENV
2022-09-13 07:26:34 +00:00
2024-03-03 11:26:39 +00:00
- name: Check Build Update
run: |
export NOW_DATA_VERSION=${{env.NOW_DATA_VERSION}}
export GITHUB_WORKSPACE=$GITHUB_WORKSPACE
bash $GITHUB_WORKSPACE/Scripts/AutoBuild_Upcheck.sh ${{env.Tempoary_FLAG}}
- name: Upload Package Version to Github Release
uses: svenstaro/upload-release-action@v2
if: env.Release=='true' && env.UPLOAD_RELEASES == 'true' && env.Result == 'true' && !cancelled()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{env.Tempoary_FLAG}}_build_pkg_ver.log
file_glob: true
tag: v${{ steps.date.outputs.date }}
overwrite: true
- name: Upload Package Update to Github Release
uses: svenstaro/upload-release-action@v2
if: env.Release=='true' && env.UPLOAD_RELEASES == 'true' && env.Result == 'true' && !cancelled()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{env.Tempoary_FLAG}}_build_pkg_up.log
file_glob: true
tag: v${{ steps.date.outputs.date }}
overwrite: true
2022-09-13 07:26:34 +00:00
- name: Process Firmware
if: env.Result == 'true' && !cancelled()
run: |
cd openwrt
source $GITHUB_WORKSPACE/Scripts/AutoBuild_Function.sh
Firmware_Diy_End
- name: Upload Firmware to Artifacts
uses: actions/upload-artifact@main
if: env.UPLOAD_ARTIFACTS == 'true' && env.Result == 'true' && !cancelled()
with:
name: ${{ env.CONFIG_FILE }}_firmware_${{ env.Compile_Date }}
path: openwrt/bin/Firmware
- name: Upload bin to Artifacts
uses: actions/upload-artifact@main
if: env.UPLOAD_BIN_ARTIFACTS == 'true' && env.Result == 'true' && !cancelled()
with:
name: ${{ env.CONFIG_FILE }}_bin_${{ env.Compile_Date }}
path: openwrt/bin
- name: Download Github Release API
if: env.UPLOAD_RELEASES == 'true' && env.Result == 'true' && !cancelled()
run: |
wget https://api.github.com/repos/${{github.repository}}/releases/tags/AutoUpdate -O API
SP_UEFI_IMG_GZ=openwrt/bin/Firmware/AutoBuild-*-UEFI-*.img.gz
SP_UEFI_IMG_GZ=$(echo $SP_UEFI_IMG_GZ)
SP_UEFI_IMG_GZ=${SP_UEFI_IMG_GZ##*/}
SP_UEFI_VMDK=openwrt/bin/Firmware/AutoBuild-*-UEFI-*.vmdk
SP_UEFI_VMDK=$(echo $SP_UEFI_VMDK)
SP_UEFI_VMDK=${SP_UEFI_VMDK##*/}
SP_UEFI_VDI=openwrt/bin/Firmware/AutoBuild-*-UEFI-*.vdi
SP_UEFI_VDI=$(echo $SP_UEFI_VDI)
SP_UEFI_VDI=${SP_UEFI_VDI##*/}
SP_UEFI_VHDX=openwrt/bin/Firmware/AutoBuild-*-UEFI-*.vhdx
SP_UEFI_VHDX=$(echo $SP_UEFI_VHDX)
SP_UEFI_VHDX=${SP_UEFI_VHDX##*/}
SP_LEGACY_IMG_GZ=openwrt/bin/Firmware/AutoBuild-*-BIOS-*.img.gz
SP_LEGACY_IMG_GZ=$(echo $SP_LEGACY_IMG_GZ)
SP_LEGACY_IMG_GZ=${SP_LEGACY_IMG_GZ##*/}
SP_LEGACY_VMDK=openwrt/bin/Firmware/AutoBuild-*-BIOS-*.vmdk
SP_LEGACY_VMDK=$(echo $SP_LEGACY_VMDK)
SP_LEGACY_VMDK=${SP_LEGACY_VMDK##*/}
SP_LEGACY_VDI=openwrt/bin/Firmware/AutoBuild-*-BIOS-*.vdi
SP_LEGACY_VDI=$(echo $SP_LEGACY_VDI)
SP_LEGACY_VDI=${SP_LEGACY_VDI##*/}
SP_LEGACY_VHDX=openwrt/bin/Firmware/AutoBuild-*-BIOS-*.vhdx
SP_LEGACY_VHDX=$(echo $SP_LEGACY_VHDX)
SP_LEGACY_VHDX=${SP_LEGACY_VHDX##*/}
echo SP_UEFI_IMG_GZ=$(echo $SP_UEFI_IMG_GZ) >> $GITHUB_ENV
echo SP_UEFI_VMDK=$(echo $SP_UEFI_VMDK) >> $GITHUB_ENV
echo SP_UEFI_VDI=$(echo $SP_UEFI_VDI) >> $GITHUB_ENV
echo SP_UEFI_VHDX=$(echo $SP_UEFI_VHDX) >> $GITHUB_ENV
echo SP_LEGACY_IMG_GZ=$(echo $SP_LEGACY_IMG_GZ) >> $GITHUB_ENV
echo SP_LEGACY_VMDK=$(echo $SP_LEGACY_VMDK) >> $GITHUB_ENV
echo SP_LEGACY_VDI=$(echo $SP_LEGACY_VDI) >> $GITHUB_ENV
echo SP_LEGACY_VHDX=$(echo $SP_LEGACY_VHDX) >> $GITHUB_ENV
- name: 1 Upload SP_UEFI_IMG_GZ to SharePoint
uses: su-dont/share-point-uploader@v2.1
if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
with:
2024-06-04 17:27:04 +00:00
sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
sp_username: ${{ secrets.USERNAME }}
sp_password: ${{ secrets.PASSWORD }}
sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
sp_file_name: ${{ env.SP_UEFI_IMG_GZ }}
file: openwrt/bin/Firmware/${{ env.SP_UEFI_IMG_GZ }}
- name: 2 Upload SP_UEFI_VMDK to SharePoint
uses: su-dont/share-point-uploader@v2.1
if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
with:
2024-06-04 17:27:04 +00:00
sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
sp_username: ${{ secrets.USERNAME }}
sp_password: ${{ secrets.PASSWORD }}
sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
sp_file_name: ${{ env.SP_UEFI_VMDK }}
file: openwrt/bin/Firmware/${{ env.SP_UEFI_VMDK }}
# - name: 3 Upload SP_UEFI_VDI to SharePoint
# uses: su-dont/share-point-uploader@v2.1
# if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
# with:
2024-06-04 17:27:04 +00:00
# sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
# sp_username: ${{ secrets.USERNAME }}
# sp_password: ${{ secrets.PASSWORD }}
# sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
# sp_file_name: ${{ env.SP_UEFI_VDI }}
# file: openwrt/bin/Firmware/${{ env.SP_UEFI_VDI }}
# - name: 4 Upload SP_UEFI_VHDX to SharePoint
# uses: su-dont/share-point-uploader@v2.1
# if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
# with:
2024-06-04 17:27:04 +00:00
# sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
# sp_username: ${{ secrets.USERNAME }}
# sp_password: ${{ secrets.PASSWORD }}
# sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
# sp_file_name: ${{ env.SP_UEFI_VHDX }}
# file: openwrt/bin/Firmware/${{ env.SP_UEFI_VHDX }}
- name: 5 Upload SP_LEGACY_IMG_GZ to SharePoint
uses: su-dont/share-point-uploader@v2.1
if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
with:
2024-06-04 17:27:04 +00:00
sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
sp_username: ${{ secrets.USERNAME }}
sp_password: ${{ secrets.PASSWORD }}
sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
sp_file_name: ${{ env.SP_LEGACY_IMG_GZ }}
file: openwrt/bin/Firmware/${{ env.SP_LEGACY_IMG_GZ }}
- name: 6 Upload SP_LEGACY_VMDK to SharePoint
uses: su-dont/share-point-uploader@v2.1
if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
with:
2024-06-04 17:27:04 +00:00
sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
sp_username: ${{ secrets.USERNAME }}
sp_password: ${{ secrets.PASSWORD }}
sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
sp_file_name: ${{ env.SP_LEGACY_VMDK }}
file: openwrt/bin/Firmware/${{ env.SP_LEGACY_VMDK }}
# - name: 7 Upload SP_LEGACY_VDI to SharePoint
# uses: su-dont/share-point-uploader@v2.1
# if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
# with:
2024-06-04 17:27:04 +00:00
# sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
# sp_username: ${{ secrets.USERNAME }}
# sp_password: ${{ secrets.PASSWORD }}
# sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
# sp_file_name: ${{ env.SP_LEGACY_VDI }}
# file: openwrt/bin/Firmware/${{ env.SP_LEGACY_VDI }}
# - name: 8 Upload SP_LEGACY_VHDX to SharePoint
# uses: su-dont/share-point-uploader@v2.1
# if: env.SharePoint=='true' && !cancelled() && env.Result == 'true'
# with:
2024-06-04 17:27:04 +00:00
# sp_url: https://xinbyte.sharepoint.com/:f:/r/sites/OpenWrt
2022-09-13 07:26:34 +00:00
# sp_username: ${{ secrets.USERNAME }}
# sp_password: ${{ secrets.PASSWORD }}
# sp_folder: /Shared Documents/OpenWrt/${{ steps.date.outputs.date }}
# sp_file_name: ${{ env.SP_LEGACY_VHDX }}
# file: openwrt/bin/Firmware/${{ env.SP_LEGACY_VHDX }}
- name: Delete VM Disk File
if: env.Release=='true' && env.UPLOAD_RELEASES == 'true' && env.Result == 'true' && !cancelled()
run: |
rm openwrt/bin/Firmware/AutoBuild-*.v* -rf
- name: Upload Firmware to Github Release
uses: svenstaro/upload-release-action@v2
if: env.Release=='true' && env.UPLOAD_RELEASES == 'true' && env.Result == 'true' && !cancelled()
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: openwrt/bin/Firmware/*
file_glob: true
tag: AutoUpdate
overwrite: true
- name: Upload API to Github Release
if: env.Release=='true' && env.UPLOAD_RELEASES == 'true' && env.Result == 'true' && !cancelled()
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./API
file_glob: true
tag: AutoUpdate
overwrite: true
- name: Delete old Workflow Runs
uses: GitRML/delete-workflow-runs@main
if: env.DELETE_OLD_WORKFLOW == 'true' && !cancelled()
with:
retain_days: 1
keep_minimum_runs: 3