|
| 1 | +#================================================= |
| 2 | +# Description: Build OpenWrt using GitHub Actions |
| 3 | +# Lisence: MIT |
| 4 | + |
| 5 | +name: NanoPi R2S 21.02 |
| 6 | + |
| 7 | +on: |
| 8 | +# release: |
| 9 | +# types: published |
| 10 | + #push: |
| 11 | + # branches: |
| 12 | + # - 21.02 |
| 13 | + # paths: |
| 14 | + # - '.github/workflows/openwrt-rockchip-2102.yml' |
| 15 | + # - 'step/00-prepare_openwrt.sh' |
| 16 | + # - 'step/01-prepare_package.sh' |
| 17 | + # - 'seed/rockchip.seed' |
| 18 | + #schedule: |
| 19 | + # - cron: 30 21 * * * |
| 20 | + watch: |
| 21 | + types: started |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + runs-on: ubuntu-18.04 |
| 27 | + if: github.event.repository.owner.id == github.event.sender.id |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@main |
| 32 | + |
| 33 | + - name: Show CPU Model and Free Space |
| 34 | + run: | |
| 35 | + echo -e "Total CPU cores\t: $(nproc)" |
| 36 | + cat /proc/cpuinfo | grep 'model name' |
| 37 | + free -h |
| 38 | + - name: Set env |
| 39 | + run: | |
| 40 | + echo "SSH_ACTIONS=false" >> $GITHUB_ENV |
| 41 | + echo "UPLOAD_BIN_DIR=false" >> $GITHUB_ENV |
| 42 | + echo "UPLOAD_FIRMWARE=true" >> $GITHUB_ENV |
| 43 | + echo "UPLOAD_RELEASE=true" >> $GITHUB_ENV |
| 44 | + echo "TZ=Europe/Paris" >>$GITHUB_ENV |
| 45 | + echo "Build_Date=$(date +%Y.%m.%d)" >> $GITHUB_ENV |
| 46 | + echo "RELTAG=v$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV |
| 47 | + |
| 48 | + - name: Show env |
| 49 | + run: echo $GITHUB_ENV |
| 50 | + |
| 51 | + - name: free disk space |
| 52 | + run: | |
| 53 | + df -h |
| 54 | + sudo swapoff -a |
| 55 | + sudo rm -f /swapfile |
| 56 | + sudo apt clean |
| 57 | + docker rmi $(docker image ls -aq) |
| 58 | + df -h |
| 59 | + /bin/bash ./workflow-scripts/free_disk_space.sh |
| 60 | + - name: Initialization environment |
| 61 | + env: |
| 62 | + DEBIAN_FRONTEND: noninteractive |
| 63 | + run: | |
| 64 | + sudo -E rm -rf /etc/apt/sources.list.d |
| 65 | + sudo -E apt-get update -y |
| 66 | + sudo -E apt-get install -y build-essential rsync asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core 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 python3 python3-pip python3-ply haveged lrzsz device-tree-compiler scons |
| 67 | + wget -qO - https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | sed 's/python-/python3-/g' | /bin/bash |
| 68 | + sudo -E apt-get clean -y |
| 69 | + git config --global user.name 'GitHub Actions' && git config --global user.email 'noreply@github.com' |
| 70 | + df -h |
| 71 | + - name: Get OpenWrt source 21.02 |
| 72 | + run: | |
| 73 | + ./steps/01_clone_openwrt_2102.sh |
| 74 | + - name: Get ImmortalWrt source 21.02 |
| 75 | + run: | |
| 76 | + ./steps/01_clone_immortal_2102.sh |
| 77 | + - name: Make working copy of OpenWrt source |
| 78 | + run: | |
| 79 | + ./steps/02_prepare_openwrt_folder_2102.sh |
| 80 | + - name: Patch OpenWrt source R2S / 21.02 |
| 81 | + run: | |
| 82 | + ./steps/r2s/03_patch_openwrt_2102.sh |
| 83 | + - name: Prepare package |
| 84 | + run: | |
| 85 | + ./steps/04-prepare_package.sh |
| 86 | + - name: Add ACL |
| 87 | + run: | |
| 88 | + ./steps/05-create_luci_acl.sh |
| 89 | + - name: Load ao Config |
| 90 | + run: | |
| 91 | + ./steps/06-create_config_from_seed.sh |
| 92 | + |
| 93 | + - name: Download package |
| 94 | + id: package |
| 95 | + run: | |
| 96 | + cd build/openwrt |
| 97 | + make defconfig |
| 98 | + make download -j128 |
| 99 | + find dl -size -1024c -exec ls -l {} \; |
| 100 | + find dl -size -1024c -exec rm -f {} \; |
| 101 | +
|
| 102 | + - name: Make toolchain-aarch64 |
| 103 | + id: compiletoolchain |
| 104 | + continue-on-error: true |
| 105 | + run: | |
| 106 | + cd build/openwrt |
| 107 | + let make_process=$(nproc)+1 |
| 108 | + make toolchain/install -j${make_process} V=s |
| 109 | + - name: If toolchain Error |
| 110 | + if: steps.compiletoolchain.outcome == 'failure' |
| 111 | + run: | |
| 112 | + echo '================================================================' |
| 113 | + cd build/openwrt && make toolchain/install -j1 V=s |
| 114 | + - name: Compile OpenWRT for R2S & R4S |
| 115 | + id: compileopenwrt |
| 116 | + continue-on-error: true |
| 117 | + run: | |
| 118 | + cd build/openwrt |
| 119 | + let make_process=$(nproc)+1 |
| 120 | + make -j${make_process} V=s || make -j${make_process} V=s |
| 121 | + - name: If compile openwrt Error |
| 122 | + if: steps.compileopenwrt.outcome == 'failure' |
| 123 | + run: | |
| 124 | + cat build/openwrt/.config |
| 125 | + echo '================================================================' |
| 126 | + cd build/openwrt && make -j1 V=s |
| 127 | + - name: Organize files |
| 128 | + id: organize |
| 129 | + run: | |
| 130 | + rm -rf ./artifact/ |
| 131 | + mkdir -p ./artifact/ |
| 132 | + mv build/openwrt/bin/targets/rockchip/armv8/*sysupgrade.img* ./artifact/ |
| 133 | + cd ./artifact/ |
| 134 | + ls -Ahl |
| 135 | + gzip -d *.gz && exit 0 |
| 136 | + gzip --best *.img |
| 137 | + ls -Ahl |
| 138 | + sha256sum openwrt*r2s* | tee NanoPI-R2S-AO-$(date +%Y%m%d)-21.02.sha256sum |
| 139 | + sha256sum openwrt*r4s* | tee NanoPI-R4S-AO-$(date +%Y%m%d)-21.02.sha256sum |
| 140 | + zip NanoPI-R2S-AO-$(date +%Y%m%d)-21.02-ext4.zip *r2s*ext4* |
| 141 | + zip NanoPI-R2S-AO-$(date +%Y%m%d)-21.02-sfs.zip *r2s*squashfs* |
| 142 | + zip NanoPI-R4S-AO-$(date +%Y%m%d)-21.02-ext4.zip *r4s*ext4* |
| 143 | + zip NanoPI-R4S-AO-$(date +%Y%m%d)-21.02-sfs.zip *r4s*squashfs* |
| 144 | + cp ../build/openwrt/*.config ./ |
| 145 | + ls -Ahl |
| 146 | + - name: Upload artifact |
| 147 | + uses: actions/upload-artifact@main |
| 148 | + if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() |
| 149 | + with: |
| 150 | + name: OpenWRT_21.02 |
| 151 | + path: ./artifact/ |
| 152 | + |
| 153 | + - name: Set env |
| 154 | + run: | |
| 155 | + echo "TZ=Europe/Paris" >>$GITHUB_ENV |
| 156 | + echo "Build_Date=$(date +%Y-%m-%d %H:%M)" >> $GITHUB_ENV |
| 157 | + echo "RELTAG=v$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV |
| 158 | +
|
| 159 | + - name: Create release |
| 160 | + id: create_release |
| 161 | + uses: ncipollo/release-action@v1.8.0 |
| 162 | + if: env.UPLOAD_RELEASE == 'true' && !cancelled() |
| 163 | + with: |
| 164 | + name: OpenWrt 21.02 ${{ env.Build_Date }} |
| 165 | + allowUpdates: true |
| 166 | + tag: ${{ env.RELTAG }} |
| 167 | + commit: main |
| 168 | + replacesArtifacts: true |
| 169 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 170 | + bodyFile: "release-info-r2s-21.02.md" |
| 171 | + artifacts: ./artifact/*.zip,./artifact/*.config,./artifact/*.sha256sum |
0 commit comments