forked from AssetRipper/AssetRipper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
del: targetframework add: publish-cli-folderexport workflow + logging single file publish single file workflow
- Loading branch information
Showing
7 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Publish-CLI-FolderExport | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
runs-on: ${{ matrix.config.os }} | ||
|
||
strategy: | ||
matrix: | ||
config: | ||
- { name: win_x64, os: windows-latest, runtime: win-x64, executable: AssetRipper.CLI.FolderExport.exe } | ||
- { name: win_arm64, os: windows-latest, runtime: win-arm64, executable: AssetRipper.CLI.FolderExport.exe } | ||
- { name: linux_x64, os: ubuntu-latest, runtime: linux-x64, executable: AssetRipper.CLI.FolderExport } | ||
- { name: mac_x64, os: macos-latest, runtime: osx-x64, executable: AssetRipper.CLI.FolderExport } | ||
- { name: mac_arm64, os: macos-latest, runtime: osx-arm64, executable: AssetRipper.CLI.FolderExport } | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 9.0.x | ||
|
||
- name: Publish | ||
run: dotnet publish -c Release -r ${{ matrix.config.runtime }} --self-contained | ||
working-directory: ./Source/AssetRipper.CLI.FolderExport/ | ||
|
||
- name: Upload | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: AssetRipper_CLI_FolderExport_${{ matrix.config.name }} | ||
path: ./Source/AssetRipper.CLI.FolderExport/bin/Release/${{ matrix.config.runtime }}/publish/${{ matrix.config.executable }} | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Source/AssetRipper.CLI.FolderExport/AssetRipper.CLI.FolderExport.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AssetRipper.Export.UnityProjects\AssetRipper.Export.UnityProjects.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using AssetRipper.Export.UnityProjects; | ||
using AssetRipper.Export.UnityProjects.Configuration; | ||
using AssetRipper.Import.Configuration; | ||
using AssetRipper.Primitives; | ||
using AssetRipper.Processing; | ||
using AssetRipper.Processing.Configuration; | ||
using System.CommandLine; | ||
using System.Diagnostics; | ||
|
||
public class Program | ||
{ | ||
private static readonly string DefaultUnityVersion = "2022.3.22f1"; | ||
|
||
public static void Main(string[] args) | ||
{ | ||
Console.WriteLine(Launch(args) ? "Files exported successfully." : "There was an error exporting the files."); | ||
} | ||
|
||
public static bool Launch(string[] args) | ||
{ | ||
RootCommand rootCommand = []; | ||
|
||
Option<string> folderOption = new( | ||
"--folder", | ||
"Path to the input folder") | ||
{ | ||
IsRequired = true | ||
}; | ||
rootCommand.AddOption(folderOption); | ||
|
||
Option<string> outputOption = new( | ||
"--output", | ||
"Path to the output folder") | ||
{ | ||
IsRequired = true | ||
}; | ||
rootCommand.AddOption(outputOption); | ||
|
||
Option<string> unityVersionOption = new( | ||
"--unity-version", | ||
() => DefaultUnityVersion, | ||
$"Unity version to use (default is {DefaultUnityVersion})"); | ||
rootCommand.AddOption(unityVersionOption); | ||
|
||
bool result = false; | ||
|
||
rootCommand.SetHandler((string folderPath, string outputPath, string unityVersion) => | ||
{ | ||
Stopwatch stopwatch = new(); | ||
stopwatch.Start(); | ||
DirectoryInfo folder = new(folderPath); | ||
DirectoryInfo output = new(outputPath); | ||
|
||
if (!folder.Exists) | ||
{ | ||
Console.WriteLine($"The specified input folder '{folder.FullName}' does not exist."); | ||
return; | ||
} | ||
|
||
if (!output.Exists) | ||
{ | ||
Console.WriteLine($"The specified output folder '{output.FullName}' does not exist."); | ||
return; | ||
} | ||
|
||
Console.WriteLine($"Input folder: {folder.FullName}"); | ||
Console.WriteLine($"Output folder: {output.FullName}"); | ||
Console.WriteLine($"Unity version: {unityVersion}"); | ||
Console.WriteLine("Initializing..."); | ||
|
||
LibraryConfiguration settings = new(); | ||
settings.LoadFromDefaultPath(); | ||
ExportHandler exportHandler = new(LoadSettings(unityVersion)); | ||
|
||
GameData gameData = exportHandler.LoadAndProcess(new string[] { folder.FullName }); | ||
|
||
exportHandler.Export(gameData, output.FullName); | ||
|
||
stopwatch.Stop(); | ||
TimeSpan ts = stopwatch.Elapsed; | ||
|
||
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", | ||
ts.Hours, ts.Minutes, ts.Seconds, | ||
ts.Milliseconds / 10); | ||
|
||
Console.WriteLine($"Process finished in {elapsedTime}"); | ||
|
||
result = true; | ||
|
||
}, folderOption, outputOption, unityVersionOption); | ||
|
||
rootCommand.Invoke(args); | ||
|
||
return result; | ||
} | ||
|
||
private static LibraryConfiguration LoadSettings(string unityVersion) | ||
{ | ||
LibraryConfiguration settings = new(); | ||
settings.LoadFromDefaultPath(); | ||
settings.ProcessingSettings.BundledAssetsExportMode = BundledAssetsExportMode.GroupByBundleName; | ||
settings.ImportSettings.DefaultVersion = UnityVersion.Parse(unityVersion); | ||
settings.ImportSettings.TargetVersion = UnityVersion.Parse(unityVersion); | ||
return settings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters