Skip to content

Commit

Permalink
add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FUjr committed Dec 19, 2024
1 parent 78deb90 commit bdce0d7
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/arm64.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SDK_NAME=openwrt-sdk-21.02.3-mvebu-cortexa53_gcc-8.4.0_musl.Linux-x86_64
SDK_URL=https://downloads.openwrt.org/releases/21.02.3/targets/mvebu/cortexa53/
SDK_ARCH=aarch64_cortex-a53
56 changes: 56 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Debug

on:
workflow_dispatch:
inputs:
target:
description: 'target ["arm64"]'
required: true
default: 'arm64'
type: choice
options:
- arm64
- x64
- mipsel

env:
TZ: Asia/Shanghai

jobs:
debug:
runs-on: ubuntu-latest
name: Debug
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: 'apps'

- name: Import Env
env:
MATRIX_TARGET: ${{ github.event.inputs.target }}
run: cat apps/.github/workflows/${MATRIX_TARGET}.env >> "$GITHUB_ENV"

- name: Download ddnsto
run: |
wget -O /tmp/ddnsto https://fw.koolcenter.com/binary/ddnsto/linux/ddnsto.amd64
chmod 755 /tmp/ddnsto
- name: Configure password
run: |
echo "### Update user: $USER password ###"
echo -e "password\npassword" | sudo passwd "$USER"
- name: Tmux
run: |
tmux new-session -d -s tmux || true
- name: Print info
run: |
ip addr
- name: Run ddnsto
env:
DDNSTO_TOKEN: ${{ secrets.DDNSTO_TOKEN }}
run: |
/tmp/ddnsto -u $DDNSTO_TOKEN
45 changes: 45 additions & 0 deletions .github/workflows/luci.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From 55db7a1f7f650f965e783301387246f9f62fa1ec Mon Sep 17 00:00:00 2001
From: Liangbin Lian <jjm2473@gmail.com>
Date: Wed, 11 Dec 2024 11:20:45 +0800
Subject: [PATCH] luci.mk: postinst compat openwrt 23

---
luci.mk | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/luci.mk b/luci.mk
index aca52e08cd..b28284c892 100644
--- a/luci.mk
+++ b/luci.mk
@@ -53,6 +53,8 @@ LUCI_LANG.uk=Українська (Ukrainian)
LUCI_LANG.vi=Tiếng Việt (Vietnamese)
LUCI_LANG.zh_Hans=简体中文 (Chinese Simplified)
LUCI_LANG.zh_Hant=繁體中文 (Chinese Traditional)
+LUCI_LANG.zh-cn=$(LUCI_LANG.zh_Hans)
+LUCI_LANG.zh-tw=$(LUCI_LANG.zh_Hant)

# Submenu titles
LUCI_MENU.col=1. Collections
@@ -211,8 +213,8 @@ endef
ifndef Package/$(PKG_NAME)/postinst
define Package/$(PKG_NAME)/postinst
[ -n "$${IPKG_INSTROOT}" ] || {$(foreach script,$(LUCI_DEFAULTS),
- (. /etc/uci-defaults/$(script)) && rm -f /etc/uci-defaults/$(script))
- rm -f /tmp/luci-indexcache
+ [ -f /etc/uci-defaults/$(script) ] && (. /etc/uci-defaults/$(script)) && rm -f /etc/uci-defaults/$(script))
+ rm -f /tmp/luci-indexcache /tmp/luci-indexcache.*
rm -rf /tmp/luci-modulecache/
killall -HUP rpcd 2>/dev/null
exit 0
@@ -325,7 +327,7 @@ define LuciTranslation

define Package/luci-i18n-$(LUCI_BASENAME)-$(1)/postinst
[ -n "$$$${IPKG_INSTROOT}" ] || {
- (. /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)) && rm -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)
+ [ -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1) ] && (. /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)) && rm -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)
exit 0
}
endef
--
2.46.0

233 changes: 233 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
name: Build IPKs

on:
repository_dispatch:
workflow_dispatch:
inputs:
applications:
description: 'build applications, eg: "luci-app-store luci-app-ddnsto". "all" means build all'
required: true
default: 'all'
target:
description: 'build target ["arm64", "x64", "mipsel", "all"]'
required: true
default: 'all'


