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

130 lines
4.0 KiB
YAML
Raw Normal View History

2020-09-11 02:08:22 +00:00
#=======================================================
2020-09-08 03:23:08 +00:00
# Description: Build OpenWrt using GitHub Actions
2020-09-11 01:37:13 +00:00
# Github: https://github.com/Hyy2001X/AutoBuild-Actions
2020-09-08 03:23:08 +00:00
# Lisence: MIT
2020-09-11 01:34:26 +00:00
# Author: P3TERX
2020-09-08 03:23:08 +00:00
# Modify: Hyy2001
2020-09-11 02:08:22 +00:00
#=======================================================
2020-09-08 03:23:08 +00:00
2020-09-11 01:34:26 +00:00
name: AutoBuild OpenWrt
2020-09-08 03:23:08 +00:00
on:
2020-09-11 01:34:26 +00:00
# release:
# types: [published]
2020-09-08 03:23:08 +00:00
2020-09-11 01:34:26 +00:00
# push:
# branches:
# - main
2020-09-08 03:23:08 +00:00
2020-09-11 01:34:26 +00:00
# schedule:
# - cron: 0 8 * * 5
2020-09-08 03:23:08 +00:00
watch:
types: [started]
env:
REPO_URL: https://github.com/coolsnowwolf/lede
2020-09-11 01:58:40 +00:00
REPO_BRANCH: master
2020-09-08 03:23:08 +00:00
CONFIG_FILE: .config
2020-09-11 01:49:57 +00:00
FEEDS_CONF_DEFAULT: ./Customize/feeds.conf.default
MAC80211: ./Customize/mac80211.sh
2020-09-19 07:37:55 +00:00
AUTOUPDATE: ./Customize/AutoUpdate.sh
2020-09-11 01:49:57 +00:00
MWAN3: ./Customize/mwan3
2020-09-16 15:18:30 +00:00
CUSTOM_SCRIPT: ./Scripts/diy-script.sh
2020-09-11 01:34:26 +00:00
TZ: Asia/Shanghai
2020-09-19 07:37:55 +00:00
UPLOAD_RELEASE: true
2020-09-20 10:02:01 +00:00
UPLOAD_FIRMWARE: true
UPLOAD_BIN_DIR: false
2020-09-08 03:23:08 +00:00
jobs:
build:
2020-09-11 01:34:26 +00:00
runs-on: ubuntu-18.04
2020-09-08 03:23:08 +00:00
steps:
- name: Checkout
2020-09-11 01:34:26 +00:00
uses: actions/checkout@main
2020-09-08 03:23:08 +00:00
2020-09-19 07:37:55 +00:00
- name: Initialization Environment
2020-09-08 03:23:08 +00:00
env:
DEBIAN_FRONTEND: noninteractive
run: |
2020-09-11 01:34:26 +00:00
sudo -E apt-get update
2020-09-13 14:11:49 +00:00
sudo -E apt-get install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync
2020-09-08 03:23:08 +00:00
2020-09-19 07:37:55 +00:00
- name: Clone Openwrt source code
2020-09-08 03:23:08 +00:00
run: |
2020-09-11 01:34:26 +00:00
git clone -b $REPO_BRANCH $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
2020-09-11 01:37:13 +00:00
2020-09-11 01:34:26 +00:00
- name: Run Before-Update-Feeds Script
run: |
[ -e $FEEDS_CONF_DEFAULT ] && mv $FEEDS_CONF_DEFAULT openwrt/feeds.conf.default
2020-09-16 15:18:30 +00:00
chmod +x $CUSTOM_SCRIPT
2020-09-11 01:34:26 +00:00
cd openwrt
2020-09-19 08:24:34 +00:00
source $GITHUB_WORKSPACE/$CUSTOM_SCRIPT && Diy-Part1
2020-09-11 01:37:13 +00:00
2020-09-11 01:34:26 +00:00
- name: Update & Install Feeds
2020-09-08 03:23:08 +00:00
run: |
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
2020-09-11 01:34:26 +00:00
- name: Run After-Update-Feeds Script
2020-09-08 03:23:08 +00:00
run: |
2020-09-19 08:24:34 +00:00
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
2020-09-11 01:34:26 +00:00
[ -e $MAC80211 ] && mv $MAC80211 openwrt/package/kernel/mac80211/files/lib/wifi/mac80211.sh
[ -e $MWAN3 ] && mv $MWAN3 openwrt/package/feeds/packages/mwan3/files/etc/config/mwan3
2020-09-19 07:37:55 +00:00
[ -e $AUTOUPDATE ] && mv $AUTOUPDATE openwrt/package/base-files/files/bin/AutoUpdate.sh
2020-09-08 03:23:08 +00:00
cd openwrt
2020-09-16 15:18:30 +00:00
source $GITHUB_WORKSPACE/$CUSTOM_SCRIPT && Diy_Core && Diy-Part2
2020-09-11 01:37:13 +00:00
2020-09-19 07:37:55 +00:00
- name: Download Package
2020-09-08 03:23:08 +00:00
run: |
2020-09-11 01:53:27 +00:00
cd openwrt
2020-09-19 07:37:55 +00:00
make defconfig
2020-09-11 01:34:26 +00:00
make download -j$(nproc)
2020-09-08 03:23:08 +00:00
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
2020-09-19 07:37:55 +00:00
- name: Compile the Firmware
2020-09-08 03:23:08 +00:00
run: |
2020-09-11 01:53:27 +00:00
cd openwrt
2020-09-08 03:23:08 +00:00
make -j$(nproc) V=s
2020-09-11 01:34:26 +00:00
- name: Run After-Compile-OpenWRT Script
run: |
cd openwrt
2020-09-16 15:18:30 +00:00
source $GITHUB_WORKSPACE/$CUSTOM_SCRIPT && Diy_Core && Diy-Part3
2020-09-11 01:34:26 +00:00
2020-09-19 07:37:55 +00:00
- name: Upload Firmware to Artifacts
2020-09-11 01:34:26 +00:00
uses: actions/upload-artifact@main
2020-09-20 10:02:01 +00:00
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
2020-09-08 03:23:08 +00:00
with:
2020-09-20 10:02:01 +00:00
name: OpenWrt_Firmware
2020-09-11 01:34:26 +00:00
path: openwrt/bin/Firmware
2020-09-20 10:02:01 +00:00
- name: Upload Firmware Directory to Artifacts
uses: actions/upload-artifact@main
if: env.UPLOAD_BIN_DIR == 'true' && !cancelled()
with:
name: OpenWrt_Bin
path: openwrt/bin
2020-09-19 07:37:55 +00:00
- name: Generate Tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo " - $(date +"%Y%m%d")-AutoUpdate" > update_log.txt
echo "::set-env name=FIRMWARE::openwrt/bin/Firmware"
echo "::set-output name=status::success"
- name: Upload Firmware to Github Release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: AutoUpdate
body_path: update_log.txt
files: ${{ env.FIRMWARE }}/*