Create builder.yml
This commit is contained in:
1 parent
370fc4cf84
commit
112f73de66
1 file changed
+142
@@ -0,0 +1,142 @@
|
||||
name: OpenWrt Builder
|
||||
on:
|
||||
repository_dispatch:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CONFIG_FILE: configs/openwrt_diffconfig
|
||||
UPLOAD_BIN_DIR: true
|
||||
UPLOAD_FIRMWARE: true
|
||||
UPLOAD_RELEASE: false
|
||||
TZ: Europe/Madrid
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@main
|
||||
|
||||
- name: Initialization environment
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: |
|
||||
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
|
||||
sudo docker image prune --all --force
|
||||
sudo -E apt-get -qq update
|
||||
sudo -E ./dependencies.sh
|
||||
sudo -E apt-get -qq autoremove --purge
|
||||
sudo -E apt-get -qq clean
|
||||
sudo timedatectl set-timezone "$TZ"
|
||||
sudo mkdir -p /workdir
|
||||
sudo chown $USER:$GROUPS /workdir
|
||||
|
||||
- name: Clone source code
|
||||
working-directory: /workdir
|
||||
run: |
|
||||
df -hT $PWD
|
||||
git clone --depth=1 https://github.com/openwrt/openwrt openwrt
|
||||
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
|
||||
|
||||
- name: Patch OpenWrt Sources
|
||||
run: |
|
||||
cp mods/ath.mk openwrt/package/kernel/mac80211/ath.mk
|
||||
cp mods/netdevices.mk openwrt/package/kernel/linux/modules/netdevices.mk
|
||||
cp mods/power openwrt/package/base-files/files/etc/rc.button/power
|
||||
|
||||
- name: Load custom target
|
||||
run: |
|
||||
[ -d msm89xx ] && mv msm89xx openwrt/target/linux/
|
||||
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
|
||||
|
||||
- name: Load custom packages
|
||||
run: |
|
||||
[ -d packages ] && mv packages openwrt/package/uz801
|
||||
|
||||
- name: Update and install feeds
|
||||
run: |
|
||||
rm -rf openwrt/tmp
|
||||
cd openwrt && ./scripts/feeds update -a
|
||||
cd openwrt && ./scripts/feeds install -a
|
||||
|
||||
- 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 || make -j1 V=s
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME
|
||||
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV
|
||||
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
|
||||
|
||||
- name: Check space usage
|
||||
if: (!cancelled())
|
||||
run: df -hT
|
||||
|
||||
- name: Upload bin directory
|
||||
uses: actions/upload-artifact@main
|
||||
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
|
||||
with:
|
||||
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
|
||||
path: openwrt/bin
|
||||
|
||||
- name: Organize files
|
||||
id: organize
|
||||
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
|
||||
run: |
|
||||
cd openwrt/bin/targets/*/*
|
||||
rm -rf packages
|
||||
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload firmware directory
|
||||
uses: actions/upload-artifact@main
|
||||
if: steps.organize.outputs.status == 'success' && !cancelled()
|
||||
with:
|
||||
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}-${{ inputs.source }}
|
||||
path: ${{ env.FIRMWARE }}
|
||||
|
||||
- name: Generate release tag
|
||||
id: tag
|
||||
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
|
||||
run: |
|
||||
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT
|
||||
touch release.txt
|
||||
[ ${UPLOAD_GOFILE} = true && ${{ steps.gofile.outputs.url }} ] && echo "🔗 [GoFile](${{ steps.gofile.outputs.url }})" >> release.txt
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Upload firmware to release
|
||||
uses: softprops/action-gh-release@master
|
||||
if: steps.tag.outputs.status == 'success' && !cancelled()
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.tag.outputs.release_tag }}-${{ inputs.source }}
|
||||
body_path: release.txt
|
||||
files: ${{ env.FIRMWARE }}/*
|
||||
|
||||
- name: Delete workflow runs
|
||||
uses: Mattraks/delete-workflow-runs@main
|
||||
with:
|
||||
retain_days: 0
|
||||
keep_minimum_runs: 2
|
||||
|
||||
- name: Remove old Releases
|
||||
uses: dev-drprasad/delete-older-releases@master
|
||||
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
|
||||
with:
|
||||
keep_latest: 3
|
||||
delete_tags: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in new issue
Block a user