env:
TZ: Asia/Shanghai

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Detect build target
id: set-matrix
env:
MATRIX_TARGET: ${{ github.event.inputs.target }}
run: |
if [ "x${MATRIX_TARGET}" = "x" -o "x${MATRIX_TARGET}" = "xall" ]; then \
echo "matrix={\"target\":[\"arm64\"]}" >> $GITHUB_OUTPUT; \
else \
targets=""; \
for target in ${MATRIX_TARGET}; do \
targets="$targets, \"$target\"";
done; \
echo "matrix={\"target\":[${targets#, }]}" >> $GITHUB_OUTPUT; \
fi
build:
needs: matrix
runs-on: ubuntu-latest
name: Build IPKs for ${{ matrix.target }}
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- name: Job Info
run: |
apps="${{ github.event.inputs.applications }}"
echo "::notice title=Apps::$apps"
- name: Checkout
uses: actions/checkout@v2
with:
path: 'apps'

- name: Import Env
env:
MATRIX_TARGET: ${{ matrix.target }}
run: cat apps/.github/workflows/${MATRIX_TARGET}.env >> "$GITHUB_ENV"

- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo swapoff -a || true
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo find /etc/apt/sources.list.d ! -name 'ubuntu.sources' -type f -exec rm -f {} +
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev libc6-dev-i386 subversion flex uglifyjs gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler antlr3 gperf rsync
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
# sudo ln -s /usr/bin/python3 /usr/bin/python3.10 || true
# sudo timedatectl set-timezone "$TZ"
# curl -fsSL https://raw.githubusercontent.com/P3TERX/dotfiles/master/.bashrc >> ~/.bashrc
- name: Download SDK
run: wget ${SDK_URL}${SDK_NAME}.tar.xz

- name: Unpack SDK
run: |
mkdir ~/openwrt-sdk
tar -xJf `pwd`/${SDK_NAME}.tar.xz --strip-components=1 -C ~/openwrt-sdk
ln -s ${HOME}/openwrt-sdk ${SDK_NAME}
- name: Clean Code
run: |
rm -f ${SDK_NAME}/package/linux/modules/*
rm -f ${SDK_NAME}/package/kernel/linux/modules/*
grep -lFr '$(call KernelPackage,' ${SDK_NAME}/package/linux | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
grep -lFr '$(call KernelPackage,' ${SDK_NAME}/package/kernel | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
find ${SDK_NAME}/target/linux -name 'modules.mk' | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
grep 'src-git base ' ${SDK_NAME}/feeds.conf.default > ${SDK_NAME}/feeds.conf
grep 'src-git luci ' ${SDK_NAME}/feeds.conf.default >> ${SDK_NAME}/feeds.conf
- name: Write Config
run: |
cat <<EOF >${SDK_NAME}/.config
# CONFIG_SIGNED_PACKAGES is not set
CONFIG_LUCI_LANG_zh_Hans=y
CONFIG_LUCI_LANG_zh-cn=y
EOF
- name: Load custom feeds
run: |
echo "" >> ${SDK_NAME}/feeds.conf
echo "src-link apps `pwd`/apps/applications" >> ${SDK_NAME}/feeds.conf
echo "" >> ${SDK_NAME}/feeds.conf
echo "Final feeds.conf:"
cat ${SDK_NAME}/feeds.conf
- name: 'Restore feeds from cache'
id: feeds-cache
uses: actions/cache@v3
env:
CACHE_NAME: 'feeds-cache'
with:
path: |
~/openwrt-sdk/feeds/packages
~/openwrt-sdk/feeds/luci
key: ${{ env.CACHE_NAME }}-${{ env.SDK_NAME }}-pl-3

- name: 'Restore staging from cache'
id: staging-cache
uses: actions/cache@v3
env:
CACHE_NAME: 'staging-cache'
with:
path: ~/openwrt-sdk/staging_dir
key: ${{ env.CACHE_NAME }}-${{ env.SDK_NAME }}-hht-2

- name: Update feeds
run: |
apps="${{ github.event.inputs.applications }}"
cd ~/openwrt-sdk
./scripts/feeds update -a
grep -lFr '$(call KernelPackage,' feeds/base/package/linux | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
grep -lFr '$(call KernelPackage,' feeds/base/package/kernel | xargs -rn1 sed -i 's/ FILES:=/ XFILES:=/g' || true
patch -d feeds/luci -p1 -f -N -i ${{ github.workspace }}/apps/.github/workflows/luci.patch
if [ "$apps" = "all" ]; then
./scripts/feeds install -a -p apps -d y
for repo in `sed -e 's/src-[^ ]* \([^ ]*\) .*/\1/g' ${{ github.workspace }}/apps/feeds.conf`
do
echo add all in repo $repo
./scripts/feeds install -a -p $repo -d y
done
else
./scripts/feeds install -d y ${apps}
fi
- name: Defconfig
id: defconfig
run: |
cd ~/openwrt-sdk
make defconfig
sed -i 's/^CONFIG_PACKAGE_\(.*\)=m$/# CONFIG_PACKAGE_\1 is not set/' .config
grep '^CONFIG_PACKAGE_' .config
echo "status=success" >> $GITHUB_OUTPUT
- name: 'Restore downloads from cache'
id: dl-cache
uses: actions/cache@v3
env:
CACHE_NAME: 'dl-cache'
with:
path: ${{ github.workspace }}/.dl
key: ${{ env.CACHE_NAME }}

