Skip to content

Commit 9e01c49

Browse files
committed
更新文档和脚本以支持发布包创建和安装说明
1 parent b94a2c2 commit 9e01c49

3 files changed

Lines changed: 197 additions & 1 deletion

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
- call DeepSeek to translate glossary terms and body text in batches
99
- export or deploy the in-game translation mod
1010

11+
## Install from Release
12+
13+
For end users, download the release zip and extract it directly into the game root, the folder that contains `Ostranauts.exe`.
14+
15+
The release package contains these paths:
16+
17+
- `BepInEx\plugins\OstranautsTranslator\`
18+
- `OstranautsTranslator\`
19+
- `Ostranauts_Data\Mods\loading_order.json`
20+
- `Ostranauts_Data\Mods\OstranautsTranslate\`
21+
22+
Close the game before extracting the archive. After extraction, start the game and press `F6` if you want to open the status window.
23+
1124
## Where to Run It
1225

1326
- After a solution build, the tool is copied to: `<game root>\OstranautsTranslator\`
@@ -70,6 +83,23 @@ By default, the solution build will:
7083

7184
At runtime, the plugin reads the real game version shown in the UI from the game's Unity resource `Resources/version` and stores it in `BepInEx\config\OstranautsTranslator.cfg`. If the version changes, the plugin warns you in the log and status window to run `OstranautsTranslator.exe` again and refresh the translation. After a game update, it is best to launch the game once so the plugin can record the new version before you export or deploy again.
7285

86+
## Create a Release Zip
87+
88+
Run this from the repository root:
89+
90+
- `.\tools\create-release.ps1`
91+
92+
By default, the script:
93+
94+
- runs the solution-level `Release` build
95+
- copies the deployed plugin package from `<game root>\BepInEx\plugins\OstranautsTranslator`
96+
- copies the deployed tool directory from `<game root>\OstranautsTranslator`
97+
- excludes `config.ini` and workspace data from the release package
98+
- copies `loading_order.json` and the deployed `OstranautsTranslate` mod
99+
- writes the zip and a ready-to-use release note file under `artifacts\release\v<version>\`
100+
101+
The generated zip is structured so it can be extracted directly into the game root.
102+
73103
## Configuration File
74104

75105
The repository root includes a committed template file: `config-example.ini`.

src/OstranautsTranslator.Plugin.BepInEx/PluginData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ internal static class PluginData
44
{
55
public const string Identifier = "OstranautsTranslator";
66
public const string Name = "OstranautsTranslator";
7-
public const string Version = "0.1.0";
7+
public const string Version = "1.0.0";
88
}

tools/create-release.ps1

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
[CmdletBinding()]
2+
param(
3+
[string]$RepoRoot = ( Resolve-Path ( Join-Path $PSScriptRoot ".." ) ).Path,
4+
[string]$GameRootPath,
5+
[string]$Version,
6+
[string]$Tag,
7+
[string]$OutputRoot,
8+
[switch]$SkipBuild
9+
)
10+
11+
$ErrorActionPreference = "Stop"
12+
Set-StrictMode -Version Latest
13+
14+
function Get-ProjectPropertyValue {
15+
param(
16+
[Parameter( Mandatory = $true )]
17+
[string]$ProjectFilePath,
18+
[Parameter( Mandatory = $true )]
19+
[string]$PropertyName
20+
)
21+
22+
[xml]$projectXml = Get-Content -LiteralPath $ProjectFilePath -Raw
23+
foreach( $propertyGroup in $projectXml.Project.PropertyGroup ) {
24+
$propertyElement = $propertyGroup.SelectSingleNode( $PropertyName )
25+
if( $null -eq $propertyElement ) {
26+
continue
27+
}
28+
29+
$propertyValue = $propertyElement.InnerText
30+
if( -not [string]::IsNullOrWhiteSpace( $propertyValue ) ) {
31+
return $propertyValue.Trim()
32+
}
33+
}
34+
35+
throw "Property '$PropertyName' was not found in '$ProjectFilePath'."
36+
}
37+
38+
function Copy-DirectoryContents {
39+
param(
40+
[Parameter( Mandatory = $true )]
41+
[string]$SourcePath,
42+
[Parameter( Mandatory = $true )]
43+
[string]$DestinationPath,
44+
[string[]]$ExcludeNames = @()
45+
)
46+
47+
New-Item -ItemType Directory -Path $DestinationPath -Force | Out-Null
48+
Get-ChildItem -LiteralPath $SourcePath -Force | Where-Object {
49+
$ExcludeNames -notcontains $_.Name
50+
} | ForEach-Object {
51+
Copy-Item -LiteralPath $_.FullName -Destination ( Join-Path $DestinationPath $_.Name ) -Recurse -Force
52+
}
53+
}
54+
55+
$repoRootPath = ( Resolve-Path -LiteralPath $RepoRoot ).Path
56+
$propsPath = Join-Path $repoRootPath "Directory.Build.props"
57+
58+
if( -not ( Test-Path -LiteralPath $propsPath ) ) {
59+
throw "Directory.Build.props was not found at '$propsPath'."
60+
}
61+
62+
if( [string]::IsNullOrWhiteSpace( $Version ) ) {
63+
$Version = Get-ProjectPropertyValue -ProjectFilePath $propsPath -PropertyName "Version"
64+
}
65+
66+
if( [string]::IsNullOrWhiteSpace( $GameRootPath ) ) {
67+
$GameRootPath = Get-ProjectPropertyValue -ProjectFilePath $propsPath -PropertyName "GameRootPath"
68+
}
69+
70+
$gameRootResolvedPath = ( Resolve-Path -LiteralPath $GameRootPath ).Path
71+
72+
if( [string]::IsNullOrWhiteSpace( $Tag ) ) {
73+
$Tag = "v$Version"
74+
}
75+
76+
if( [string]::IsNullOrWhiteSpace( $OutputRoot ) ) {
77+
$OutputRoot = Join-Path $repoRootPath ( Join-Path "artifacts/release" $Tag )
78+
}
79+
80+
$outputRootPath = [System.IO.Path]::GetFullPath( $OutputRoot )
81+
$stageRootPath = Join-Path $outputRootPath "package"
82+
$zipFileName = "OstranautsTranslator-$Tag.zip"
83+
$zipPath = Join-Path $outputRootPath $zipFileName
84+
$releaseNotesPath = Join-Path $outputRootPath "release-notes.md"
85+
86+
if( -not $SkipBuild ) {
87+
$vsDevShellPath = "D:/Program Files/Microsoft Visual Studio/18/BuildTools/Common7/Tools/Launch-VsDevShell.ps1"
88+
if( -not ( Test-Path -LiteralPath $vsDevShellPath ) ) {
89+
throw "Visual Studio developer shell script was not found at '$vsDevShellPath'."
90+
}
91+
92+
& $vsDevShellPath -Arch amd64 -HostArch amd64
93+
94+
Push-Location $repoRootPath
95+
try {
96+
msbuild .\OstranautsTranslator.sln /p:Configuration=Release /nologo /verbosity:quiet /clp:Summary
97+
}
98+
finally {
99+
Pop-Location
100+
}
101+
}
102+
103+
$pluginSourcePath = Join-Path $gameRootResolvedPath "BepInEx/plugins/OstranautsTranslator"
104+
$toolSourcePath = Join-Path $gameRootResolvedPath "OstranautsTranslator"
105+
$modsRootPath = Join-Path $gameRootResolvedPath "Ostranauts_Data/Mods"
106+
$loadingOrderSourcePath = Join-Path $modsRootPath "loading_order.json"
107+
$modSourcePath = Join-Path $modsRootPath "OstranautsTranslate"
108+
$modInfoPath = Join-Path $modSourcePath "mod_info.json"
109+
110+
foreach( $requiredPath in @( $pluginSourcePath, $toolSourcePath, $loadingOrderSourcePath, $modSourcePath, $modInfoPath ) ) {
111+
if( -not ( Test-Path -LiteralPath $requiredPath ) ) {
112+
throw "Required release input was not found: '$requiredPath'."
113+
}
114+
}
115+
116+
if( Test-Path -LiteralPath $outputRootPath ) {
117+
Remove-Item -LiteralPath $outputRootPath -Recurse -Force
118+
}
119+
120+
New-Item -ItemType Directory -Path $outputRootPath -Force | Out-Null
121+
122+
Copy-DirectoryContents -SourcePath $pluginSourcePath -DestinationPath ( Join-Path $stageRootPath "BepInEx/plugins/OstranautsTranslator" )
123+
Copy-DirectoryContents -SourcePath $toolSourcePath -DestinationPath ( Join-Path $stageRootPath "OstranautsTranslator" ) -ExcludeNames @( "config.ini", "workspace", "workspace-validation", "XUnity.AutoTranslator.Workspace" )
124+
New-Item -ItemType Directory -Path ( Join-Path $stageRootPath "Ostranauts_Data/Mods" ) -Force | Out-Null
125+
Copy-Item -LiteralPath $loadingOrderSourcePath -Destination ( Join-Path $stageRootPath "Ostranauts_Data/Mods/loading_order.json" ) -Force
126+
Copy-Item -LiteralPath $modSourcePath -Destination ( Join-Path $stageRootPath "Ostranauts_Data/Mods/OstranautsTranslate" ) -Recurse -Force
127+
128+
$modInfo = Get-Content -LiteralPath $modInfoPath -Raw | ConvertFrom-Json
129+
$gameVersion = if( $modInfo.Count -gt 0 -and -not [string]::IsNullOrWhiteSpace( $modInfo[0].strGameVersion ) ) {
130+
$modInfo[0].strGameVersion
131+
}
132+
else {
133+
"Unknown"
134+
}
135+
136+
@"
137+
# OstranautsTranslator $Tag
138+
139+
Compatible game version: $gameVersion
140+
141+
## Installation
142+
143+
1. Close the game.
144+
2. Download $zipFileName.
145+
3. Extract the archive directly into the game root, the folder that contains Ostranauts.exe.
146+
4. Overwrite existing files when prompted.
147+
5. Launch the game. Press F6 to open the status window.
148+
149+
## Included content
150+
151+
- BepInEx/plugins/OstranautsTranslator
152+
- OstranautsTranslator
153+
- Ostranauts_Data/Mods/loading_order.json
154+
- Ostranauts_Data/Mods/OstranautsTranslate
155+
156+
## Notes
157+
158+
- This package targets Simplified Chinese.
159+
- config.ini and workspace data are intentionally excluded from the release package.
160+
- If the game updates, rerun OstranautsTranslator.exe or install a newer release package.
161+
"@ | Set-Content -LiteralPath $releaseNotesPath -Encoding UTF8
162+
163+
Compress-Archive -Path ( Join-Path $stageRootPath "*" ) -DestinationPath $zipPath -CompressionLevel Optimal
164+
165+
Write-Host "Release package created: $zipPath"
166+
Write-Host "Release notes created: $releaseNotesPath"

0 commit comments

Comments
 (0)