Skip to content

Commit

Permalink
feat: 新增 macOS 发布自动化
Browse files Browse the repository at this point in the history
  • Loading branch information
freeok committed May 6, 2024
1 parent 412a2b1 commit 2a16c5f
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*'

jobs:
release-windows:
release:
runs-on: windows-latest
permissions:
contents: write
Expand All @@ -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 }}
53 changes: 53 additions & 0 deletions bin/deploy-macos.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion bin/deploy-windows.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# launch4j-maven-plugin 仅支持 windows

# JRE 升级后需要修改下面两个变量
# JRE 升级后需要修改下面两个版本号
# JRE 文件名
jre_filename="jre-17.0.11+9-x64_windows.tar.gz"
# JRE 解压后的目录名
Expand Down Expand Up @@ -43,3 +43,4 @@ if [ "$1" == "jre" ]; then
fi
tar czf $artifacts SoNovel
mv $artifacts $project_path/out

Binary file added input/jre-17.0.11+9-arm64_mac.tar.gz
Binary file not shown.
Binary file added input/jre-17.0.11+9-x64_mac.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions input/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./runtime/Contents/Home/bin/java -jar app.jar
6 changes: 2 additions & 4 deletions src/main/java/com/pcdd/sonovel/parse/BookParser.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 2a16c5f

Please sign in to comment.