Skip to content

Commit

Permalink
Merge pull request #1011 from PBH-BTN/master
Browse files Browse the repository at this point in the history
v7.4.4
  • Loading branch information
Ghost-chu authored Mar 7, 2025
2 parents c362445 + 0cbea79 commit a04887a
Show file tree
Hide file tree
Showing 48 changed files with 1,369 additions and 1,250 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bat text eol=crlf
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/build_jni.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build C++ JNI Library

on:
workflow_call:

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
arch:
- x64
- amd64_arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '21'
- uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: ${{ matrix.arch }}
- name: Build JNI Library
run: |
cd cpp-src
cl /LD /I"$env:JAVA_HOME\include" /I"$env:JAVA_HOME\include\win32" ghost-common-jni.cpp /link /out:ghost-common-jni_vc2015_${{ matrix.arch == 'x64' && 'amd64' || 'aarch64'}}.dll
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: jni-${{ matrix.arch == 'x64' && 'amd64' || 'aarch64'}}
path: cpp-src/*.dll
13 changes: 10 additions & 3 deletions .github/workflows/build_maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ on:
jobs:
WebUI:
uses: ./.github/workflows/build_fe.yml
JNI:
uses: ./.github/workflows/build_jni.yml
Maven:
needs: WebUI
needs: [WebUI,JNI]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
name: Download WebUI Files
with:
name: webui-dist
path: src/main/resources/static
- name: Display structure of WebUI dist
run: ls src/main/resources/static
- uses: actions/download-artifact@v4
name: Download JNI Library
with:
pattern: jni-*
merge-multiple: true
path: src/main/resources/native/windows
- uses: actions/setup-java@v4
with:
distribution: "temurin"
Expand Down
83 changes: 46 additions & 37 deletions .github/workflows/jvm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,34 @@ on:
workflow_dispatch:
jobs:
Build_Executable:
name: Build JAR Files
uses: ./.github/workflows/build_maven.yml
secrets: inherit
Build_Installers:
name: Generate Installers
needs: Build_Executable
uses: ./.github/workflows/build_installers.yml
secrets: inherit
Build_Portable:
name: Generate Portable Version
needs: Build_Executable
uses: ./.github/workflows/build_portable.yml
Build_SPK:
name: Generate Synology Package
needs: Build_Executable
uses: ./.github/workflows/build_spk.yml
with:
image: ghostchu/peerbanhelper-snapshot:sha-$(git rev-parse --short ${{ github.sha }})
Build_DEB:
name: Generate Debian Package
needs: Build_Executable
uses: ./.github/workflows/build_deb.yml
Build_PKG:
name: Generate FreeBSD Package
needs: Build_Executable
uses: ./.github/workflows/build_pkg.yml
Create_Torrent:
name: Create Torrent
needs: [ Build_Executable, Build_Installers, Build_SPK, Build_DEB, Build_PKG, Build_Portable ]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -101,6 +108,7 @@ jobs:
-o peerbanhelper.torrent \
"PeerBanHelper_Installers_${{ steps.set_version.outputs.version }}.tar.gz"
Build_Docker:
name: Build and Push Docker Images
needs: Build_Executable
runs-on: ubuntu-latest
steps:
Expand All @@ -120,7 +128,7 @@ jobs:
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.6.1
uses: docker/metadata-action@v5.7.0
with:
images: ghostchu/peerbanhelper-snapshot
tags: |
Expand All @@ -133,7 +141,7 @@ jobs:
type=raw,ci
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v6.13.0
uses: docker/build-push-action@v6.15.0
with:
context: .
file: ./Dockerfile
Expand All @@ -145,38 +153,39 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}-jvm-universal
cache-from: type=gha
cache-to: type=gha,mode=min
# Build_Docker_Standalone:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set Up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set Up Buildx
# uses: docker/setup-buildx-action@v3
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/[email protected]
# with:
# images: ghostchu/peerbanhelper-snapshot
# tags: |
# type=ref,event=branch
# type=ref,event=tag
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=raw,ci-jvm-universal
# type=raw,ci
# type=sha
# - name: Build and push Docker image
# uses: docker/[email protected]
# with:
# context: .
# file: ./Dockerfile
# push: false
# platforms: |
# linux/amd64
# linux/arm64/v8
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}-jvm-universal
# cache-from: type=gha
# cache-to: type=gha,mode=min
Build_Docker_Standalone:
name: Build Standalone Docker Images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
- name: Set Up Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ghostchu/peerbanhelper-snapshot
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,ci-jvm-universal
type=raw,ci
type=sha
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: false
platforms: |
linux/amd64
linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}-jvm-universal
cache-from: type=gha
cache-to: type=gha,mode=min
19 changes: 15 additions & 4 deletions .github/workflows/jvm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

jobs:
Build_Executable:
name: Build JAR Files
permissions:
contents: write
checks: write
Expand All @@ -21,35 +22,42 @@ jobs:
uses: ./.github/workflows/build_maven.yml

Build_Installers:
name: Generate Installers
needs: Build_Executable
uses: ./.github/workflows/build_installers.yml
secrets: inherit

Build_SPK:
name: Generate Synology Package
needs: Build_Executable
uses: ./.github/workflows/build_spk.yml
with:
image: registry.cn-hangzhou.aliyuncs.com/ghostchu/peerbanhelper:${{ github.ref_name }}

Build_DEB:
name: Generate Debian Package
needs: Build_Executable
uses: ./.github/workflows/build_deb.yml

Build_PKG:
name: Generate FreeBSD Package
needs: Build_Executable
uses: ./.github/workflows/build_pkg.yml

Build_Portable:
name: Generate Portable Version
needs: Build_Executable
uses: ./.github/workflows/build_portable.yml

Empty_Old_S3_Files:
name: Delete Outdate file in S3
if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
needs: [Build_Executable, Build_Installers, Build_SPK, Build_DEB, Build_PKG, Build_Portable]
uses: ./.github/workflows/delete_old_s3_objects.yml
secrets: inherit

Upload_Updates_To_S3:
name: Update To S3
if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
needs: [ Build_Executable, Build_Installers, Build_SPK, Build_DEB, Build_PKG, Build_Portable, Empty_Old_S3_Files ]
runs-on: ubuntu-latest
Expand All @@ -68,12 +76,14 @@ jobs:
destination_dir: 'updates/latest'

Clear_CloudFlare_Updates:
name: Clear CloudFlare Cache
if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
needs: [Upload_Updates_To_S3]
uses: ./.github/workflows/flush_cloudflare_cache.yml
secrets: inherit

Upload_Artifacts:
name: Upload Release Artifacts
continue-on-error: true
if: github.event_name != 'workflow_dispatch'
needs: [Build_Executable, Build_Installers, Build_SPK, Build_DEB, Build_PKG, Build_Portable]
Expand Down Expand Up @@ -158,6 +168,7 @@ jobs:
asset_paths: '["target/media/PeerBanHelper_*", "target/media/peerbanhelper_*", "target/media/peerbanhelper-*", "target/media/_____UNSUPPORTED_PeerBanHelper_*", "peerbanhelper.torrent", "PeerBanHelper_Installers.tar.gz"]'

Build_Docker:
name: Build Docker Image
if: github.event_name != 'workflow_dispatch'
permissions:
contents: write
Expand Down Expand Up @@ -187,7 +198,7 @@ jobs:
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.6.1
uses: docker/metadata-action@v5.7.0
with:
images: ghostchu/peerbanhelper
tags: |
Expand All @@ -200,7 +211,7 @@ jobs:
type=raw,latest
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v6.13.0
uses: docker/build-push-action@v6.15.0
with:
context: .
file: ./Dockerfile
Expand All @@ -222,7 +233,7 @@ jobs:
password: ${{ secrets.ALIYUN_ACR_PASSWORD }}
- name: Extract metadata (tags, labels) for Aliyun ACR
id: meta-acr
uses: docker/metadata-action@v5.6.1
uses: docker/metadata-action@v5.7.0
with:
images: registry.cn-hangzhou.aliyuncs.com/ghostchu/peerbanhelper
tags: |
Expand All @@ -235,7 +246,7 @@ jobs:
type=raw,latest
type=sha
- name: Build and push Aliyun ACR
uses: docker/build-push-action@v6.13.0
uses: docker/build-push-action@v6.15.0
with:
context: .
file: ./Dockerfile-Release
Expand Down
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
FROM --platform=$BUILDPLATFORM node:current-alpine as build_web

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Standalone Docker Images

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build and Push Docker Images

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
COPY webui /webui
WORKDIR /webui
RUN corepack enable pnpm && CI=1 pnpm i && pnpm run build

FROM --platform=$BUILDPLATFORM docker.io/maven:3.9.9-eclipse-temurin-21-alpine AS build
COPY . /build
WORKDIR /build
COPY --from=build_web webui/dist src/main/resources/static
RUN apk add git && \
mvn -B clean package --file pom.xml -T 1.5C -P thin-sqlite-packaging

FROM docker.io/bellsoft/liberica-runtime-container:jre-23-slim-musl
LABEL maintainer="https://github.com/PBH-BTN/PeerBanHelper"
COPY target/libraries /app/libraries
COPY target/PeerBanHelper.jar /app/PeerBanHelper.jar
USER 0
EXPOSE 9898
ENV TZ=UTC
ENV JAVA_OPTS="-Dpbh.release=docker -Djava.awt.headless=true -Xmx512M -Xms16M -Xss512k -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+ShrinkHeapInSteps"
WORKDIR /app
VOLUME /tmp
COPY --from=build build/target/libraries /app/libraries
COPY --from=build build/target/PeerBanHelper.jar /app/PeerBanHelper.jar
ENV PATH="${JAVA_HOME}/bin:${PATH}"
ENTRYPOINT ["sh", "-c", "${JAVA_HOME}/bin/java ${JAVA_OPTS} -jar PeerBanHelper.jar"]
7 changes: 6 additions & 1 deletion PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,9 @@ CEF 默认使用沙盒技术避免 Web 内容危害本地计算机安全,但
### 禁用更新检查

文件名称:disable-update-check.txt
注:这会禁用更新检查,但已计划的更新仍可能会在启动时安装。
注:这会禁用更新检查,但已计划的更新仍可能会在启动时安装。

### 更改检查并发等级

默认情况下最多允许 32 个并发检查,你可以通过 `pbh.checkParallelism=32` 开关参数来更改并发等级。
注意:过高的并发等级可能耗尽堆内存导致程序卡死。
12 changes: 10 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/sh
echo "Setup webui files.."
sh setup-webui.sh
current_wd=$(pwd)
static_dir="$(dirname $0)/src/main/resources/static"

rm -rf ${static_dir} || echo ""
cd ${current_wd}/webui
pnpm install
pnpm run build
cd ${current_wd}
cp -r webui/dist ${static_dir}

echo "Prepare to build jar.."
mvn -B clean package --file pom.xml
mvn -B clean package --file pom.xml
4 changes: 2 additions & 2 deletions cpp-src/build.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VS2015 x64 本机工具命令提示符
# VS2015 x64 本机工具命令提示符
cl /LD /I"%JAVA_HOME%\include" /I"%JAVA_HOME%\include\win32" ghost-common-jni.cpp /link /out:ghost-common-jni_vc2015_amd64.dll
VS2015 x64 ARM 兼容工具命令提示符
# VS2015 x64 ARM 兼容工具命令提示符
cl /LD /I"%JAVA_HOME%\include" /I"%JAVA_HOME%\include\win32" ghost-common-jni.cpp /link /out:ghost-common-jni_vc2015_aarch64.dll
Loading

0 comments on commit a04887a

Please sign in to comment.