diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000000..25a6103167c939 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,186 @@ +name: CI + +on: + workflow_dispatch: + push: + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - name: Install dependencies + run: | + sudo add-apt-repository ppa:npalix/coccinelle + sudo apt update + sudo apt install build-essential clang flex g++ gawk gcc-multilib gettext \ + git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev \ + coccinelle + + - name: Maximize build space + uses: easimon/maximize-build-space@master + + - name: Checkout + uses: actions/checkout@v3 + + - name: Hook the openwrt_core URL for opkg + run: | + TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)" + echo "ci-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S')-${GITHUB_SHA:0:8}" >version + sed -i "s|%U/targets/%S/packages|https://hzyitc.github.io/openwrt-redmi-ax3000/${GITHUB_REF_NAME}/%R|" include/feeds.mk + + - name: Update and install feeds + run: | + ./scripts/feeds update -a + ./scripts/feeds install -a + + - name: Configure + run: | + cat <.config + CONFIG_TARGET_ipq50xx=y + CONFIG_TARGET_ipq50xx_arm=y + CONFIG_TARGET_ipq50xx_arm_DEVICE_redmi_ax3000=y + + CONFIG_IB=y + # CONFIG_IB_STANDALONE is not set + CONFIG_SDK=y + CONFIG_MAKE_TOOLCHAIN=y + + CONFIG_REPRODUCIBLE_DEBUG_INFO=y + + CONFIG_PACKAGE_kmod-qca-nss-ecm-standard=y + CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe=y + + CONFIG_PACKAGE_luci=y + EOF + make defconfig + + - name: Download + run: | + make -j16 download + + - name: Build tools + run: | + make -j$(nproc) tools/install + + - name: Build toolchain + run: | + make -j$(nproc) toolchain/install + + - name: Build all + run: | + make -j$(nproc) + + - name: Upload bin to artifacts + uses: actions/upload-artifact@v3 + with: + name: bin-ipq50xx-arm + path: bin/targets/ipq50xx/arm/* + + - name: Upload dl to artifacts + uses: actions/upload-artifact@v3 + with: + name: dl + path: dl/* + + gh-pages: + needs: [ build ] + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: Checkout gh-pages + uses: actions/checkout@v3 + with: + path: 'gh-pages' + ref: 'gh-pages' + fetch-depth: 0 + + - name: Configure the git user + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Drop old versions + run: | + cd gh-pages + readarray -t old_version < <(git log --format='%h' -- "${GITHUB_REF_NAME}" | tail -n +10) + GIT_SEQUENCE_EDITOR="sed -i '1 i break'" git rebase -i --root + for commit in "${old_version[@]}"; do + sed -i "/${commit}/d" .git/rebase-merge/git-rebase-todo + done + git rebase --continue + + - name: Download bin from artifacts + uses: actions/download-artifact@v3 + with: + name: bin-ipq50xx-arm + path: bin/ + + - name: Copy contents + run: | + version="$(cat "bin/version.buildinfo")" + mkdir -p "gh-pages/${GITHUB_REF_NAME}/${version}/" + cp -avr bin/packages/* "gh-pages/${GITHUB_REF_NAME}/${version}/" + + - name: Commit + run: | + cd gh-pages + git add . + git commit -m "Add: ${GITHUB_REF_NAME}: $(cat ../bin/version.buildinfo)" + + - name: Publish + run: | + cd gh-pages + git push -f origin gh-pages + + release: + needs: [ build ] + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download dl from artifacts + uses: actions/download-artifact@v3 + with: + name: dl + path: dl/ + + - name: Download bin from artifacts + uses: actions/download-artifact@v3 + with: + name: bin-ipq50xx-arm + path: bin/targets/ipq50xx/arm/ + + - name: Tar + run: | + tar cvf dl.tar -C dl/ . + tar cvf bin-ipq50xx.tar -C bin/targets/ipq50xx/arm/ . + + - name: Release + run: | + TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)" + + cat <Release.md + CI ${GITHUB_REF_NAME} $(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)') + + # ${GITHUB_REF_NAME} + + $(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)') + + ## Sources + $(cat bin/targets/ipq50xx/arm/feeds.buildinfo | awk -F'[ ^]' '{print $2 ": `" $4 "`"}') + + ## SHA256 + $(cat bin/targets/ipq50xx/arm/sha256sums | awk '{printf "%s: `%s`\n", $2, $1}' | sed -E 's/^\*//') + EOF + + tag="ci-${GITHUB_REF_NAME}-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S-%Z')" + hub release create -t "$GITHUB_SHA" "$tag" -F Release.md \ + -a bin/targets/ipq50xx/arm/sha256sums \ + $(for a in bin/targets/ipq50xx/arm/*.*; do echo -a "$a"; done) \ + $(for a in *.tar; do echo -a "$a"; done) + env: + GITHUB_TOKEN: ${{ github.token }}