|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + device: |
| 8 | + description: 'select device to build' |
| 9 | + default: 'r2s' |
| 10 | + required: false |
| 11 | + |
| 12 | +jobs: |
| 13 | + |
| 14 | + build: |
| 15 | + name: ${{ github.event.client_payload.device }} |
| 16 | + runs-on: ubuntu-latest |
| 17 | + if: github.event.repository.owner.id == github.event.sender.id |
| 18 | + |
| 19 | + steps: |
| 20 | + |
| 21 | + - name: Space cleanup |
| 22 | + env: |
| 23 | + DEBIAN_FRONTEND: noninteractive |
| 24 | + run: | |
| 25 | + sudo rm -rf /usr/share/dotnet & #/usr/local/lib/android/sdk |
| 26 | + sudo -E apt update |
| 27 | + sudo -E apt -y install secure-delete zstd build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python python3 python-pip python3-pip python-ply python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf intltool rsync swig |
| 28 | + sudo -E apt -y autoremove --purge |
| 29 | + sudo -E apt clean |
| 30 | + df -h |
| 31 | +
|
| 32 | + - uses: actions/checkout@v2 |
| 33 | + with: |
| 34 | + fetch-depth: 1 |
| 35 | + |
| 36 | + - name: Checkout |
| 37 | + run: | |
| 38 | + for i in {0..5} |
| 39 | + do |
| 40 | + curl -s -L --fail https://github.com/${{ github.repository }}/releases/download/cache/lede.${{ github.event.client_payload.device }}.img.zst.0$i || break |
| 41 | + done | zstdmt -d -o lede.img || (truncate -s 40g lede.img && mkfs.xfs lede.img) |
| 42 | + LOOP_DEVICE=$(losetup -f) && echo $LOOP_DEVICE > LOOP_DEVICE |
| 43 | + sudo losetup -P --direct-io $LOOP_DEVICE lede.img |
| 44 | + mkdir lede && sudo mount $LOOP_DEVICE lede && sudo chown -R $USER:$USER lede |
| 45 | + [ ! -e lede/.git ] && (cd lede && git init && git remote add -t openwrt-18.06-k5.4 -f origin https://github.com/immortalwrt/immortalwrt && git checkout openwrt-18.06-k5.4) |
| 46 | + cd lede && git config --local user.email "[email protected]" && git config --local user.name "GitHub Action" && git pull -X theirs |
| 47 | +
|
| 48 | + - name: Update feeds and packages |
| 49 | + run: | |
| 50 | + cd lede/ |
| 51 | + git clone --depth=1 https://github.com/destan19/OpenAppFilter.git && rm -rf package/OpenAppFilter && mv OpenAppFilter package/ |
| 52 | + git clone --depth=1 -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git && rm -rf package/lean/luci-theme-argon && mv luci-theme-argon package/lean/ |
| 53 | + ./scripts/feeds update -a |
| 54 | + ./scripts/feeds install -a |
| 55 | +
|
| 56 | + - name: Custom configure file |
| 57 | + run: | |
| 58 | + cd lede |
| 59 | + rm -f .config* |
| 60 | + cat ../${{ github.event.client_payload.device }}.config.seed > .config |
| 61 | + sed -i 's/^[ \t]*//g' .config |
| 62 | + echo ' |
| 63 | + # CONFIG_v2ray-plugin_INCLUDE_GOPROXY is not set |
| 64 | + # CONFIG_XRAY_CORE_COMPRESS_GOPROXY is not set |
| 65 | + # CONFIG_UnblockNeteaseMusicGo_INCLUDE_GOPROXY is not set |
| 66 | + ' >> .config |
| 67 | + make defconfig && cat .config |
| 68 | +
|
| 69 | + - name: Compile firmware |
| 70 | + run: | |
| 71 | + cd lede |
| 72 | + while true; do make download -j8 && break || true; done |
| 73 | + make -j$(($(nproc) + 1)) -s || (make clean && make -j1 V=sc) |
| 74 | + echo "=======================" |
| 75 | + echo "Space usage:" |
| 76 | + echo "=======================" |
| 77 | + df -h |
| 78 | + echo "=======================" |
| 79 | + du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin |
| 80 | + du -h --max-depth=1 ./build_dir |
| 81 | + du -h --max-depth=1 ./bin |
| 82 | +
|
| 83 | + - name: Prepare artifact |
| 84 | + run: | |
| 85 | + mkdir -p ./artifact/firmware |
| 86 | + mkdir -p ./artifact/package |
| 87 | + mkdir -p ./artifact/buildinfo |
| 88 | + mkdir -p ./release |
| 89 | + cd lede |
| 90 | + rm -rf $(find ./bin/targets/ -type d -name "packages") |
| 91 | + cp -rf $(find ./bin/targets/ -type f) ../artifact/firmware/ |
| 92 | + cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ../artifact/package/ |
| 93 | + cp -rf $(find ./bin/targets/ -type f -name "*.buildinfo" -o -name "*.manifest") ../artifact/buildinfo/ |
| 94 | + cp $(ls -1 ../artifact/firmware/*img*) ../release/${{ github.event.client_payload.device }}.img.gz |
| 95 | + pushd ../release/ && md5sum ${{ github.event.client_payload.device }}.img.gz > md5sum.txt && popd |
| 96 | + echo "strDate=$(date +%Y-%m-%d)" >> $GITHUB_ENV |
| 97 | + echo "strDevice=$(echo ${{ github.event.client_payload.device }} | awk '{print toupper($0)}')" >> $GITHUB_ENV |
| 98 | + rm -rf bin/ tmp/ |
| 99 | + cd .. |
| 100 | + rm -f *zst* |
| 101 | + sudo umount lede |
| 102 | + LOOP_DEVICE=$(cat LOOP_DEVICE) |
| 103 | + sudo losetup -d $LOOP_DEVICE |
| 104 | + zstdmt -c lede.img | split -d -b 2000m - lede.${{ github.event.client_payload.device }}.img.zst. |
| 105 | + ls -l *zst* |
| 106 | +
|
| 107 | + - name: Deliver buildinfo |
| 108 | + uses: actions/upload-artifact@v2 |
| 109 | + with: |
| 110 | + name: OpenWrt_buildinfo |
| 111 | + path: ./artifact/buildinfo/ |
| 112 | + |
| 113 | + - name: Deliver package |
| 114 | + uses: actions/upload-artifact@v2 |
| 115 | + with: |
| 116 | + name: OpenWrt_package |
| 117 | + path: ./artifact/package/ |
| 118 | + |
| 119 | + - name: Deliver firmware |
| 120 | + uses: actions/upload-artifact@v2 |
| 121 | + with: |
| 122 | + name: OpenWrt_firmware |
| 123 | + path: ./artifact/firmware/ |
| 124 | + |
| 125 | + - name: Upload release asset |
| 126 | + uses: svenstaro/upload-release-action@v2 |
| 127 | + with: |
| 128 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + file: ./release/* |
| 130 | + tag: ${{ github.event.client_payload.device }}-${{ env.strDate }} |
| 131 | + file_glob: true |
| 132 | + overwrite: true |
| 133 | + release_name: ${{ env.strDevice }} ${{ env.strDate }} 自动发布 |
| 134 | + |
| 135 | + - name: Save cache state |
| 136 | + uses: svenstaro/upload-release-action@master |
| 137 | + with: |
| 138 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 139 | + file: ./lede.${{ github.event.client_payload.device }}*zst* |
| 140 | + tag: cache |
| 141 | + file_glob: true |
| 142 | + overwrite: true |
| 143 | + prerelease: true |
| 144 | + |
| 145 | + - name: Debug via tmate |
| 146 | + uses: P3TERX/ssh2actions@main |
| 147 | + if: ${{ failure() }} |
| 148 | + env: |
| 149 | + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 150 | + TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} |
| 151 | + |
| 152 | + - name: Send tg notification |
| 153 | + uses: appleboy/telegram-action@master |
| 154 | + #if: always() |
| 155 | + with: |
| 156 | + to: ${{ secrets.TELEGRAM_CHAT_ID }} |
| 157 | + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
| 158 | + args: The ${{ github.event.client_payload.device }} build ran completed at ${{ job.status }}. |
0 commit comments