|
| 1 | +#================================================= |
| 2 | +# Description: Build OpenWrt using GitHub Actions |
| 3 | +# Lisence: MIT |
| 4 | + |
| 5 | +name: NanoPi Build |
| 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 | + inputs: |
| 24 | + openwrt_branch: |
| 25 | + description: 'OpenWrt Branch to build' |
| 26 | + required: true |
| 27 | + default: '21.02' |
| 28 | + type: choice |
| 29 | + options: |
| 30 | + - '21.02' |
| 31 | + |
| 32 | +jobs: |
| 33 | + init: |
| 34 | + runs-on: ubuntu-20.04 |
| 35 | + if: github.event.repository.owner.id == github.event.sender.id |
| 36 | + |
| 37 | + # Map a step output to a job output |
| 38 | + outputs: |
| 39 | + build_string: ${{ steps.gen_build_string.outputs.build_string }} |
| 40 | + release_tag: ${{ steps.gen_release_tag.outputs.release_tag }} |
| 41 | + steps: |
| 42 | + - id: gen_build_string |
| 43 | + run: echo "::set-output name=build_string::$(date +%Y.%m.%d)" |
| 44 | + - id: gen_release_tag |
| 45 | + run: echo "::set-output name=release_tag::$(date +%Y%m%d)" |
| 46 | + |
| 47 | + build: |
| 48 | + needs: init |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + nanopi_model: [R2S, R4S] |
| 52 | + |
| 53 | + runs-on: ubuntu-20.04 |
| 54 | + if: github.event.repository.owner.id == github.event.sender.id |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout repository |
| 58 | + uses: actions/checkout@main |
| 59 | + |
| 60 | + - name: Free space |
| 61 | + run: ./workflow-scripts/free_disk_space.sh |
| 62 | + |
| 63 | + - name: Setup Linux Requirements |
| 64 | + uses: ./.github/actions/setup-devenv |
| 65 | + |
| 66 | + - name: Set GITHUB_ENV |
| 67 | + run: | |
| 68 | + echo "TZ=Europe/Paris" >>$GITHUB_ENV |
| 69 | + echo "BUILD_STRING=${{ needs.init.outputs.build_string }}" >> $GITHUB_ENV |
| 70 | + echo "RELTAG=${{ needs.init.outputs.release_tag }}" >> $GITHUB_ENV |
| 71 | + echo "OPENWRT_BRANCH=${{ github.event.inputs.openwrt_branch }}" >> $GITHUB_ENV |
| 72 | + echo "NANOPI_MODEL=${{ matrix.nanopi_model }}" >> $GITHUB_ENV |
| 73 | +
|
| 74 | + - name: Show GITHUB_ENV |
| 75 | + run: echo $GITHUB_ENV |
| 76 | + |
| 77 | + - name: Clone OpenWrt source |
| 78 | + run: ./openwrt-$OPENWRT_BRANCH/steps/01_clone_openwrt.sh |
| 79 | + |
| 80 | + - name: Make working copy of OpenWrt source |
| 81 | + run: ./openwrt-$OPENWRT_BRANCH/steps/02_prepare_openwrt_folder.sh |
| 82 | + |
| 83 | + - name: Patch OpenWrt Source |
| 84 | + run: ./openwrt-$OPENWRT_BRANCH/steps/03_patch_openwrt.sh |
| 85 | + |
| 86 | + - name: Prepare package |
| 87 | + run: ./openwrt-$OPENWRT_BRANCH/steps/04-prepare_package.sh |
| 88 | + |
| 89 | + - name: Add ACL |
| 90 | + run: ./openwrt-$OPENWRT_BRANCH/steps/05-create_luci_acl.sh |
| 91 | + |
| 92 | + - name: Load toolchain seed |
| 93 | + run: ./openwrt-$OPENWRT_BRANCH/steps/06-create_config_from_seed.sh $NANOPI_MODEL full |
| 94 | + |
| 95 | + - name: Download package |
| 96 | + id: package |
| 97 | + run: | |
| 98 | + cd build/openwrt |
| 99 | + make download -j10 |
| 100 | + find dl -size -1024c -exec ls -l {} \; |
| 101 | + find dl -size -1024c -exec rm -f {} \; |
| 102 | +
|
| 103 | + - name: Make toolchain-aarch64 |
| 104 | + id: compiletoolchain |
| 105 | + continue-on-error: true |
| 106 | + run: | |
| 107 | + cd build/openwrt |
| 108 | + let make_process=$(nproc)+1 |
| 109 | + make toolchain/install -j${make_process} |
| 110 | + |
| 111 | + - name: If toolchain Error |
| 112 | + if: steps.compiletoolchain.outcome == 'failure' |
| 113 | + run: | |
| 114 | + echo '================================================================' |
| 115 | + cd build/openwrt && make toolchain/install -j1 V=s |
| 116 | + |
| 117 | +# - name: Try cleaning build_dir before packing |
| 118 | +# run: | |
| 119 | +# cd build/openwrt |
| 120 | +# make clean |
| 121 | +# #ls -l build_dir/ |
| 122 | +# #rm -rf build_dir/host build_dir/toolchain* |
| 123 | +# |
| 124 | +# - name: Pack toolchain |
| 125 | +# run: | |
| 126 | +# pwd |
| 127 | +# cd ~/work/OpenWrt-NanoPi-R2S-R4S-Builds |
| 128 | +# pwd |
| 129 | +# tar --posix -cf ../toolchain_built.tar OpenWrt-NanoPi-R2S-R4S-Builds |
| 130 | +# |
| 131 | +# - name: Upload artifact |
| 132 | +# uses: actions/upload-artifact@v2 |
| 133 | +# with: |
| 134 | +# name: toolchain_built |
| 135 | +# path: ~/work/toolchain_built.tar |
| 136 | +# |
| 137 | +# build: |
| 138 | +# needs: [init, toolchain] |
| 139 | +# runs-on: ubuntu-20.04 |
| 140 | +# steps: |
| 141 | + - name: Dump github context |
| 142 | + run: echo "$GITHUB_CONTEXT" |
| 143 | + shell: bash |
| 144 | + env: |
| 145 | + GITHUB_CONTEXT: ${{ toJson(github) }} |
| 146 | +# |
| 147 | +# - name: Retrieve toolchain artifact |
| 148 | +# uses: actions/download-artifact@v2 |
| 149 | +# with: |
| 150 | +# name: toolchain_built |
| 151 | +# path: ~/work/ |
| 152 | +# |
| 153 | +# - name: Unpack and clean toolchain artifact |
| 154 | +# run: | |
| 155 | +# cd ~/work/OpenWrt-NanoPi-R2S-R4S-Builds |
| 156 | +# tar xf ../toolchain_built.tar |
| 157 | +# rm ../toolchain_built.tar |
| 158 | +# pwd |
| 159 | +# ls -l |
| 160 | +# |
| 161 | +# - name: list files (debug) |
| 162 | +# run: ls -l |
| 163 | +# |
| 164 | +# - name: fix timestamps |
| 165 | +# run: | |
| 166 | +# cd build/openwrt |
| 167 | +# #find build_dir/{host*,toolchain-*} -name .built\* -exec touch {} \; |
| 168 | +# touch staging_dir/{host*,toolchain-*}/stamp/.* |
| 169 | +# |
| 170 | +# - name: Free space |
| 171 | +# run: | |
| 172 | +# /bin/bash ./workflow-scripts/free_disk_space.sh |
| 173 | +# df -h |
| 174 | +# |
| 175 | +# - name: Prepare Build deps |
| 176 | +# uses: ./.github/actions/setup-devenv |
| 177 | +# |
| 178 | +# - name: Set env |
| 179 | +# run: | |
| 180 | +# #echo "SSH_ACTIONS=false" >> $GITHUB_ENV |
| 181 | +# #echo "UPLOAD_BIN_DIR=false" >> $GITHUB_ENV |
| 182 | +# #echo "UPLOAD_FIRMWARE=true" >> $GITHUB_ENV |
| 183 | +# #echo "UPLOAD_RELEASE=true" >> $GITHUB_ENV |
| 184 | +# echo "TZ=Europe/Paris" >> $GITHUB_ENV |
| 185 | +# echo "BUILD_STRING=${{ needs.init.outputs.build_string }}" >> $GITHUB_ENV |
| 186 | +# echo "RELTAG=${{ needs.init.outputs.release_tag }}" >> $GITHUB_ENV |
| 187 | +# echo "OPENWRT_BRANCH=${{ github.event.inputs.openwrt_branch }}" >> $GITHUB_ENV |
| 188 | +# echo "NANOPI_MODEL=${{ github.event.inputs.nanopi_model }}" >> $GITHUB_ENV |
| 189 | + |
| 190 | + - name: Load AO seed (mini) |
| 191 | + run: ./openwrt-$OPENWRT_BRANCH/steps/06-create_config_from_seed.sh $NANOPI_MODEL mini |
| 192 | + |
| 193 | +# - name: Download package |
| 194 | +# run: | |
| 195 | +# cd build/openwrt |
| 196 | +# make defconfig |
| 197 | +# make download -j10 |
| 198 | +# find dl -size -1024c -exec ls -l {} \; |
| 199 | +# find dl -size -1024c -exec rm -f {} \; |
| 200 | + |
| 201 | + - name: Compile OpenWRT (mini) |
| 202 | + id: compileopenwrtmini |
| 203 | + continue-on-error: true |
| 204 | + run: | |
| 205 | + cd build/openwrt |
| 206 | + let make_process=$(nproc)+1 |
| 207 | + make -j${make_process} || make -j${make_process} |
| 208 | + |
| 209 | + - name: If compile openwrt Error |
| 210 | + if: steps.compileopenwrtmini.outcome == 'failure' |
| 211 | + run: | |
| 212 | + cat build/openwrt/.config |
| 213 | + echo '================================================================' |
| 214 | + cd build/openwrt && make -j1 V=s |
| 215 | + |
| 216 | + - name: Organize files (mini) |
| 217 | + id: organizemini |
| 218 | + run: ./openwrt-$OPENWRT_BRANCH/steps/organize_files.sh $NANOPI_MODEL mini $OPENWRT_BRANCH $RELTAG |
| 219 | + |
| 220 | + - name: Load AO seed (full) |
| 221 | + run: ./openwrt-$OPENWRT_BRANCH/steps/06-create_config_from_seed.sh $NANOPI_MODEL full |
| 222 | + |
| 223 | +# - name: Download package |
| 224 | +# run: | |
| 225 | +# cd build/openwrt |
| 226 | +# make defconfig |
| 227 | +# make download -j10 |
| 228 | +# find dl -size -1024c -exec ls -l {} \; |
| 229 | +# find dl -size -1024c -exec rm -f {} \; |
| 230 | + |
| 231 | + - name: Compile OpenWRT (full) |
| 232 | + id: compileopenwrtfull |
| 233 | + continue-on-error: true |
| 234 | + run: | |
| 235 | + cd build/openwrt |
| 236 | + let make_process=$(nproc)+1 |
| 237 | + make -j${make_process} || make -j${make_process} |
| 238 | + |
| 239 | + - name: If compile openwrt Error |
| 240 | + if: steps.compileopenwrtfull.outcome == 'failure' |
| 241 | + run: | |
| 242 | + cat build/openwrt/.config |
| 243 | + echo '================================================================' |
| 244 | + cd build/openwrt && make -j1 V=s |
| 245 | + |
| 246 | + - name: Organize files (full) |
| 247 | + id: organizefull |
| 248 | + run: ./openwrt-$OPENWRT_BRANCH/steps/organize_files.sh $NANOPI_MODEL full $OPENWRT_BRANCH $RELTAG |
| 249 | + |
| 250 | + - name: Create release |
| 251 | + id: create_release |
| 252 | + uses: ncipollo/release-action@v1.9.0 |
| 253 | + if: ${{ !cancelled() }} |
| 254 | + with: |
| 255 | + name: OpenWrt ${{ env.OPENWRT_BRANCH }} ${{ env.BUILD_STRING }} |
| 256 | + allowUpdates: true |
| 257 | + tag: OpenWrtAO-${{ env.OPENWRT_BRANCH }}-${{ env.RELTAG }} |
| 258 | + commit: main |
| 259 | + replacesArtifacts: true |
| 260 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 261 | + bodyFile: "openwrt-${{ env.OPENWRT_BRANCH }}/release-info.md" |
| 262 | + artifacts: ./artifact/*.zip |
0 commit comments