Skip to content

Auto compile with OpenWrt SDK #17

Auto compile with OpenWrt SDK

Auto compile with OpenWrt SDK #17

#
# Copyright (c) 2022-2023 SMALLPROGRAM <https://github.com/smallprogram>
# Description: Auto compile
#
#
# Fork and compile the latest version yourself using Github Actions
# 1.Into the repository of your own fork
# 2.Into the repository [Settings]
# 3.[Code and automation - Actions] ↓ [General] → [Workflow permissions] ↓ Check the [Read and write permissions] and [Save]
# 4.Let's take [Actions]
#
name: "Auto compile with OpenWrt SDK"
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
push:
branches:
- 'master'
paths:
- 'luci-theme-argon/Makefile'
env:
TZ: Asia/Shanghai
jobs:
job_check:
if: github.repository == ${{ github.repository }}
name: Check Version
runs-on: ubuntu-latest
outputs:
argon_version: ${{ steps.check_version.outputs.latest_version }}
has_update: ${{ steps.check_version.outputs.has_update }}
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
ref: 'master'
- name: Check version
id: check_version
env:
url_release: https://api.github.com/repos/${{ github.repository }}/releases/latest
run: |
latest_version=$(grep -oP 'PKG_VERSION:=\K.*' Makefile | sed 's/^/v/')
latest_release=$(wget -qO- -t1 -T2 ${{env.url_release}} | awk -F '"' '/tag_name/{print $4}')
has_update=$([ "${latest_version}" != "${latest_release}" ] && echo true || echo false)
echo "latest_version=${latest_version}" >> $GITHUB_OUTPUT
echo "has_update=${has_update}" >> $GITHUB_OUTPUT
echo "latest_version: ${latest_version}"
echo "latest_release: ${latest_release}"
echo "has_update: ${has_update}"
- name: Generate new tag & release
if: steps.check_version.outputs.has_update == 'true'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: For openwrt official Snapshots LuCI master
tag_name: ${{steps.check_version.outputs.latest_version}}
job_build_argon:
name: Build Argon (master)
needs: job_check
if: needs.job_check.outputs.has_update == 'true'
runs-on: ubuntu-latest
steps:
- name: Install packages
run: |
echo "Install packages"
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
- name: Cache openwrt SDK
id: cache-sdk
uses: actions/cache@v3
with:
path: sdk
key: openwrt-sdk-21.02-x86-64
- name: Initialization environment
if: steps.cache-sdk.outputs.cache-hit != 'true'
env:
url_sdk: https://archive.openwrt.org/releases/21.02.5/targets/x86/64/openwrt-sdk-21.02.5-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz
run: |
wget ${{ env.url_sdk }}
file_name=$(echo ${{env.url_sdk}} | awk -F/ '{print $NF}')
mkdir sdk && tar -xJf $file_name -C ./sdk --strip-components=1
cd sdk
echo "src-git base https://github.com/openwrt/openwrt.git;openwrt-21.02" > feeds.conf
echo "src-git-full packages https://github.com/openwrt/packages.git;openwrt-21.02" >> feeds.conf
echo "src-git-full luci https://git.openwrt.org/project/luci.git;openwrt-21.02" >> feeds.conf
echo "src-git-full routing https://git.openwrt.org/feed/routing.git;openwrt-21.02" >> feeds.conf
git clone -b master https://github.com/${{ github.repository }}.git package/downloads/luci-theme-argon
./scripts/feeds update -a
echo "CONFIG_PACKAGE_luci-theme-argon=m" > .config
./scripts/feeds install -d n luci-theme-argon
make download -j8
- name: Configure Argon (master)
run: |
cd sdk
./scripts/feeds install luci-theme-argon
echo "CONFIG_ALL_NONSHARED=n" > .config
echo "CONFIG_ALL_KMODS=n" >> .config
echo "CONFIG_ALL=n" >> .config
echo "CONFIG_AUTOREMOVE=n" >> .config
echo "CONFIG_LUCI_LANG_zh_Hans=y" >> .config
echo "CONFIG_PACKAGE_luci-theme-argon=m" >> .config
make defconfig
- name: Compile Argon (master)
id: compile
run: |
cd sdk
echo "make package/luci-theme-argon/{clean,compile} -j$(nproc)"
make package/luci-theme-argon/{clean,compile} -j$(nproc)
mv bin/packages/x86_64/base/ ../
rm .config .config.old
cd ..
echo "status=success" >> $GITHUB_OUTPUT
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
- name: Upload Argon (master) ipks to release
uses: softprops/action-gh-release@v1
if: steps.compile.outputs.status == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{needs.job_check.outputs.argon_version}}
files: ${{ env.FIRMWARE }}/base/luci-theme*.ipk