Skip to content

Commit

Permalink
增加版本号显示
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangYiQiu committed Sep 11, 2024
1 parent 1f64934 commit 16fa1c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/dotnet-publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ jobs:
dotnet-version: 8.0.x
- name: Publish
run: |
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
dotnet publish -c Release -r linux-arm64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-arm64
TAG_NAME=${{ github.ref_name }}
VERSION=${TAG_NAME#pre-v}
echo "Version is $VERSION"
dotnet publish -c Release -p:Version=$VERSION -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
dotnet publish -c Release -p:Version=$VERSION -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
dotnet publish -c Release -p:Version=$VERSION -r linux-arm64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-arm64
cd app
find . -type f -name 'appsettings.Example.json' -execdir mv {} appsettings.json \;
find . -maxdepth 1 -type d ! -name '.' | xargs -I {} sh -c 'cd "{}" && zip -r "../${{ github.ref_name }}-$(basename {}).zip" *'
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/dotnet-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ jobs:
dotnet-version: 8.0.x
- name: Publish
run: |
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
dotnet publish -c Release -r linux-arm64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-arm64
TAG_NAME=${{ github.ref_name }}
VERSION=${TAG_NAME#v}
echo "Version is $VERSION"
dotnet publish -c Release -p:Version=$VERSION -r linux-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-x64
dotnet publish -c Release -p:Version=$VERSION -r win-x64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/win-x64
dotnet publish -c Release -p:Version=$VERSION -r linux-arm64 --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -o app/linux-arm64
cd app
find . -type f -name 'appsettings.Example.json' -execdir mv {} appsettings.json \;
find . -maxdepth 1 -type d ! -name '.' | xargs -I {} sh -c 'cd "{}" && zip -r "../${{ github.ref_name }}-$(basename {}).zip" *'
Expand Down
14 changes: 10 additions & 4 deletions src/TokenPay/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Mvc.Razor;
using Serilog;
using Serilog.Events;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime;
Expand All @@ -22,7 +23,12 @@
.WriteTo.File("logs/log-.log", rollingInterval: RollingInterval.Day)
.WriteTo.Console()
.CreateBootstrapLogger();
Log.Information("-------------{value}-------------", "System Info Begin");
Assembly assembly = Assembly.GetExecutingAssembly();
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
Log.Information("-------------{value}-------------", "TokenPay Info");
Log.Information("File Version: {value}", fileVersionInfo.FileVersion);
Log.Information("Product Version: {value}", fileVersionInfo.ProductVersion);
Log.Information("-------------{value}-------------", "System Info");
Log.Information("Platform: {value}", (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "Linux" :
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "OSX" :
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows" : "Unknown"));
Expand All @@ -32,11 +38,11 @@
Log.Information("X64: {value}", (Environment.Is64BitOperatingSystem ? "Yes" : "No"));
Log.Information("CPU CORE: {value}", Environment.ProcessorCount);
Log.Information("HostName: {value}", Environment.MachineName);
Log.Information("Version: {value}", Environment.OSVersion);
Log.Information("OSVersion: {value}", Environment.OSVersion);
Log.Information("IsServerGC: {value}", GCSettings.IsServerGC);
Log.Information("IsConcurrent: {value}", GC.GetGCMemoryInfo().Concurrent);
Log.Information("LatencyMode: {value}", GCSettings.LatencyMode);
Log.Information("-------------{value}-------------", "System Info End");
Log.Information("-------------{value}-------------", "Info End");

var builder = WebApplication.CreateBuilder(args);
var Services = builder.Services;
Expand Down Expand Up @@ -163,4 +169,4 @@
finally
{
Log.CloseAndFlush();
}
}

0 comments on commit 16fa1c0

Please sign in to comment.