- name: Download sources
id: download
if: steps.defconfig.outputs.status == 'success'
run: |
[ -d "${{ github.workspace }}/.dl" ] || mkdir -p "${{ github.workspace }}/.dl"
cd ~/openwrt-sdk
rm -rf dl
ln -s "${{ github.workspace }}/.dl" dl
make -j4 download
echo "status=success" >> $GITHUB_OUTPUT
- name: ReDownload
if: failure() && steps.defconfig.outputs.status == 'success'
run: |
cd ~/openwrt-sdk
make -j1 V=s download
- name: 'Restore ccache from cache'
id: ccache-cache
uses: actions/cache@v3
env:
CACHE_NAME: 'ccache-cache'
with:
path: ~/openwrt-sdk/.ccache
key: ${{ env.CACHE_NAME }}-${{ env.SDK_NAME }}-2

- name: PreCompile IPKs
id: precompile
if: steps.download.outputs.status == 'success'
run: |
cd ~/openwrt-sdk
make -j4 package/compile
echo "status=success" >> $GITHUB_OUTPUT
- name: ReCompile IPKs
id: compile
if: failure() && steps.download.outputs.status == 'success'
run: |
cd ~/openwrt-sdk
bash -c 'set -o pipefail ; make -j1 V=s defconfig package/compile 2>&1 | tee /tmp/openwrt-sdk-build.log'
echo "status=success" >> $GITHUB_OUTPUT
- name: Last fail log
if: failure() && steps.download.outputs.status == 'success'
run: tail -n 200 /tmp/openwrt-sdk-build.log && false

- name: PreUpload - Clean
id: preupload
if: steps.precompile.outputs.status == 'success' || steps.compile.outputs.status == 'success'
run: |
cd ${SDK_NAME}/bin/packages/${SDK_ARCH}
rm -rf base luci
- name: Upload bin directory
uses: actions/upload-artifact@main
if: steps.precompile.outputs.status == 'success' || steps.compile.outputs.status == 'success'
with:
name: ${{ env.SDK_ARCH }}
path: ${{ env.SDK_NAME }}/bin/packages/${{ env.SDK_ARCH }}

- name: PreCache - Clean
run: |
git -C "${SDK_NAME}/feeds/luci" reset --hard HEAD^
cd ${SDK_NAME}/staging_dir
rm -rf packages target-*
3 changes: 3 additions & 0 deletions .github/workflows/mipsel.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SDK_NAME=openwrt-sdk-21.02.3-ramips-mt7620_gcc-8.4.0_musl.Linux-x86_64
SDK_URL=https://downloads.openwrt.org/releases/21.02.3/targets/ramips/mt7620/
SDK_ARCH=mipsel_24kc
3 changes: 3 additions & 0 deletions .github/workflows/x64.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SDK_NAME=openwrt-sdk-21.02.3-x86-64_gcc-8.4.0_musl.Linux-x86_64
SDK_URL=https://downloads.openwrt.org/releases/21.02.3/targets/x86/64/
SDK_ARCH=x86_64

0 comments on commit bdce0d7

Please sign in to comment.