diff --git a/.github/workflows/release-launch4j.yml b/.github/workflows/release.yml similarity index 80% rename from .github/workflows/release-launch4j.yml rename to .github/workflows/release.yml index 444d2c7..fcf88b5 100644 --- a/.github/workflows/release-launch4j.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - 'v*' jobs: - release-windows: + release: runs-on: windows-latest permissions: contents: write @@ -23,9 +23,10 @@ jobs: run: | sh bin/deploy-windows.sh sh bin/deploy-windows.sh jre + sh bin/deploy-macos.sh - name: Create Release uses: ncipollo/release-action@v1 with: # 表示要上传到 Release 的产出文件。这可能是单个路径或以逗号分隔的路径列表(或 globs) - artifacts: "out/sonovel-win.tar.gz,out/sonovel-win-with-jre.tar.gz" + artifacts: "out/sonovel-win.tar.gz, out/sonovel-win-with-jre.tar.gz, out/sonovel-macos_arm64.tar.gz, out/sonovel-macos_x64.tar.gz" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/bin/deploy-macos.sh b/bin/deploy-macos.sh new file mode 100644 index 0000000..045fe02 --- /dev/null +++ b/bin/deploy-macos.sh @@ -0,0 +1,53 @@ +# JRE 升级后需要修改下面 3 个版本号 +# JRE arm64 文件名 +jre_filename_arm64="jre-17.0.11+9-arm64_mac.tar.gz" +# JRE x64 文件名 +jre_filename_x64="jre-17.0.11+9-x64_mac.tar.gz" +# JRE 解压后的目录名相同 +jre_dirname="jdk-17.0.11+9-jre" + +# 最终产物的压缩文件名和解压后的目录名 +dist_filename_arm64="sonovel-macos_arm64.tar.gz" +dist_filename_x64="sonovel-macos_x64.tar.gz" +dist_dirname_arm64="SoNovel-macOS_arm64" +dist_dirname_x64="SoNovel-macOS_x64" + +project_path=$( + cd "$(dirname "$0")" || exit + cd .. + pwd +) +cd "$project_path" || exit +mkdir -p out + +mvn clean package -DskipTests + +mkdir "target/$dist_dirname_arm64" +mkdir "target/$dist_dirname_x64" + +# 复制配置文件、使用说明、启动脚本、JRE +cp config.ini input/readme.txt input/run.sh input/*arm64_mac.tar.gz "target/$dist_dirname_arm64" +cp config.ini input/readme.txt input/run.sh input/*x64_mac.tar.gz "target/$dist_dirname_x64" + +# 复制 jar +cd target +mv app-jar-with-dependencies.jar app.jar +cp app.jar "$dist_dirname_arm64" +cp app.jar "$dist_dirname_x64" + +cd "$dist_dirname_arm64" +tar zxf "$jre_filename_arm64" && rm "$jre_filename_arm64" +mv "$jre_dirname" runtime +cd .. + +cd "$dist_dirname_x64" +tar zxf "$jre_filename_x64" && rm "$jre_filename_x64" +mv "$jre_dirname" runtime +cd .. + +tar czf "$dist_filename_arm64" "$dist_dirname_arm64" +tar czf "$dist_filename_x64" "$dist_dirname_x64" + +# TODO .tar.gz 移动到 out 目录 +mv "$dist_filename_arm64" $project_path/out +mv "$dist_filename_x64" $project_path/out \ No newline at end of file diff --git a/bin/deploy-windows.sh b/bin/deploy-windows.sh index 009d739..1b8e463 100644 --- a/bin/deploy-windows.sh +++ b/bin/deploy-windows.sh @@ -1,6 +1,6 @@ # launch4j-maven-plugin 仅支持 windows -# JRE 升级后需要修改下面两个变量 +# JRE 升级后需要修改下面两个版本号 # JRE 文件名 jre_filename="jre-17.0.11+9-x64_windows.tar.gz" # JRE 解压后的目录名 @@ -43,3 +43,4 @@ if [ "$1" == "jre" ]; then fi tar czf $artifacts SoNovel mv $artifacts $project_path/out + diff --git a/input/jre-17.0.11+9-arm64_mac.tar.gz b/input/jre-17.0.11+9-arm64_mac.tar.gz new file mode 100644 index 0000000..7c46a61 Binary files /dev/null and b/input/jre-17.0.11+9-arm64_mac.tar.gz differ diff --git a/input/jre-17.0.11+9-x64_mac.tar.gz b/input/jre-17.0.11+9-x64_mac.tar.gz new file mode 100644 index 0000000..a5d7269 Binary files /dev/null and b/input/jre-17.0.11+9-x64_mac.tar.gz differ diff --git a/input/run.sh b/input/run.sh new file mode 100644 index 0000000..7bee032 --- /dev/null +++ b/input/run.sh @@ -0,0 +1 @@ +./runtime/Contents/Home/bin/java -jar app.jar \ No newline at end of file diff --git a/src/main/java/com/pcdd/sonovel/parse/BookParser.java b/src/main/java/com/pcdd/sonovel/parse/BookParser.java index c1bf6b7..a755065 100644 --- a/src/main/java/com/pcdd/sonovel/parse/BookParser.java +++ b/src/main/java/com/pcdd/sonovel/parse/BookParser.java @@ -1,11 +1,9 @@ package com.pcdd.sonovel.parse; -import cn.hutool.core.io.resource.ResourceUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; -import cn.hutool.json.JSONUtil; import com.pcdd.sonovel.model.Book; import com.pcdd.sonovel.model.Rule; import lombok.SneakyThrows; @@ -20,10 +18,10 @@ /** * @author pcdd */ -public class BookParser extends Parser{ +public class BookParser extends Parser { public BookParser(int sourceId) { - super(sourceId); + super(sourceId); } @SneakyThrows