Skip to content

Commit 4d95ab4

Browse files
committed
[Major] it's alive
1 parent 0c4fa49 commit 4d95ab4

File tree

8 files changed

+481
-0
lines changed

8 files changed

+481
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: publish
4+
on:
5+
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
6+
push:
7+
branches:
8+
- 'main' # Run the workflow when pushing to the main branch (test only)
9+
tags:
10+
- '*' # Run the workflow with a tag
11+
12+
env:
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
14+
DOTNET_NOLOGO: true
15+
NuGetDirectory: ${{ github.workspace }}/nuget
16+
17+
defaults:
18+
run:
19+
shell: pwsh
20+
21+
jobs:
22+
set_version:
23+
if: startsWith(github.ref, 'refs/tags/')
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set Version
32+
id: package_version
33+
uses: KageKirin/set-csproj-version@v0
34+
with:
35+
file: ./ModShardUnpacker.csproj
36+
version: ${{ github.ref_name }}
37+
38+
- name: Set user info
39+
run: |
40+
git config user.name github-actions
41+
git config user.email [email protected]
42+
43+
- name: Commit Files & Pull
44+
run: |
45+
git commit -a -m "Updated version with CI."
46+
git pull origin main --rebase
47+
48+
- name: Push Changes
49+
uses: ad-m/github-push-action@master
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
branch: main
53+
54+
create_nuget:
55+
runs-on: ubuntu-latest
56+
needs: [ set_version ]
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
61+
62+
# Install the .NET SDK indicated in the global.json file
63+
- name: Setup .NET
64+
uses: actions/setup-dotnet@v4
65+
66+
# Build the project
67+
- run: dotnet build --configuration Release
68+
69+
# Create the NuGet package in the folder from the environment variable NuGetDirectory
70+
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
71+
72+
# Publish the NuGet package as an artifact, so they can be used in the following jobs
73+
- uses: actions/upload-artifact@v3
74+
with:
75+
name: nuget
76+
if-no-files-found: error
77+
retention-days: 7
78+
path: ${{ env.NuGetDirectory }}/*.nupkg
79+
80+
validate_nuget:
81+
runs-on: ubuntu-latest
82+
needs: [ create_nuget ]
83+
steps:
84+
# Install the .NET SDK indicated in the global.json file
85+
- name: Setup .NET
86+
uses: actions/setup-dotnet@v4
87+
88+
# Download the NuGet package created in the previous job
89+
- uses: actions/download-artifact@v3
90+
with:
91+
name: nuget
92+
path: ${{ env.NuGetDirectory }}
93+
94+
- name: Install nuget validator
95+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
96+
97+
# Validate metadata and content of the NuGet package
98+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
99+
# If some rules are not applicable, you can disable them
100+
# using the --excluded-rules or --excluded-rule-ids option
101+
- name: Validate package
102+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
103+
104+
run_test:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v3
108+
- name: Setup .NET
109+
uses: actions/setup-dotnet@v4
110+
- name: Run tests
111+
run: dotnet test --configuration Release
112+
113+
create_release:
114+
runs-on: ubuntu-latest
115+
needs: [ validate_nuget, run_test ]
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Create Release
120+
run: gh release create ${{ github.ref_name }} --generate-notes
121+
env:
122+
GITHUB_TOKEN: ${{ github.TOKEN }}
123+
124+
deploy:
125+
# Publish only when creating a GitHub Release
126+
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
127+
# You can update this logic if you want to manage releases differently
128+
runs-on: ubuntu-latest
129+
needs: [ create_release ]
130+
steps:
131+
# Download the NuGet package created in the previous job
132+
- uses: actions/download-artifact@v3
133+
with:
134+
name: nuget
135+
path: ${{ env.NuGetDirectory }}
136+
137+
# Install the .NET SDK indicated in the global.json file
138+
- name: Setup .NET Core
139+
uses: actions/setup-dotnet@v4
140+
141+
# Publish all NuGet packages to NuGet.org
142+
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
143+
# If you retry a failed workflow, already published packages will be skipped without error.
144+
- name: Publish NuGet package
145+
run: |
146+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
147+
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
148+
}

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (C) 2024 Rémy Cases
2+
# See LICENSE file for extended copyright information.
3+
# This file is part of the Speedshard repository from https://github.com/ModShardTeam/ModShardUnpacker.
4+
5+
# do not include obj and bin folders
6+
7+
obj
8+
bin
9+
nupkg
10+
logs
11+
*.sml

ModShardUnpacker.csproj

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<Version>1.0.0</Version>
9+
<PackAsTool>true</PackAsTool>
10+
<ToolCommandName>msu</ToolCommandName>
11+
<PackageOutputPath>./nupkg</PackageOutputPath>
12+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
13+
<PackageReadmeFile>README.md</PackageReadmeFile>
14+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
15+
<Authors>zizani</Authors>
16+
<PackageTags>msl;cli</PackageTags>
17+
<PackageProjectUrl>https://github.com/ModShardTeam/ModShardUnpacker</PackageProjectUrl>
18+
<Description>A cli tool to unpack a sml file into a mod source.</Description>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<None Include="README.md" Pack="true" PackagePath=""/>
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="dnlib" Version="4.4.0" />
27+
<PackageReference Include="CommandLineParser" Version="2.8.0" />
28+
<PackageReference Include="ICSharpCode.Decompiler" Version="8.2.0.7535" />
29+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
30+
<PackageReference Include="System.Drawing.Common" Version="8.0.6" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<None Include="icon.png" Pack="true" PackagePath="\"/>
35+
</ItemGroup>
36+
37+
<PropertyGroup>
38+
<RepositoryUrl>https://github.com/ModShardTeam/ModShardUnpacker</RepositoryUrl>
39+
</PropertyGroup>
40+
41+
<PropertyGroup>
42+
<ProjectUrl>https://github.com/ModShardTeam/ModShardUnpacker</ProjectUrl>
43+
</PropertyGroup>
44+
45+
<PropertyGroup>
46+
<PackageIcon>icon.png</PackageIcon>
47+
</PropertyGroup>
48+
</Project>

ModShardUnpacker.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModShardUnpacker", "ModShardUnpacker.csproj", "{A89BE92C-0E59-48DB-AFE1-D527FC6A69C9}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A89BE92C-0E59-48DB-AFE1-D527FC6A69C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A89BE92C-0E59-48DB-AFE1-D527FC6A69C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A89BE92C-0E59-48DB-AFE1-D527FC6A69C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A89BE92C-0E59-48DB-AFE1-D527FC6A69C9}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {496E8A78-FA53-4B2D-9410-C1CCBEFF968D}
24+
EndGlobalSection
25+
EndGlobal

Program.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System.CommandLine;
2+
using System.CommandLine.Builder;
3+
using System.CommandLine.Parsing;
4+
5+
namespace ModShardUnpacker;
6+
internal static class Program
7+
{
8+
static async Task Main(string[] args)
9+
{
10+
Option<string> nameOption = new("--name")
11+
{
12+
Description = "Name of the output.",
13+
IsRequired = false
14+
};
15+
nameOption.AddAlias("-n");
16+
17+
Option<string?> outputOption = new("--output")
18+
{
19+
Description = "Output folder."
20+
};
21+
outputOption.AddAlias("-o");
22+
outputOption.SetDefaultValue(null);
23+
24+
RootCommand rootCommand = new("A CLI tool to pack mod source from MSL.")
25+
{
26+
nameOption,
27+
outputOption,
28+
};
29+
30+
rootCommand.SetHandler(MainOperations.MainCommand, nameOption, outputOption);
31+
32+
CommandLineBuilder commandLineBuilder = new(rootCommand);
33+
34+
commandLineBuilder.AddMiddleware(async (context, next) =>
35+
{
36+
await next(context);
37+
});
38+
39+
commandLineBuilder.UseDefaults();
40+
Parser parser = commandLineBuilder.Build();
41+
42+
await parser.InvokeAsync(args);
43+
}
44+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ModShardUnpacker
2+
3+
A CLI tool to unpack a sml file into a mod code source.

0 commit comments

Comments
 (0)