From 852a9fa2015fdda45a03750d3869a87ac172f51b Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Fri, 3 May 2024 18:27:23 +0200 Subject: [PATCH] ci: test commit to build everything Signed-off-by: Paul Spooren --- .github/workflows/apk.yml | 277 +++++++++++++++++++++++++++++ include/version.mk | 2 +- package/base-files/image-config.in | 2 +- 3 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/apk.yml diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml new file mode 100644 index 0000000000000..9cd325cdbdd4c --- /dev/null +++ b/.github/workflows/apk.yml @@ -0,0 +1,277 @@ +name: Build ApkWrt snapshot + +on: + push: + workflow_dispatch: + inputs: + target: + description: "Targets to build (x86/64 ath79/genric mediatek/mt7622)" + required: false + default: "x86/64 ath79/generic mediatek/mt7622" + config: + description: "Extra lines to append to the config" + required: false + default: "" + +jobs: + determine_targets: + name: Set targets + runs-on: ubuntu-latest + outputs: + target: ${{ steps.find_targets.outputs.target }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set targets + id: find_targets + run: | + if [ "${{ github.event.inputs.target }}" = "all" ]; then + export TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null | awk '{ print $1 }')" + else + if [ -n "${{ github.event.inputs.target }}" ]; then + export TARGETS="${{ github.event.inputs.target }}" + else + export TARGETS="x86/64 ath79/generic mediatek/mt7622" + fi + fi + JSON='[' + FIRST=1 + for TARGET_SUBTARGET in $TARGETS; do + TARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 1) + SUBTARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 2) + + TUPLE='{"target":"'"$TARGET"'","subtarget":"'"$SUBTARGET"'","os":"ubuntu-latest"}' + [[ $FIRST -ne 1 ]] && JSON="$JSON"',' + JSON="$JSON""$TUPLE" + FIRST=0 + done + JSON="$JSON"']' + echo -e "\n---- targets ----\n" + echo "$JSON" + echo -e "\n---- targets ----\n" + echo "target=$JSON" >> $GITHUB_OUTPUT + + build: + name: Build ${{ matrix.os }}/${{ matrix.target }}/${{ matrix.subtarget }} + needs: determine_targets + runs-on: ${{ matrix.os }} + strategy: + fail-fast: False + matrix: + include: ${{fromJson(needs.determine_targets.outputs.target)}} + + container: ghcr.io/openwrt/toolchain:${{ matrix.target }}-${{ matrix.subtarget }}-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: openwrt + + - name: Fix permission + run: | + chown -R buildbot:buildbot openwrt + + - name: Prepare prebuilt tools + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + cd "$WORKPATH" + mkdir -p staging_dir build_dir + ln -s /prebuilt_tools/staging_dir/host staging_dir/host + ln -s /prebuilt_tools/build_dir/host build_dir/host + + ./scripts/ext-tools.sh --refresh + + - name: Initialization environment + run: | + echo "TARGET=${{ matrix.target }}" >> "$GITHUB_ENV" + echo "SUBTARGET=${{ matrix.subtarget }}" >> "$GITHUB_ENV" + + - name: Update & Install feeds + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + ./scripts/feeds update -a + ./scripts/feeds install -a -p base -d m + ./scripts/feeds install -a + + - name: Set configuration + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + curl "https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/config.buildinfo" > .config + for CONFIG in ${{ github.event.inputs.config }}; do + echo "CONFIG_$CONFIG" >> .config + done + echo "CONFIG_USE_APK=y" >> .config + echo "CONFIG_BPF_TOOLCHAIN_HOST=y" >> .config + echo "CONFIG_PACKAGE_uxc=m" >> .config + echo "CONFIG_PACKAGE_uvol=m" >> .config + echo "CONFIG_PACKAGE_strace=m" >> .config + echo "CONFIG_PACKAGE_tmate=m" >> .config + echo "CONFIG_PACKAGE_luci=m" >> .config + echo "CONFIG_PACKAGE_freeswitch=m" >> .config + echo -e "\n---- config input ----\n" + cat .config + echo -e "\n---- config input ----\n" + make defconfig + echo -e "\n---- config post-defconfig ----\n" + cat .config + echo -e "\n---- config post-defconfig ----\n" + echo "${{ secrets.PUBLIC_KEY_PEM }}" > public-key.pem + echo "${{ secrets.PRIVATE_KEY_PEM }}" > private-key.pem + + - name: Setup reusable + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + echo CONFIG_DEVEL=y >> .config + echo CONFIG_AUTOREMOVE=y >> .config + + make defconfig + + - name: Configure external toolchain in container + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + ./scripts/ext-toolchain.sh \ + --toolchain /external-toolchain/$(ls /external-toolchain/ | grep openwrt-toolchain)/toolchain-* \ + --overwrite-config \ + --config ${{ env.TARGET }}/${{ env.SUBTARGET }} + + - name: Build tools + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make tools/install -j$(nproc) || \ + make tools/install V=s + + - name: Build toolchain + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make toolchain/install -j$(nproc) || \ + make toolchain/install V=s + + - name: Build target + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make target/compile -j$(nproc) IGNORE_ERRORS='n m' || \ + make target/compile IGNORE_ERRORS='n m' V=s + + - name: Build packages + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make package/apk/host/compile -j$(nproc) || \ + make package/apk/host/compile V=s + make package/compile -j$(nproc) IGNORE_ERRORS='n m' || \ + make package/compile IGNORE_ERRORS='n m' V=s + make package/index V=s + + - name: Determine Kernel version + working-directory: openwrt + run: | + export TOPDIR=$(pwd) + KERNEL_VERSION="$(make --no-print-directory -C target/linux \ + val.LINUX_VERSION val.LINUX_RELEASE val.LINUX_VERMAGIC | \ + tr '\n' '-' | head -c -1)" + echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV" + + - name: Determine architecutre + working-directory: openwrt + run: | + echo "ARCH=$(make val.ARCH_PACKAGES)" >> "$GITHUB_ENV" + + - name: Upload packages + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: apk + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }} + AWS_REGION: auto + SOURCE_DIR: openwrt/bin/packages/${{ env.ARCH }}/ + DEST_DIR: packages/${{ env.ARCH }}/ + + - name: Prepare upload of kmods + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + continue-on-error: true + run: | + KMOD_DIR="bin/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/kmods/${{ env.KERNEL_VERSION }}/" + mkdir -p "$KMOD_DIR" + cp bin/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}//packages/kmod-*.apk "$KMOD_DIR" + make package/index V=s PACKAGE_SUBDIRS="$KMOD_DIR" + + - name: Upload kmods + continue-on-error: true + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: apk + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }} + AWS_REGION: auto + SOURCE_DIR: openwrt/bin/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/kmods/${{ env.KERNEL_VERSION }}/ + DEST_DIR: targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/kmods/${{ env.KERNEL_VERSION }}/ + + - name: Install packages + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make package/install -j$(nproc) || \ + make package/install V=s + + - name: Build firmware + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make target/install -j$(nproc) || \ + make target/install V=s + + - name: Buildinfo + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make buildinfo V=s + + - name: JSON overview + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make json_overview_image_info V=s + + - name: Checksum + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + make checksum V=s + + - name: Clean build + shell: su buildbot -c "sh -e {0}" + working-directory: openwrt + run: | + rm -rf staging_dir/ build_dir + + - name: Upload target + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: apk + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }} + AWS_REGION: auto + SOURCE_DIR: openwrt/bin/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/ + DEST_DIR: targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/ diff --git a/include/version.mk b/include/version.mk index cdee0976dad29..1555c62fa2d8c 100644 --- a/include/version.mk +++ b/include/version.mk @@ -29,7 +29,7 @@ VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE)) VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION)) VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO)) -VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.openwrt.org/snapshots) +VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://apk.openwrt.ansuel.com) VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST)) VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt) diff --git a/package/base-files/image-config.in b/package/base-files/image-config.in index 2de2130b8490d..fe6c3c693faa9 100644 --- a/package/base-files/image-config.in +++ b/package/base-files/image-config.in @@ -190,7 +190,7 @@ if VERSIONOPT config VERSION_REPO string prompt "Release repository" - default "https://downloads.openwrt.org/snapshots" + default "https://apk.openwrt.ansuel.com" help This is the repository address embedded in the image, it defaults to the trunk snapshot repo; the url may contain the following placeholders: