friendlywrt.yml 6.0 KB
Newer Older
S
songchenwen 已提交
1
name: friendlywrt
S
songchenwen 已提交
2 3

on:
S
songchenwen 已提交
4
  repository_dispatch:
S
songchenwen 已提交
5 6 7
  push:
    branches: 
      - master
S
songchenwen 已提交
8
    paths:
S
songchenwen 已提交
9
      - '.github/workflows/friendlywrt.yml'
S
songchenwen 已提交
10 11 12
      - '*.sh'
  schedule:
    - cron: '0 0 * * *'
S
songchenwen 已提交
13 14 15 16

jobs:
  build:
    runs-on: ubuntu-latest
S
songchenwen 已提交
17 18 19 20
    env:
      GITHUB_TOKEN: ${{ secrets.sec_token }}
      sec_token: ${{ secrets.sec_token }}

S
songchenwen 已提交
21 22 23 24 25
    steps:
      - name: Checkout
        uses: actions/checkout@master
        with:
          ref: master
S
songchenwen 已提交
26 27 28
          fetch-depth: 0
          token: ${{ env.sec_token }}

S
songchenwen 已提交
29 30 31 32 33 34
      - name: Init Env
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          . init_env.sh
      
S
songchenwen 已提交
35 36 37 38
      - name: Repo Hash
        run: |
          ./set_repo_hash.sh Builder
      
S
songchenwen 已提交
39 40 41 42
      - name: Friendlywrt Source
        run: |
          . friendlywrt_source.sh

S
songchenwen 已提交
43
      - name: Change Feeds to Lean
S
songchenwen 已提交
44
        run: |
S
songchenwen 已提交
45 46 47 48 49 50 51 52 53 54 55
          cd friendlywrt-rk3328
          git clone https://github.com/coolsnowwolf/lede
          cd lede
          ../../set_repo_hash.sh Lean
          cd ../friendlywrt
          cp -r ../lede/package/lean package/
          sed -i 's/^src-git luci.*/src-git luci https:\/\/github.com\/coolsnowwolf\/luci/' feeds.conf.default
          sed -i 's/^src-git packages.*/src-git packages https:\/\/github.com\/coolsnowwolf\/packages/' feeds.conf.default
          ../../set_repo_hash.sh LeanLuci https://github.com/coolsnowwolf/luci.git
          ../../set_repo_hash.sh LeanPackage https://github.com/coolsnowwolf/packages.git
        
S
songchenwen 已提交
56 57 58 59
      - name: Add Packages to Lean
        run: |
          . add_packages_to_lean.sh

S
songchenwen 已提交
60
      - name: Install Openwrt Libs
S
songchenwen 已提交
61
        run: |
S
songchenwen 已提交
62 63 64 65 66
          cd friendlywrt-rk3328
          git clone https://github.com/openwrt/openwrt
          rm -rf friendlywrt/package/libs
          cp -r openwrt/package/libs friendlywrt/package/
      
S
songchenwen 已提交
67 68 69
      - name: Change Log
        id: changelog
        run: |
S
songchenwen 已提交
70 71
          git config --global user.email "action@github.com" && git config --global user.name "GitHub Action"
          ./changelog.sh FriendlyWRT
S
songchenwen 已提交
72

S
songchenwen 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85
      - name: Update Feeds
        run: |
          cd friendlywrt-rk3328/friendlywrt
          ./scripts/feeds update -a
          ./scripts/feeds install -a
        
      - name: Install Mods
        run: |
          cd friendlywrt-rk3328
          sed -i '/Load Average/i\\t\t<tr><td width="33%"><%:CPU Temperature%></td><td><%=luci.sys.exec("cut -c1-2 /sys/class/thermal/thermal_zone0/temp")%></td></tr>' friendlywrt/feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
          sed -i 's/pcdata(boardinfo.system or "?")/"ARMv8"/' friendlywrt/feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
          sed -i "/redirect_https/d" friendlywrt/package/network/services/uhttpd/files/uhttpd.config
        
