Source Code Update #823
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
#========================================================================================================== | |
# Thanks: | |
# https://github.com/P3TERX/Actions-OpenWrt/blob/main/.github/workflows/build-openwrt.yml | |
# https://github.com/kiddin9/OpenWrt_x86-r2s-r4s/blob/master/.github/workflows/Openwrt-AutoBuild.yml | |
# https://github.com/281677160/build-actions/blob/main/.github/workflows/build-openwrt.yml | |
# https://github.com/gd0772/AutoBuild-OpenWrt/blob/main/.github/workflows/compile-openwrt.yml | |
# https://github.com/yfdoor/OpenWrt/tree/master/.github/workflows | |
#========================================================================================================= | |
name: Compile OpenWrt | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
env: | |
Github: https://github.com/${{github.repository}} | |
Author: ${{github.actor}} | |
Apidz: ${{github.repository}} | |
Run_number: ${{github.run_number}} | |
Run_workflow: ${{github.workflow}} | |
REPO_TOKEN: ${{ secrets.REPO_TOKEN }} | |
TZ: Asia/Shanghai | |
jobs: | |
CompileOpenWrt: | |
runs-on: ubuntu-20.04 | |
if: github.event.repository.owner.id == github.event.sender.id | |
name: Compile "${{matrix.target}}" | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [Lede_source] | |
# [Lede_source,Lienol_source,Mortal_source] | |
steps: | |
- name: Checkout Github Workspace | |
uses: actions/checkout@v4 | |
- name: Assign Environment Variables | |
run: | | |
source "${GITHUB_WORKSPACE}/cus_script/ENV.ini" | |
echo "REPO_URL=${REPO_URL}" >> $GITHUB_ENV | |
echo "REPO_BRANCH=${REPO_BRANCH}" >> $GITHUB_ENV | |
echo "COMPILE_INFORMATION=${COMPILE_INFORMATION}" >> $GITHUB_ENV | |
echo "UPLOAD_CONFIG=${UPLOAD_CONFIG}" >> $GITHUB_ENV | |
echo "UPLOAD_BIN_DIR=${UPLOAD_BIN_DIR}" >> $GITHUB_ENV | |
echo "UPLOAD_Artifacts=${UPLOAD_Artifacts}" >> $GITHUB_ENV | |
echo "UPLOAD_COWTRANSFER=${UPLOAD_COWTRANSFER}" >> $GITHUB_ENV | |
echo "UPLOAD_WETRANSFER=${UPLOAD_WETRANSFER}" >> $GITHUB_ENV | |
echo "UPLOAD_RELEASE=${UPLOAD_RELEASE}" >> $GITHUB_ENV | |
echo "CACHE_BUILD=${CACHE_BUILD}" >> $GITHUB_ENV | |
echo "CangKu=${Apidz##*/}" >> $GITHUB_ENV | |
echo "Modelfile=${{matrix.target}}" >> $GITHUB_ENV | |
if [[ "${REPO_BRANCH}" == "master" ]]; then | |
echo "ZZZ=package/lean/default-settings/files/zzz-default-settings" >> $GITHUB_ENV | |
echo "CODE=Lede" >> $GITHUB_ENV | |
echo "OpenWrt_name=18.06" >> $GITHUB_ENV | |
elif [[ "${REPO_BRANCH}" == "19.07" ]]; then | |
echo "ZZZ=package/default-settings/files/zzz-default-settings" >> $GITHUB_ENV | |
echo "CODE=Lienol" >> $GITHUB_ENV | |
echo "OpenWrt_name=19.07" >> $GITHUB_ENV | |
elif [[ "${REPO_BRANCH}" == "openwrt-18.06" ]]; then | |
echo "ZZZ=package/emortal/default-settings/files/zzz-default-settings" >> $GITHUB_ENV | |
echo "CODE=Mortal" >> $GITHUB_ENV | |
echo "OpenWrt_name=18.06" >> $GITHUB_ENV | |
fi | |
echo "NETIP=package/base-files/files/etc/networkip" >> $GITHUB_ENV | |
echo "DELETE=package/base-files/files/etc/deletefile" >> $GITHUB_ENV | |
- name: Deploy Environment | |
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-2004) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /${{matrix.target}} | |
sudo chown $USER:$GROUPS /${{matrix.target}} | |
- name: Clone Source Code | |
run: | | |
git clone -b "$REPO_BRANCH" --single-branch "$REPO_URL" openwrt | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
cd openwrt | |
./scripts/feeds update -a > /dev/null 2>&1 | |
echo "Home=${GITHUB_WORKSPACE}/openwrt" >> $GITHUB_ENV | |
#echo "PATH_Custom=${GITHUB_WORKSPACE}/custom_files" >> $GITHUB_ENV | |
echo "PATH_Comscript=${GITHUB_WORKSPACE}/com_script" >> $GITHUB_ENV | |
echo "PATH_Cusscript=${GITHUB_WORKSPACE}/cus_script" >> $GITHUB_ENV | |
- name: Feed Add Update Install | |
run: | | |
cd openwrt | |
chmod -R +x "${PATH_Cusscript}" | |
source ${PATH_Cusscript}/Add_a_third_party_feed.sh | |
#source ${PATH_Cusscript}/Add_third_party_package.sh | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: Load Custom Configuration | |
run: | | |
echo "Compile_Date=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
cp -Rf `find ./ -maxdepth 1 -type d ! -path './openwrt' ! -path './'` openwrt | |
cd openwrt | |
chmod -R +x "${PATH_Cusscript}" | |
source ${PATH_Cusscript}/Delete_original_code.sh | |
source ${PATH_Cusscript}/Modify_default_config.sh | |
source ${PATH_Cusscript}/Device_config.sh | |
source ${PATH_Cusscript}/Package_config.sh | |
source ${PATH_Cusscript}/Adjust_menu_position.sh | |
#source ${PATH_Cusscript}/Rename_plug-in.sh | |
- name: Generate Configuration | |
run: | | |
cd openwrt | |
source "${PATH_Comscript}/Plugin_Conflict.sh" > /dev/null 2>&1 | |
make defconfig > /dev/null 2>&1 | |
./scripts/diffconfig.sh > ${GITHUB_WORKSPACE}/config.txt | |
echo "TARGET_BOARD=$(awk -F '[="]+' '/TARGET_BOARD/{print $2}' .config)" >> $GITHUB_ENV | |
echo "TARGET_SUBTARGET=$(awk -F '[="]+' '/TARGET_SUBTARGET/{print $2}' .config)" >> $GITHUB_ENV | |
if [ `grep -c "CONFIG_TARGET_x86_64=y" .config` -eq '1' ]; then | |
echo "TARGET_PROFILE=x86-64" >> $GITHUB_ENV | |
elif [ `grep -c "CONFIG_TARGET_x86_generic=y" .config` -eq '1' ]; then | |
echo "TARGET_PROFILE=x86-32" >> $GITHUB_ENV | |
elif [ `grep -c "CONFIG_TARGET.*DEVICE.*=y" .config` -eq '1' ]; then | |
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
[ -s DEVICE_NAME ] && echo "TARGET_PROFILE=$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
else | |
echo "TARGET_PROFILE=armvirt" >> $GITHUB_ENV | |
fi | |
- name: Compilation Information | |
run: | | |
cd openwrt | |
source "${PATH_Comscript}/Precompile.sh" > /dev/null 2>&1 | |
if [ "${COMPILE_INFORMATION}" == "true" ]; then | |
source "${PATH_Comscript}/Get_Target_Info.sh" | |
source "${PATH_Comscript}/Compilation_Info.sh" | |
chmod -R 755 . | |
fi | |
- name: Download Package | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile the Firmware | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
echo "date=$(date "+%Y%m%d%H%M%S")" >> $GITHUB_ENV | |
echo "date1=$(date +'%m-%d')" >> $GITHUB_ENV | |
- name: Organize files | |
id: organize | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload Config to Actions Runs Artifacts | |
if: env.UPLOAD_CONFIG == 'true' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: .config_${{ env.CODE }}_${{ env.TARGET_PROFILE }}_${{ env.Compile_Date }} | |
path: config.txt | |
- name: Upload Bin_Dir to Actions Runs Artifacts | |
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: firmware+ipk_${{ env.CODE }}_${{ env.TARGET_PROFILE }}_${{ env.Compile_Date }} | |
path: openwrt/bin | |
- name: Upload Firmware to Actions Runs Artifacts | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_Artifacts == 'true' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.OpenWrt_name }}-${{ env.CODE }}-${{ env.TARGET_PROFILE }}-firmware-${{ env.Compile_Date }} | |
path: ${{ env.FIRMWARE }} | |
- name: Upload Firmware to CowTransfer | |
id: cowtransfer | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled() | |
run: | | |
curl -fsSL git.io/file-transfer | sh | |
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log | |
sed -i "s/Download Link/CowTransfer/g" cowtransfer.log | |
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)" | |
echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT | |
- name: Upload Firmware to 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 | |
sed -i "s/Download Link/WeTransfer/g" 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: Generate Releases Tags | |
id: tag | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled() | |
run: | | |
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT | |
touch update_log.txt | |
if [[ "${UPLOAD_COWTRANSFER}" == "true" ]]; then | |
curl -fsSL git.io/file-transfer | sh | |
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log | |
echo "##### CowTransfer:$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> update_log.txt | |
fi | |
if [[ "${UPLOAD_WETRANSFER}" == "true" ]]; then | |
curl -fsSL git.io/file-transfer | sh | |
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log | |
echo "##### WETRANSFER:$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> update_log.txt | |
fi | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload Firmware to Release Assets | |
if: steps.tag.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && env.REPO_TOKEN | |
uses: ncipollo/[email protected] | |
with: | |
name: ${{ env.CODE }}-${{ env.TARGET_PROFILE }} | |
tag: ${{ steps.tag.outputs.release_tag }} | |
token: ${{ secrets.REPO_TOKEN }} | |
bodyFile: "update_log.txt" | |
artifacts: "${{ env.FIRMWARE }}/*" | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ secrets.REPO_TOKEN }} | |
repository: ${{ github.repository }} | |
keep_minimum_runs: 8 | |
retain_days: ${{ github.event.inputs.days }} | |
- name: Remove old Releases | |
uses: dev-drprasad/delete-older-releases@master | |
with: | |
repo: ${{ github.repository }} | |
keep_latest: 8 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} |