|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-20.04 |
| 10 | + steps: |
| 11 | + - name: Install dependencies |
| 12 | + run: | |
| 13 | + sudo add-apt-repository ppa:npalix/coccinelle |
| 14 | + sudo apt update |
| 15 | + sudo apt install build-essential clang flex g++ gawk gcc-multilib gettext \ |
| 16 | + git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev \ |
| 17 | + coccinelle |
| 18 | +
|
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Hook the openwrt_core URL for opkg |
| 23 | + run: | |
| 24 | + TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)" |
| 25 | + echo "ci-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S')-${GITHUB_SHA:0:8}" >version |
| 26 | + sed -i "s|%U/targets/%S/packages|https://hzyitc.github.io/openwrt-redmi-ax3000/${GITHUB_REF_NAME}/%R|" include/feeds.mk |
| 27 | +
|
| 28 | + - name: Update and install feeds |
| 29 | + run: | |
| 30 | + ./scripts/feeds update -a |
| 31 | + ./scripts/feeds install -a |
| 32 | +
|
| 33 | + - name: Configure |
| 34 | + run: | |
| 35 | + cat <<EOF | sed -E 's/^ //' >.config |
| 36 | + CONFIG_TARGET_ipq50xx=y |
| 37 | + CONFIG_TARGET_ipq50xx_arm=y |
| 38 | + CONFIG_TARGET_ipq50xx_arm_DEVICE_redmi_ax3000=y |
| 39 | +
|
| 40 | + CONFIG_ALL_NONSHARED=y |
| 41 | + CONFIG_REPRODUCIBLE_DEBUG_INFO=y |
| 42 | +
|
| 43 | + CONFIG_PACKAGE_kmod-bonding=y |
| 44 | + CONFIG_PACKAGE_kmod-qca-nss-ecm-standard=y |
| 45 | + CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe=y |
| 46 | +
|
| 47 | + CONFIG_PACKAGE_luci=y |
| 48 | + EOF |
| 49 | + make defconfig |
| 50 | +
|
| 51 | + - name: Download |
| 52 | + run: | |
| 53 | + make -j16 download |
| 54 | +
|
| 55 | + - name: Build tools |
| 56 | + run: | |
| 57 | + make -j$(nproc) tools/install |
| 58 | +
|
| 59 | + - name: Build toolchain |
| 60 | + run: | |
| 61 | + make -j$(nproc) toolchain/install |
| 62 | +
|
| 63 | + - name: Build all |
| 64 | + run: | |
| 65 | + make -j$(nproc) IGNORE_ERRORS=1 |
| 66 | +
|
| 67 | + - name: Upload bin to artifacts |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + with: |
| 70 | + name: bin-ipq50xx-arm |
| 71 | + path: bin/targets/ipq50xx/arm/* |
| 72 | + |
| 73 | + - name: Upload dl to artifacts |
| 74 | + uses: actions/upload-artifact@v3 |
| 75 | + with: |
| 76 | + name: dl |
| 77 | + path: dl/* |
| 78 | + |
| 79 | + gh-pages: |
| 80 | + needs: [ build ] |
| 81 | + runs-on: ubuntu-20.04 |
| 82 | + permissions: |
| 83 | + contents: write |
| 84 | + steps: |
| 85 | + - name: Checkout gh-pages |
| 86 | + uses: actions/checkout@v3 |
| 87 | + with: |
| 88 | + path: 'gh-pages' |
| 89 | + ref: 'gh-pages' |
| 90 | + fetch-depth: 0 |
| 91 | + |
| 92 | + - name: Configure the git user |
| 93 | + run: | |
| 94 | + git config --global user.name 'github-actions[bot]' |
| 95 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 96 | +
|
| 97 | + - name: Drop old versions |
| 98 | + run: | |
| 99 | + cd gh-pages |
| 100 | + readarray -t old_version < <(git log --format='%h' -- "${GITHUB_REF_NAME}" | tail -n +10) |
| 101 | + GIT_SEQUENCE_EDITOR="sed -i '1 i break'" git rebase -i --root |
| 102 | + for commit in "${old_version[@]}"; do |
| 103 | + sed -i "/${commit}/d" .git/rebase-merge/git-rebase-todo |
| 104 | + done |
| 105 | + git rebase --continue |
| 106 | +
|
| 107 | + - name: Download bin from artifacts |
| 108 | + uses: actions/download-artifact@v3 |
| 109 | + with: |
| 110 | + name: bin-ipq50xx-arm |
| 111 | + path: bin/ |
| 112 | + |
| 113 | + - name: Copy contents |
| 114 | + run: | |
| 115 | + version="$(cat "bin/version.buildinfo")" |
| 116 | + mkdir -p "gh-pages/${GITHUB_REF_NAME}/${version}/" |
| 117 | + cp -avr bin/packages/* "gh-pages/${GITHUB_REF_NAME}/${version}/" |
| 118 | +
|
| 119 | + - name: Commit |
| 120 | + run: | |
| 121 | + cd gh-pages |
| 122 | + git add . |
| 123 | + git commit -m "Add: ${GITHUB_REF_NAME}: $(cat ../bin/version.buildinfo)" |
| 124 | +
|
| 125 | + - name: Publish |
| 126 | + run: | |
| 127 | + cd gh-pages |
| 128 | + git push -f origin gh-pages |
| 129 | +
|
| 130 | + release: |
| 131 | + needs: [ build ] |
| 132 | + runs-on: ubuntu-20.04 |
| 133 | + permissions: |
| 134 | + contents: write |
| 135 | + steps: |
| 136 | + - name: Checkout |
| 137 | + uses: actions/checkout@v3 |
| 138 | + |
| 139 | + - name: Download dl from artifacts |
| 140 | + uses: actions/download-artifact@v3 |
| 141 | + with: |
| 142 | + name: dl |
| 143 | + path: dl/ |
| 144 | + |
| 145 | + - name: Download bin from artifacts |
| 146 | + uses: actions/download-artifact@v3 |
| 147 | + with: |
| 148 | + name: bin-ipq50xx-arm |
| 149 | + path: bin/targets/ipq50xx/arm/ |
| 150 | + |
| 151 | + - name: Tar |
| 152 | + run: | |
| 153 | + tar cvf dl.tar -C dl/ . |
| 154 | + tar cvf bin-ipq50xx.tar -C bin/targets/ipq50xx/arm/ . |
| 155 | +
|
| 156 | + - name: Release |
| 157 | + run: | |
| 158 | + TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)" |
| 159 | +
|
| 160 | + cat <<EOF | sed -E 's/^ //' >Release.md |
| 161 | + CI ${GITHUB_REF_NAME} $(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)') |
| 162 | +
|
| 163 | + # ${GITHUB_REF_NAME} |
| 164 | +
|
| 165 | + $(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)') |
| 166 | +
|
| 167 | + ## Sources |
| 168 | + $(cat bin/targets/ipq50xx/arm/feeds.buildinfo | awk -F'[ ^]' '{print $2 ": `" $4 "`"}') |
| 169 | +
|
| 170 | + ## SHA256 |
| 171 | + $(cat bin/targets/ipq50xx/arm/sha256sums | awk '{printf "%s: `%s`\n", $2, $1}' | sed -E 's/^\*//') |
| 172 | + EOF |
| 173 | +
|
| 174 | + tag="ci-${GITHUB_REF_NAME}-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S-%Z')" |
| 175 | + hub release create -t "$GITHUB_SHA" "$tag" -F Release.md \ |
| 176 | + -a bin/targets/ipq50xx/arm/sha256sums \ |
| 177 | + $(for a in bin/targets/ipq50xx/arm/*.*; do echo -a "$a"; done) \ |
| 178 | + $(for a in *.tar; do echo -a "$a"; done) |
| 179 | + env: |
| 180 | + GITHUB_TOKEN: ${{ github.token }} |
0 commit comments