From 8464336a64e0dd47b034d28ff574ce6c85027297 Mon Sep 17 00:00:00 2001 From: phnzb <139914799+phnzb@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:23:23 +0300 Subject: [PATCH] Build workflows update (#457) --- .github/workflows/android.yml | 103 +++++++++++--- .github/workflows/build.yml | 16 +-- .github/workflows/docker.yml | 215 +++++++++++++++++++----------- .github/workflows/freebsd.yml | 38 +++--- .github/workflows/linux-pkg.yml | 9 +- .github/workflows/linux.yml | 106 ++++++++++++--- .github/workflows/osx.yml | 10 +- .github/workflows/qnap-repack.yml | 17 ++- .github/workflows/tests.yml | 1 + .github/workflows/windows.yml | 98 ++++++++++++-- CMakeLists.txt | 16 ++- docker/Dockerfile | 2 +- linux/build-info.md | 2 +- linux/build-nzbget.sh | 5 +- windows/build-nzbget.ps1 | 35 ++--- 15 files changed, 470 insertions(+), 203 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 0738b161d..6698e13c7 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -4,49 +4,116 @@ on: workflow_call: workflow_dispatch: +env: + BUILD_ARCHS: "aarch64-ndk armhf-ndk i686-ndk x86_64-ndk" + BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'release debug' || 'release' }} + BUILD_TESTING: ${{ (github.ref_name != 'main') && 'testing' || '' }} + jobs: - build: - runs-on: [self-hosted, nzbget-android] + + prepare-build-matrix: + runs-on: ubuntu-24.04 + outputs: + archs: ${{ steps.matrix-vars.outputs.ARCHS }} + types: ${{ steps.matrix-vars.outputs.TYPES }} + steps: + + - name: Calculate matrix variables + id: matrix-vars + run: | + echo ARCHS=[\"$BUILD_ARCHS\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT" + echo TYPES=[\"$BUILD_TYPES\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT" + + build-bin: + runs-on: ubuntu-24.04 + needs: prepare-build-matrix + strategy: + matrix: + arch: ${{ fromJSON(needs.prepare-build-matrix.outputs.archs) }} + type: ${{ fromJSON(needs.prepare-build-matrix.outputs.types) }} steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build + - name: Prepare ${{ matrix.arch }} / ${{ matrix.type }} environment run: | - BUILD_PARAMS="android bin installer" - if [ "$GITHUB_REF_NAME" == "develop" ] || [ "$GITHUB_REF_NAME" == "main" ]; then - BUILD_PARAMS="$BUILD_PARAMS debug release" - else - BUILD_PARAMS="$BUILD_PARAMS release" - fi - if [ "$GITHUB_REF_NAME" != "main" ]; then - BUILD_PARAMS="$BUILD_PARAMS testing" - fi - bash linux/build-nzbget.sh $BUILD_PARAMS + sudo mkdir -p /build + sudo chown $USER:$USER /build + mkdir -p /build/android + mkdir -p /build/lib + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/android-${{ matrix.arch }}.tar.gz -o /build/android/ndk.tar.gz + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/lib-${{ matrix.arch }}.tar.gz -o /build/lib/lib.tar.gz + tar zxf /build/android/ndk.tar.gz -C /build/android + tar zxf /build/lib/lib.tar.gz -C /build/lib + sudo apt-get update + sudo apt-get install -y autoconf automake bc build-essential cmake cpio curl file git libtool pkg-config rsync unzip wget libtinfo6 + + - name: Build + run: bash linux/build-nzbget.sh bin ${{ matrix.arch }} ${{ matrix.type }} ${{ env.BUILD_TESTING }} - name: Upload full build log on failure uses: actions/upload-artifact@v4 if: failure() with: - name: nzbget-android-build-log + name: nzbget-android-${{ matrix.arch }}-${{ matrix.type }}-build-log path: build/*/build.log retention-days: 5 + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: nzbget-${{ matrix.arch }}-${{ matrix.type }}-bin + path: build/*.tar.gz + retention-days: 5 + + build-installer: + runs-on: ubuntu-24.04 + needs: build-bin + + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Prepare build environment + run: | + sudo mkdir -p /build + sudo chown $USER:$USER /build + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/android-unpack.tar.gz -o /build/unpack.tar.gz + tar zxf /build/unpack.tar.gz -C /build + + - name: Download build artifacts + uses: actions/download-artifact@v4 + + - name: Build installer + run: | + mkdir -p build + for ARCH in ${{ env.BUILD_ARCHS }}; do + for TYPE in ${{ env.BUILD_TYPES }}; do + cp nzbget-$ARCH-$TYPE-bin/*.tar.gz build/ + done + done + bash linux/build-nzbget.sh android installer ${{ env.BUILD_TYPES }} ${{ env.BUILD_TESTING }} + - name: Rename build artifacts if: github.ref_name != 'main' && github.ref_name != 'develop' run: | cd build - SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-android.run" + SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-android" for FILE in *.run; do [ -f $FILE ] || continue - NEW_FILE=${FILE/-bin-android.run/$SUFFIX} + NEW_FILE=${FILE/-bin-android/$SUFFIX} mv $FILE $NEW_FILE done + - name: Delete unneeded platform-specific artifacts + uses: geekyeggo/delete-artifact@v5 + with: + name: | + nzbget-*-*-*-bin + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5ad28809e..8516c7977 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: permissions: actions: write secrets: inherit - + build-linux-pkg: uses: ./.github/workflows/linux-pkg.yml with: @@ -45,15 +45,15 @@ jobs: generate-signatures: env: PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: [build-windows, build-linux, build-osx, build-android, build-freebsd, repack-qnap, build-linux-pkg] permissions: actions: write steps: - + - name: Download build artifacts uses: actions/download-artifact@v4 - + - name: Generate signatures run: | mkdir -p builds @@ -97,7 +97,7 @@ jobs: cd .. echo echo "Done." - + - name: Upload build artifacts with signatures uses: actions/upload-artifact@v4 with: @@ -105,7 +105,7 @@ jobs: path: builds/* retention-days: 5 - - name: Delete unneded platform-specific artifacts + - name: Delete unneeded platform-specific artifacts uses: geekyeggo/delete-artifact@v4 with: name: | @@ -116,7 +116,7 @@ jobs: nzbget-osx-installers nzbget-qnap-packages - - name: Delete unneded linux packages artifacts + - name: Delete unneeded linux packages artifacts uses: geekyeggo/delete-artifact@v4 with: name: | @@ -130,7 +130,7 @@ jobs: contents: write if: github.ref_name == 'develop' steps: - + - name: Delete tag and release uses: dev-drprasad/delete-tag-and-release@v0.2.1 with: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 83e94b406..2b8e002cf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,86 +13,143 @@ env: REGISTRY_IMAGE: nzbgetcom/nzbget jobs: + build: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + - platform: linux/arm/v7 + runner: ubuntu-24.04 + - platform: linux/arm64 + runner: ubuntu-24.04 + runs-on: ${{ matrix.runner }} + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Prepare + id: prepare + run: | + platform=${{ matrix.platform }} + echo "platform-slug=${platform//\//-}" >> $GITHUB_OUTPUT + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_SUMMARY: false + with: + context: . + file: docker/Dockerfile + platforms: ${{ matrix.platform }} + provenance: false + outputs: "type=image,oci-mediatypes=false,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true" + build-args: | + "NZBGET_RELEASE=${{ github.ref_name }}" + "MAKE_JOBS=4" + + - name: Export digest + run: | + rm -rf digests + mkdir -p digests + digest="${{ steps.build.outputs.digest }}" + touch "digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ steps.prepare.outputs.platform-slug }} + path: digests/* + if-no-files-found: error + retention-days: 1 + + merge: + runs-on: ubuntu-24.04 + needs: build permissions: packages: write - steps: - - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Generate image tags - id: gen_tags - run: | - if [[ "$GITHUB_REF_NAME" == "develop" ]]; then - TAG="testing" - fi - if [[ "$GITHUB_REF_NAME" == "main" ]]; then - TAG="latest" - fi - if [[ $GITHUB_REF == 'refs/tags/'* ]]; then - TAG="${GITHUB_REF/refs\/tags\//}" - fi - if [[ "$TAG" == "" ]]; then - TAG="${GITHUB_REF_NAME/\//-}" - fi - if [[ "$GITHUB_REF_NAME" == "develop" ]] || [[ "$GITHUB_REF_NAME" == "main" ]] || [[ $GITHUB_REF == 'refs/tags/'* ]]; then - TAGS="${{ env.REGISTRY_IMAGE }}:$TAG,ghcr.io/${{ env.REGISTRY_IMAGE }}:$TAG" - else - TAGS="${{ env.REGISTRY_IMAGE }}:$TAG" - fi - echo "tags=$TAGS" >> $GITHUB_OUTPUT - echo "version=$TAG" >> $GITHUB_OUTPUT - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: docker/Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7 - provenance: false - push: true - tags: ${{ steps.gen_tags.outputs.tags }} - outputs: "type=image,oci-mediatypes=false,name=${{ env.REGISTRY_IMAGE }}" - build-args: | - "NZBGET_RELEASE=${{ github.ref_name }}" - "MAKE_JOBS=2" - - - name: Update Docker Hub Description - if: github.ref_name == 'main' - uses: peter-evans/dockerhub-description@v4 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ env.REGISTRY_IMAGE }} - readme-filepath: ./docker/README.md - - - name: Cleanup ghcr.io from outdated images - uses: miklinux/ghcr-cleanup-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - package-owner: nzbgetcom - package-name: nzbget - delete-orphans: true - dry-run: false + + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: digests + pattern: digests-* + merge-multiple: true + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate image tag + id: gen-tag + run: | + case $GITHUB_REF_NAME in + develop) + TAG="testing" + ;; + main) + TAG="latest" + ;; + refs/tags/*) + TAG="${GITHUB_REF/refs\/tags\//}" + ;; + *) + TAG="${GITHUB_REF_NAME/\//-}" + ;; + esac + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Create manifest list, push and inspect + run: | + cd digests + docker manifest create ${{ env.REGISTRY_IMAGE }}:${{ steps.gen-tag.outputs.tag }} $(printf -- '--amend ${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + docker manifest push ${{ env.REGISTRY_IMAGE }}:${{ steps.gen-tag.outputs.tag }} + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.gen-tag.outputs.tag }} + if [[ "$GITHUB_REF_NAME" == "develop" ]] || [[ "$GITHUB_REF_NAME" == "main" ]] || [[ $GITHUB_REF == 'refs/tags/'* ]]; then + docker buildx imagetools create -t ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ steps.gen-tag.outputs.tag }} ${{ env.REGISTRY_IMAGE }}:${{ steps.gen-tag.outputs.tag }} + docker buildx imagetools inspect ghcr.io/${{ env.REGISTRY_IMAGE }}:${{ steps.gen-tag.outputs.tag }} + fi + + - name: Update Docker Hub Description + if: github.ref_name == 'main' + uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ env.REGISTRY_IMAGE }} + readme-filepath: ./docker/README.md + + - name: Cleanup ghcr.io from outdated images + uses: miklinux/ghcr-cleanup-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + package-owner: nzbgetcom + package-name: nzbget + delete-orphans: true + dry-run: false diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index ffdb776aa..954cde5b5 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -4,29 +4,35 @@ on: workflow_call: workflow_dispatch: +env: + BUILD_ARCHS: "x86_64-bsd" + BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'release debug' || 'release' }} + BUILD_TESTING: ${{ (github.ref_name != 'main') && 'testing' || '' }} + jobs: build: - runs-on: [self-hosted, nzbget-freebsd] + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build + - name: Prepare freebsd build environment run: | - BUILD_PARAMS="freebsd bin installer" - if [ "$GITHUB_REF_NAME" == "develop" ] || [ "$GITHUB_REF_NAME" == "main" ]; then - BUILD_PARAMS="$BUILD_PARAMS debug release" - else - BUILD_PARAMS="$BUILD_PARAMS release" - fi - if [ "$GITHUB_REF_NAME" != "main" ]; then - BUILD_PARAMS="$BUILD_PARAMS testing" - fi - bash linux/build-nzbget.sh $BUILD_PARAMS + sudo mkdir -p /build + sudo chown $USER:$USER /build + mkdir -p /build/freebsd + mkdir -p /build/lib + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/freebsd-sysroot.tar.gz -o /build/freebsd/sysroot.tar.gz + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/lib-x86_64-bsd.tar.gz -o /build/lib/lib.tar.gz + tar zxf /build/freebsd/sysroot.tar.gz -C /build/freebsd + tar zxf /build/lib/lib.tar.gz -C /build/lib + sudo apt-get update + sudo apt-get install -y autoconf automake bc build-essential cmake cpio curl file git libtool pkg-config rsync unzip wget libtinfo6 clang-14 + + - name: Build + run: bash linux/build-nzbget.sh bin installer ${{ env.BUILD_ARCHS }} ${{ env.BUILD_TYPES }} ${{ env.BUILD_TESTING }} - name: Upload full build log on failure uses: actions/upload-artifact@v4 @@ -40,10 +46,10 @@ jobs: if: github.ref_name != 'main' && github.ref_name != 'develop' run: | cd build - SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-freebsd.run" + SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-freebsd" for FILE in *.run; do [ -f $FILE ] || continue - NEW_FILE=${FILE/-bin-freebsd.run/$SUFFIX} + NEW_FILE=${FILE/-bin-freebsd/$SUFFIX} mv $FILE $NEW_FILE done diff --git a/.github/workflows/linux-pkg.yml b/.github/workflows/linux-pkg.yml index f91c68da3..2db28d0bb 100644 --- a/.github/workflows/linux-pkg.yml +++ b/.github/workflows/linux-pkg.yml @@ -16,7 +16,7 @@ jobs: if: ${{ inputs.external_call == false }} build-pkg: - runs-on: [self-hosted, nzbget-linux] + runs-on: ubuntu-24.04 needs: [build-linux] if: always() permissions: @@ -26,15 +26,14 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Download build artifacts uses: actions/download-artifact@v4 - name: Build DEB and RPM packages run: | - sudo apt-get update && sudo apt-get install rpm -y + sudo apt-get update + sudo apt-get install rpm -y bash linux/pkg/build-pkg.sh - name: Upload DEB build artifacts @@ -51,7 +50,7 @@ jobs: path: build/rpm/*.rpm retention-days: 5 - - name: Delete unneded linux artifacts + - name: Delete unneeded linux artifacts if: ${{ inputs.external_call == false }} uses: geekyeggo/delete-artifact@v4 with: diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2a1b1d508..81641e330 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,52 +1,118 @@ -name: linux build +name: linux build on: workflow_call: workflow_dispatch: +env: + BUILD_ARCHS: "aarch64 armel armhf i686 mipseb mipsel ppc500 ppc6xx riscv64 x86_64" + BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'release debug' || 'release' }} + BUILD_TESTING: ${{ (github.ref_name != 'main') && 'testing' || '' }} + jobs: - build: - runs-on: [self-hosted, nzbget-linux] + prepare-build-matrix: + runs-on: ubuntu-24.04 + outputs: + archs: ${{ steps.matrix-vars.outputs.ARCHS }} + types: ${{ steps.matrix-vars.outputs.TYPES }} + steps: + + - name: Calculate matrix variables + id: matrix-vars + run: | + echo ARCHS=[\"$BUILD_ARCHS\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT" + echo TYPES=[\"$BUILD_TYPES\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT" + + build-bin: + runs-on: ubuntu-24.04 + needs: prepare-build-matrix + strategy: + matrix: + arch: ${{ fromJSON(needs.prepare-build-matrix.outputs.archs) }} + type: ${{ fromJSON(needs.prepare-build-matrix.outputs.types) }} steps: - + - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build + - name: Prepare ${{ matrix.arch }} / ${{ matrix.type }} environment run: | - BUILD_PARAMS="linux bin installer" - if [ "$GITHUB_REF_NAME" == "develop" ] || [ "$GITHUB_REF_NAME" == "main" ]; then - BUILD_PARAMS="$BUILD_PARAMS debug release" - else - BUILD_PARAMS="$BUILD_PARAMS release" - fi - if [ "$GITHUB_REF_NAME" != "main" ]; then - BUILD_PARAMS="$BUILD_PARAMS testing" - fi - bash linux/build-nzbget.sh $BUILD_PARAMS + sudo mkdir -p /build + sudo chown $USER:$USER /build + mkdir -p /build/buildroot + mkdir -p /build/lib + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/buildroot-${{ matrix.arch }}.tar.gz -o /build/buildroot/buildroot.tar.gz + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/lib-${{ matrix.arch }}.tar.gz -o /build/lib/lib.tar.gz + tar zxf /build/buildroot/buildroot.tar.gz -C /build/buildroot + tar zxf /build/lib/lib.tar.gz -C /build/lib + sudo apt-get update + sudo apt-get install -y autoconf automake bc build-essential cmake cpio curl file git libtool pkg-config rsync unzip wget libtinfo6 + + - name: Build + run: bash linux/build-nzbget.sh bin ${{ matrix.arch }} ${{ matrix.type }} ${{ env.BUILD_TESTING }} - name: Upload full build log on failure uses: actions/upload-artifact@v4 if: failure() with: - name: nzbget-linux-build-log + name: nzbget-linux-${{ matrix.arch }}-${{ matrix.type }}-build-log path: build/*/build.log retention-days: 5 + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: nzbget-${{ matrix.arch }}-${{ matrix.type }}-bin + path: build/*.tar.gz + retention-days: 5 + + build-installer: + runs-on: ubuntu-24.04 + needs: build-bin + + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Prepare build environment + run: | + sudo mkdir -p /build + sudo chown $USER:$USER /build + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/linux-unpack.tar.gz -o /build/unpack.tar.gz + tar zxf /build/unpack.tar.gz -C /build + + - name: Download build artifacts + uses: actions/download-artifact@v4 + + - name: Build installer + run: | + mkdir -p build + for ARCH in ${{ env.BUILD_ARCHS }}; do + for TYPE in ${{ env.BUILD_TYPES }}; do + cp nzbget-$ARCH-$TYPE-bin/*.tar.gz build/ + done + done + bash linux/build-nzbget.sh linux installer ${{ env.BUILD_TYPES }} ${{ env.BUILD_TESTING }} + - name: Rename build artifacts if: github.ref_name != 'main' && github.ref_name != 'develop' run: | cd build - SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-linux.run" + SUFFIX="-${GITHUB_REF_NAME/\//-}-bin-linux" for FILE in *.run; do [ -f $FILE ] || continue - NEW_FILE=${FILE/-bin-linux.run/$SUFFIX} + NEW_FILE=${FILE/-bin-linux/$SUFFIX} mv $FILE $NEW_FILE done + - name: Delete unneeded platform-specific artifacts + uses: geekyeggo/delete-artifact@v5 + with: + name: | + nzbget-*-*-bin + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index b32990c6e..6f9d1cbb6 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -12,8 +12,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Build run: | @@ -56,8 +54,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Build run: | @@ -101,8 +97,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Download build artifacts uses: actions/download-artifact@v4 @@ -129,7 +123,7 @@ jobs: retention-days: 5 combine-osx-artifacts: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: [build-x64, sign-universal] permissions: actions: write @@ -151,7 +145,7 @@ jobs: path: nzbget-osx-installers/* retention-days: 5 - - name: Delete unneded artifacts + - name: Delete unneeded artifacts uses: geekyeggo/delete-artifact@v4 with: name: | diff --git a/.github/workflows/qnap-repack.yml b/.github/workflows/qnap-repack.yml index 357e92231..adf285676 100644 --- a/.github/workflows/qnap-repack.yml +++ b/.github/workflows/qnap-repack.yml @@ -16,7 +16,7 @@ jobs: if: ${{ inputs.external_call == false }} repack: - runs-on: [self-hosted, nzbget-qnap] + runs-on: ubuntu-24.04 needs: [build-linux] if: always() permissions: @@ -26,15 +26,20 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Download build artifacts uses: actions/download-artifact@v4 + - name: Download QDK and prepare environment + run: | + sudo mkdir -p /qnap + sudo chown $USER:$USER /qnap + curl -L https://github.com/nzbgetcom/build-files/releases/download/v1.0/QDK.tar.gz -o $HOME/QDK.tar.gz + tar zxf $HOME/QDK.tar.gz -C $HOME + - name: Repack linux installer for QNAP run: | - export PATH="$PATH:/usr/share/QDK/bin" + export PATH="$PATH:$HOME/QDK/bin" bash qnap/repack-nzbget.sh - name: Rename build artifacts @@ -46,7 +51,7 @@ jobs: for FILE in *.qpkg; do [ -f $FILE ] || continue NEW_FILE=${FILE/$VERSION/$NEW_VERSION} - sudo mv $FILE $NEW_FILE + sudo mv $FILE $NEW_FILE done - name: Upload build artifacts @@ -56,7 +61,7 @@ jobs: path: /qnap/nzbget/build/*.qpkg retention-days: 5 - - name: Delete unneded linux artifacts + - name: Delete unneeded linux artifacts if: ${{ inputs.external_call == false }} uses: geekyeggo/delete-artifact@v4 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9aa319423..d02488e94 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,6 +53,7 @@ jobs: - name: Prepare environment run: | + sudo apt-get update sudo apt-get install -y cmake libxml2-dev libssl-dev libncurses-dev libboost-all-dev - name: Checkout diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1a755298c..63335f72f 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,28 +1,91 @@ -name: windows build +name: windows build on: workflow_call: workflow_dispatch: +env: + BUILD_ARCHS: "32 64" + BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'Release Debug' || 'Release' }} + BUILD_TESTING: ${{ (github.ref_name != 'main') && '-BuildTesting' || '' }} + jobs: - build: - runs-on: [self-hosted, windows] + prepare-build-matrix: + runs-on: ubuntu-24.04 + outputs: + archs: ${{ steps.matrix-vars.outputs.ARCHS }} + types: ${{ steps.matrix-vars.outputs.TYPES }} + build-args: ${{ steps.matrix-vars.outputs.BUILD_ARGS }} + steps: + + - name: Calculate matrix variables + id: matrix-vars + run: | + echo ARCHS=[\"$BUILD_ARCHS\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT" + echo TYPES=[\"$BUILD_TYPES\"] | sed 's| |","|g' >> "$GITHUB_OUTPUT" + BUILD_ARGS=$BUILD_TESTING + for BUILD_PARAM in $BUILD_ARCHS $BUILD_TYPES; do + BUILD_ARGS=$(echo $BUILD_ARGS -Build$BUILD_PARAM | xargs) + done + echo BUILD_ARGS=$BUILD_ARGS >> "$GITHUB_OUTPUT" + + build-bin: + runs-on: windows-2022 + needs: prepare-build-matrix + strategy: + matrix: + arch: ${{ fromJSON(needs.prepare-build-matrix.outputs.archs) }} + type: ${{ fromJSON(needs.prepare-build-matrix.outputs.types) }} steps: - + - name: Checkout uses: actions/checkout@v4 - - name: Build + - name: Prepare build environment run: | - $BuildParams="-BuildRelease -Build32 -Build64 -BuildSetup" - If (-not ($env:GITHUB_REF_NAME -eq "main")) { - $BuildParams="$BuildParams -BuildTesting" - } - If (($env:GITHUB_REF_NAME -eq "main") -or ($env:GITHUB_REF_NAME -eq "develop")) { - $BuildParams="$BuildParams -BuildDebug" - } - Invoke-Expression "windows\build-nzbget.ps1 $BuildParams" + $ProgressPreference = "SilentlyContinue" + Invoke-WebRequest https://github.com/nzbgetcom/build-files/releases/download/v1.0/vcpkg-windows-x${{ matrix.arch }}.zip -OutFile "${{ github.workspace }}\vcpkg.zip" + Rename-Item -path "C:\vcpkg" -NewName "C:\vcpkg.old" + Expand-Archive -Path "${{ github.workspace }}\vcpkg.zip" -DestinationPath C:\ + Invoke-WebRequest https://github.com/nzbgetcom/build-files/releases/download/v1.0/nzbget-windows-tools.zip -OutFile "${{ github.workspace }}\tools.zip" + Expand-Archive -Path "${{ github.workspace }}\tools.zip" -DestinationPath C:\ + + - name: Build nzbget ${{ matrix.arch }}-bit / ${{ matrix.type }} binary + run: Invoke-Expression "windows\build-nzbget.ps1 -Build${{ matrix.type }} -Build${{ matrix.arch }} ${{ env.BUILD_TESTING }}" + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.type }}${{ matrix.arch }} + path: | + build\${{ matrix.type }}${{ matrix.arch }}\${{ matrix.type }}\*.exe + build\${{ matrix.type }}${{ matrix.arch }}\*.nsi + retention-days: 5 + + build-installer: + runs-on: windows-2022 + needs: [build-bin, prepare-build-matrix] + + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + + - name: Prepare build environment + run: | + $ProgressPreference = "SilentlyContinue" + Invoke-WebRequest https://github.com/nzbgetcom/build-files/releases/download/v1.0/nzbget-windows-tools.zip -OutFile "${{ github.workspace }}\tools.zip" + Expand-Archive -Path "${{ github.workspace }}\tools.zip" -DestinationPath C:\ + New-Item build -ItemType Directory -ErrorAction SilentlyContinue | Out-Null + Copy-Item Release* build -Recurse -ErrorAction SilentlyContinue + Copy-Item Debug* build -Recurse -ErrorAction SilentlyContinue + + - name: Build nzbget windows installer + run: Invoke-Expression "windows\build-nzbget.ps1 -BuildSetup ${{ needs.prepare-build-matrix.outputs.build-args }}" - name: Rename build artifacts if: github.ref_name != 'main' && github.ref_name != 'develop' @@ -30,9 +93,16 @@ jobs: $Output="build" $Suffix = $env:GITHUB_REF_NAME.Replace("/","-") ForEach ($File In Get-ChildItem -Path $Output -Filter "*.exe") { - Rename-Item -Path "$Output\$($File.Name)" -NewName $File.Name.Replace("-bin-windows-setup.exe", "-$Suffix-bin-windows-setup.exe") + Rename-Item -Path "$Output\$($File.Name)" -NewName $File.Name.Replace("-bin-windows-", "-$Suffix-bin-windows-") } + - name: Delete unneeded platform-specific artifacts + uses: geekyeggo/delete-artifact@v5 + with: + name: | + Release* + Debug* + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index ac366bc93..0427a5508 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,13 +41,15 @@ if(NOT BUILD_ONLY_TESTS) add_executable(${PACKAGE} ${SRC}) target_precompile_headers(${PACKAGE} PRIVATE ${CMAKE_SOURCE_DIR}/daemon/main/nzbget.h) - if(CMAKE_BUILD_TYPE STREQUAL "Release") - add_custom_command( - TARGET ${PACKAGE} POST_BUILD - DEPENDS ${PACKAGE} - COMMAND ${CMAKE_STRIP} - ARGS ${PACKAGE} - ) + if(NOT WIN32) + if(CMAKE_BUILD_TYPE STREQUAL "Release") + add_custom_command( + TARGET ${PACKAGE} POST_BUILD + DEPENDS ${PACKAGE} + COMMAND ${CMAKE_STRIP} + ARGS ${PACKAGE} + ) + endif() endif() endif() diff --git a/docker/Dockerfile b/docker/Dockerfile index ffa5c7c8b..71ef6815f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -82,7 +82,7 @@ LABEL org.opencontainers.image.description="NZBGet from nzbget.com, version ${NZ LABEL org.opencontainers.image.source="https://github.com/nzbgetcom/nzbget" LABEL maintainer="nzbget@nzbget.com" -ENV TERM linux +ENV TERM=linux COPY --from=build /usr/bin/unrar /usr/bin/unrar COPY --from=build /usr/bin/unrar7 /usr/bin/unrar7 COPY --from=build /app/nzbget/ /app/nzbget/ diff --git a/linux/build-info.md b/linux/build-info.md index c6ff0684d..0c938d6ce 100644 --- a/linux/build-info.md +++ b/linux/build-info.md @@ -13,7 +13,7 @@ Supported freebsd architectures: `x86_64-bsd` 1. Linux x86_64 host (Ubuntu 22.04 LTS for example) 2. Installed build dependencies (Ubuntu/Debian example): ``` -sudo apt install autoconf automake bc build-essential cmake cpio curl file git libtool pkg-config rsync unzip wget libtinfo5 clang ldd +sudo apt install autoconf automake bc build-essential cmake cpio curl file git libtool pkg-config rsync unzip wget libtinfo6 clang-14 ``` 3. Installed buildroot - one per architecture (see [Buildroot setup](#buildroot-setup) below) 4. Installed Android NDK and standalone Android toolkits - one per architecture (see [NDK setup](#ndk-setup) below) diff --git a/linux/build-nzbget.sh b/linux/build-nzbget.sh index b5346862e..a22958c24 100755 --- a/linux/build-nzbget.sh +++ b/linux/build-nzbget.sh @@ -212,8 +212,8 @@ build_lib() URL=$1 LIB_SRC_FILE=${URL##*/} LIB=$(echo $LIB_SRC_FILE | cut -d- -f 1) - download_lib_source $LIB $URL if [ ! -d "$LIB_PATH/$ARCH/$LIB" ]; then + download_lib_source $LIB $URL mkdir -p "$LIB_PATH/$ARCH" cp "$LIB_SRC_PATH/$LIB_SRC_FILE" "$LIB_PATH/$ARCH" cd "$LIB_PATH/$ARCH" @@ -805,10 +805,7 @@ build_installer() } NZBGET_ROOT=$PWD - -# cleanup shared and build directories mkdir -p $OUTPUTDIR -rm -rf $OUTPUTDIR/* parse_args $@ print_config diff --git a/windows/build-nzbget.ps1 b/windows/build-nzbget.ps1 index c75db0b67..9bd03bca8 100644 --- a/windows/build-nzbget.ps1 +++ b/windows/build-nzbget.ps1 @@ -179,24 +179,26 @@ Function BuildTarget($Type, $Bits) { New-Item -Path "$BuildDir\$Type$Bits" -ItemType Directory -Force | Out-Null Set-Location "$BuildDir\$Type$Bits" - $CMakeCmd="cmake ..\.. -DCMAKE_TOOLCHAIN_FILE=$VcpkgDir\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=$Arch-windows-static -A $Platform" + If (-not (Test-Path "$Type\nzbget.exe")) { + $CMakeCmd="cmake ..\.. -DCMAKE_TOOLCHAIN_FILE=$VcpkgDir\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=$Arch-windows-static -A $Platform" - If ($Type -eq "Debug" ) { - $CMakeCmd="$CMakeCmd -DCMAKE_BUILD_TYPE=Debug" - } + If ($Type -eq "Debug" ) { + $CMakeCmd="$CMakeCmd -DCMAKE_BUILD_TYPE=Debug" + } - if ($BuildTesting) { - $CMakeCmd="$CMakeCmd -DVERSION_SUFFIX=$VersionSuffix" - } + if ($BuildTesting) { + $CMakeCmd="$CMakeCmd -DVERSION_SUFFIX=$VersionSuffix" + } - Write-Host "Building nzbget binary for $Type-$Arch$VersionSuffix" - Write-Host $CMakeCmd + Write-Host "Building nzbget binary for $Type-$Arch$VersionSuffix" + Write-Host $CMakeCmd - Invoke-Expression "& $CMakeCmd" - If (-not $?) { Set-Location $SrcDir; Exit 1 } + Invoke-Expression "& $CMakeCmd" + If (-not $?) { Set-Location $SrcDir; Exit 1 } - & cmake --build . --config $Type - If (-not $?) { Set-Location $SrcDir; Exit 1 } + & cmake --build . --config $Type -j $Jobs + If (-not $?) { Set-Location $SrcDir; Exit 1 } + } Copy-Item "$Type\nzbget.exe" "$SrcDir\$PackageDir\$Bits\" Set-Location $SrcDir @@ -248,6 +250,7 @@ $SrcDir=Get-Location | Select-Object -ExpandProperty Path $BuildDir="build" $DistribDir="$BuildDir\distrib" $PackageDir="$DistribDir\nzbget" +$Jobs=(Get-ComputerInfo).CsProcessors.NumberOfCores If ($BuildTesting) { $VersionSuffix="-testing-$(Get-Date -Format "yyyyMMdd")" @@ -256,10 +259,10 @@ If ($BuildTesting) { $Version = ((Select-String -Path CMakeLists.txt -Pattern "set\(VERSION ")[0] -split('"'))[1] # clean build folder -If (Test-Path $BuildDir) { - Remove-Item $BuildDir -Force -Recurse +If (Test-Path $DistribDir) { + Remove-Item $DistribDir -Force -Recurse } -New-Item -ItemType Directory $BuildDir | Out-Null +New-Item -ItemType Directory $BuildDir -ErrorAction SilentlyContinue | Out-Null # download 7z/unrar if ($DownloadUnpackers) {