lean-mt7621 #827
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
name: lean-mt7621 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 00 09 * * * | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Set environment variables | |
shell: bash {0} | |
run: | | |
echo "TARGET_NAME=ramips" >> $GITHUB_ENV | |
echo "DEVICE_NAME=mt7621" >> $GITHUB_ENV | |
echo "OPENWRT_REL=lean" >> $GITHUB_ENV | |
- name: Get latest release version | |
shell: bash {0} | |
run: | | |
echo "RELEASE_VERSION=$(curl -s -L https://api.github.com/repos/redchenjs/openwrt-packages/releases | jq ".[] | .tag_name" | grep '".*-${{ env.OPENWRT_REL }}-${{ env.DEVICE_NAME }}"' | head -n 1 | sed -r 's|.*"(.*)".*|\1|g')" >> $GITHUB_ENV | |
- name: Checkout OpenWrt repository | |
uses: actions/checkout@v2 | |
with: | |
repository: 'coolsnowwolf/lede' | |
- name: Get latest Kernel version | |
shell: bash {0} | |
run: | | |
KERNEL_VERSION=$(cat target/linux/${{ env.TARGET_NAME }}/Makefile | grep KERNEL_PATCHVER | sed -r 's|.*([0-9]+.[0-9]+)$|\1|') | |
LINUX_VERSION=$(cat include/kernel-$KERNEL_VERSION | grep LINUX_VERSION-$KERNEL_VERSION | sed -r 's|.*(\.[0-9]+)$|\1|') | |
echo "KERNEL_VERSION=$KERNEL_VERSION$LINUX_VERSION" >> $GITHUB_ENV | |
- name: Compare release versions | |
shell: bash {0} | |
run: | | |
if [[ "v${{ env.KERNEL_VERSION }}-${{ env.OPENWRT_REL }}-${{ env.DEVICE_NAME }}" == "${{ env.RELEASE_VERSION }}" ]]; then | |
echo "LATEST_VERSION=1" >> $GITHUB_ENV | |
else | |
echo "LATEST_VERSION=0" >> $GITHUB_ENV | |
fi | |
- name: Compile OpenWrt packages | |
if: env.LATEST_VERSION == 0 | |
shell: bash {0} | |
run: | | |
sudo apt update | |
sudo apt install build-essential ccache ecj fastjar file g++ gawk \ | |
gettext git java-propose-classpath libelf-dev libncurses5-dev \ | |
libncursesw5-dev libssl-dev python python2.7-dev python3 unzip wget \ | |
python3-distutils python3-setuptools rsync subversion swig time \ | |
xsltproc zlib1g-dev texlive python-is-python3 | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
curl https://raw.githubusercontent.com/redchenjs/openwrt-packages/main/${{ env.OPENWRT_REL }}-${{ env.DEVICE_NAME }}.config > .config | |
make defconfig | |
make download | |
make -j$(nproc) V=s | |
- name: Prepare artifacts | |
if: env.LATEST_VERSION == 0 | |
shell: bash {0} | |
run: | | |
mkdir artifacts | |
for file in bin/targets/${{ env.TARGET_NAME }}/*/*; do | |
sudo mv $file artifacts/ | |
done | |
cd artifacts | |
sudo tar -czf packages.tar.gz packages/ | |
sudo rm -rf packages/ | |
- name: Create release | |
if: env.LATEST_VERSION == 0 | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.KERNEL_VERSION }}-${{ env.OPENWRT_REL }}-${{ env.DEVICE_NAME }} | |
release_name: Release v${{ env.KERNEL_VERSION }}-${{ env.OPENWRT_REL }}-${{ env.DEVICE_NAME }} | |
draft: false | |
prerelease: false | |
- name: Upload release assets | |
if: env.LATEST_VERSION == 0 | |
uses: NBTX/upload-release-assets@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
targets: artifacts/* | |
- name: Delete older releases | |
uses: dev-drprasad/delete-older-releases@v0.3.2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
keep_latest: 50 | |
delete_tags: true |