Skip to content

Commit

Permalink
优化发布脚本,使用-p:PublishTrimmed=true特性,有效减少包大小
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Dec 18, 2020
1 parent 3f38e58 commit 56f13eb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/bilibili-daily-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ jobs:
with:
dotnet-version: 5.0.x

# 还原、构建、发布
# 发布
- name: Publish
run: |
dotnet restore
dotnet build --configuration Release --no-restore
cd ./src/Ray.BiliBiliTool.Console
dotnet publish --self-contained false -o ./bin/Publish/net5-dependent
dotnet publish --configuration Release --self-contained false --output ./bin/Publish/net5-dependent
# 运行
- name: Run APP
Expand All @@ -64,7 +62,7 @@ jobs:
Ray_DailyTaskConfig:DevicePlatform: ${{secrets.DEVICEPLATFORM}}
Ray_Serilog:WriteTo:0:Args:restrictedToMinimumLevel: ${{secrets.CONSOLELOGLEVEL}}
Ray_Serilog:WriteTo:0:Args:outputTemplate: ${{secrets.CONSOLELOGTEMPLATE}}
ASPNETCORE_ENVIRONMENT: ${{secrets.ENV}} # 方便切换不同的appsettings文件 也可以在不同的action yml文件中配置来同时运行多个任务
ASPNETCORE_ENVIRONMENT: ${{secrets.ENV}} # 运行环境
Ray_WebProxy: ${{secrets.PROXY}} # 代理
run: |
cd ./src/Ray.BiliBiliTool.Console/bin/Publish/net5-dependent
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,27 @@ on:

jobs:
build:
name: Publish release and upload asset
name: publish relesae
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 5.0.x

- name: Publish and zip
run: |
dotnet restore
dotnet build --configuration Release --no-restore
cd ./src/Ray.BiliBiliTool.Console
dotnet publish --self-contained false -o ./bin/Publish/net5-dependent
dotnet publish --configuration Release --self-contained false -o ./bin/Publish/net5-dependent
echo "dotnet Ray.BiliBiliTool.Console.dll" > ./bin/Publish/net5-dependent/start.bat
dotnet publish --runtime win-x86 --self-contained true -o ./bin/Publish/win-x86-x64
dotnet publish --runtime linux-arm --self-contained true -o ./bin/Publish/linux-arm
dotnet publish --runtime linux-x64 --self-contained true -o ./bin/Publish/linux-x64
dotnet publish --runtime osx-x64 --self-contained true -o ./bin/Publish/osx-x64
dotnet publish --configuration Release --runtime win-x86 --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/win-x86-x64
dotnet publish --configuration Release --runtime linux-arm --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/linux-arm
dotnet publish --configuration Release --runtime linux-x64 --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/linux-x64
dotnet publish --configuration Release --runtime osx-x64 --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/osx-x64
cd ./bin/Publish
zip -q -r bilibili-tool-v${{ github.event.inputs.version }}-net5-dependent.zip net5-dependent
zip -q -r bilibili-tool-v${{ github.event.inputs.version }}-win-x86-x64.zip win-x86-x64
Expand Down
12 changes: 12 additions & 0 deletions publish.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

cd ./src/Ray.BiliBiliTool.Console

dotnet publish --configuration Release --self-contained false -o ./bin/Publish/net5-dependent
echo "dotnet Ray.BiliBiliTool.Console.dll" > ./bin/Publish/net5-dependent/start.bat

dotnet publish --configuration Release --runtime win-x86 --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/win-x86-x64
dotnet publish --configuration Release --runtime linux-arm --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/linux-arm
dotnet publish --configuration Release --runtime linux-x64 --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/linux-x64
dotnet publish --configuration Release --runtime osx-x64 --self-contained true -p:PublishTrimmed=true -o ./bin/Publish/osx-x64

pause
4 changes: 2 additions & 2 deletions src/Ray.BiliBiliTool.Agent/Ray.BiliBiliTool.Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Refit" Version="5.2.1" />
<PackageReference Include="Refit.HttpClientFactory" Version="5.2.1" />
<PackageReference Include="Refit" Version="5.2.4" />
<PackageReference Include="Refit.HttpClientFactory" Version="5.2.4" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 4 additions & 7 deletions src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@ public void DoDailyTask()
{
if (_securityOptions.IsSkipDailyTask)
{
_logger.LogWarning("\r\n已配置为跳过每日任务");
_logger.LogWarning("已配置为跳过每日任务");
return;
}

_logger.LogInformation("\r\n-----开始每日任务-----\r\n");
_logger.LogInformation("-----开始每日任务-----\r\n");

UseInfo userInfo;
DailyTaskInfo dailyTaskInfo;

userInfo = Login();
dailyTaskInfo = GetDailyTaskStatus();
UseInfo userInfo = Login();
DailyTaskInfo dailyTaskInfo = GetDailyTaskStatus();

WatchAndShareVideo(dailyTaskInfo);
AddCoinsForVideo();
Expand Down
8 changes: 4 additions & 4 deletions src/Ray.BiliBiliTool.Console/Ray.BiliBiliTool.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Authors>Ray</Authors>
<Version>1.0.17</Version>
<Version>1.0.18</Version>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -33,14 +33,14 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Refit" Version="5.2.1" />
<PackageReference Include="Refit.HttpClientFactory" Version="5.2.1" />
<PackageReference Include="Refit" Version="5.2.4" />
<PackageReference Include="Refit.HttpClientFactory" Version="5.2.4" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.TextWriter" Version="2.1.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/InfrastructureTest/InfrastructureTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 56f13eb

Please sign in to comment.