S
songchenwen 已提交
86
      - name: Download Clash Binary
S
songchenwen 已提交
87
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
88 89 90 91 92 93 94 95
        run: |
          CLASH_VERSION=v0.19.0
          mkdir -p friendlywrt-rk3328/friendlywrt/package/base-files/files/usr/bin
          cd friendlywrt-rk3328/friendlywrt/package/base-files/files/usr/bin
          wget -O clash.gz https://github.com/Dreamacro/clash/releases/download/$CLASH_VERSION/clash-linux-armv8-$CLASH_VERSION.gz
          gunzip clash.gz
          chmod +x clash

S
songchenwen 已提交
96 97 98 99 100 101 102 103 104 105
      - name: Install UPX
        run: |
          mkdir -p friendlywrt-rk3328/friendlywrt/staging_dir/host/bin/
          ln -s /usr/bin/upx-ucl friendlywrt-rk3328/friendlywrt/staging_dir/host/bin/upx
  
      - name: Update Target.mk
        run: |
          cd friendlywrt-rk3328/friendlywrt/include
          sed -i 's/dnsmasq /dnsmasq-full default-settings luci /' target.mk

S
songchenwen 已提交
106
      - name: Build Config
S
songchenwen 已提交
107
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
108 109 110 111 112 113 114 115
        run: |
          cd friendlywrt-rk3328
          cat configs/config_rk3328 | grep "TARGET" > ../rk3328.config
          cat ../minimal_config.seed >> ../rk3328.config
          cat ../rk3328.config > configs/config_rk3328
          cat configs/config_rk3328
      
      - name: Build Friendlywrt
S
songchenwen 已提交
116
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
117 118 119 120 121 122
        run: |
          cd friendlywrt-rk3328
          sed -i 's/set -eu/set -u/' scripts/mk-friendlywrt.sh
          ./build.sh nanopi_r2s.mk
      
      - name: Zip Files
S
songchenwen 已提交
123
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
124 125 126 127
        run: |
          gzip friendlywrt-rk3328/out/*.img

      - name: Assemble Artifact
S
songchenwen 已提交
128
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
129 130 131 132 133 134
        id: assemble_artifact
        run: |
          rm -rf ./artifact/
          mkdir -p ./artifact/
          cd friendlywrt-rk3328/friendlywrt;./scripts/diffconfig.sh > ../../artifact/config.seed;cd ../../
          mv friendlywrt-rk3328/out/*img* ./artifact/
S
songchenwen 已提交
135
          cp friendlywrt-rk3328/friendlywrt/.config ./artifact/full.config
S
songchenwen 已提交
136 137
          zip -r artifact.zip -j artifact artifact/*
          release_tag=${{ steps.changelog.outputs.buildtag }}
S
songchenwen 已提交
138 139 140
          echo "##[set-output name=release_tag;]$release_tag"

      - name: Create Release
S
songchenwen 已提交
141
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
142 143 144 145
        id: create_release
        uses: actions/create-release@v1
        with:
          tag_name: ${{ steps.assemble_artifact.outputs.release_tag }}
S
songchenwen 已提交
146
          release_name: ${{ steps.assemble_artifact.outputs.release_tag }}
S
songchenwen 已提交
147
          body: ${{ steps.changelog.outputs.changelog }}
S
songchenwen 已提交
148 149 150 151
          draft: false
          prerelease: false

      - name: Upload Release Asset
S
songchenwen 已提交
152
        if: steps.changelog.outputs.changelog != ''
S
songchenwen 已提交
153 154 155 156 157 158 159
        id: upload-release-asset
        uses: actions/upload-release-asset@v1
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
          asset_path: ./artifact.zip
          asset_name: ${{ steps.assemble_artifact.outputs.release_tag }}-ROM.zip
          asset_content_type: application/zip
S
songchenwen 已提交
160 161 162 163 164 165
    
      - name: Push Change Log
        if: steps.changelog.outputs.changelog != ''
        run: |
          git pull --rebase --autostash
          git push