Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cheese3660 committed Dec 31, 2023
0 parents commit c8fa769
Show file tree
Hide file tree
Showing 16 changed files with 400 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build the solution
run: dotnet build "Shoemaker.sln" -c Release

- name: Find zip
id: find-zip
run: |
echo "zip=$(ls -1 dist/Shoemaker-*.zip | head -n 1)" >> $GITHUB_ENV
echo "artifact_name=ShoemakerRelease" >> $GITHUB_ENV
- name: Upload zip artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: ${{ env.zip }}

41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Upload release

on:
release:
types: [ "published" ]

jobs:
publish:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download NuGet
id: download-nuget
run: |
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
- name: Install jq
uses: dcarbone/[email protected]

- name: Build the solution
run: |
version=$(jq -r '.version' plugin_template/swinfo.json)
echo "Version is $version"
dotnet build "Shoemaker.sln" -c Release
echo "release_filename=Shoemaker-$version.zip" >> $GITHUB_ENV
echo "zip=$(ls -1 dist/Shoemaker-*.zip | head -n 1)" >> $GITHUB_ENV
echo "upload_url=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].upload_url' | tr -d \")" >> $GITHUB_ENV
- name: Upload zip to release
uses: shogo82148/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
asset_path: ${{ env.zip }}
asset_name: ${{ env.release_filename }}
asset_content_type: application/zip

16 changes: 16 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Verify swinfo.json

on:
push:
branches: [ "main" ]

jobs:
verify:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Verify KSP2 Mod
uses: Rexicon226/[email protected]
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# General C# project
*.suo
*.user
.vs/
[Bb]in/
[Oo]bj/
_UpgradeReport_Files/
/[Pp]ackages/

# Mod template folders
/[Bb]uild/
/[Dd]ist/
/[Nn]uget/

# Rider

# User specific
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/httpRequests/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml

# VS Code files
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# OS-specific
Thumbs.db
Desktop.ini
.DS_Store
59 changes: 59 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup Label="Framework and language configuration">
<TargetFramework>netstandard2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Label="Game folder configuration">
<!-- Set this to the path to your KSP 2 folder if you don't have the KSP2DIR environmental variable set -->
<KSP2DIR Condition="'$(KSP2DIR)' == ''">C:/Program Files (x86)/Steam/steamapps/common/Kerbal Space Program 2</KSP2DIR>
</PropertyGroup>

<PropertyGroup Label="Build and namespace configuration">
<SolutionDir Condition="'$(SolutionDir)'==''">$(MSBuildThisFileDirectory)</SolutionDir>
<PluginBinPath>$(SolutionDir)build/bin/plugin/$(Configuration)</PluginBinPath>
<PluginObjPath>$(SolutionDir)build/obj/plugin/$(Configuration)</PluginObjPath>
<BaseOutputPath>$(PluginBinPath)/$(MSBuildProjectName)</BaseOutputPath>
<BaseIntermediateOutputPath>$(PluginObjPath)/$(MSBuildProjectName)</BaseIntermediateOutputPath>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<Configurations>Debug;Release;Deploy;DeployAndRun</Configurations>
<Platforms>AnyCPU</Platforms>
<NoWarn>$(NoWarn);CS0436</NoWarn>
</PropertyGroup>

<PropertyGroup Label="Package source configuration">
<RestoreAdditionalProjectSources>
https://nuget.spacewarp.org/v3/index.json
</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup Label="Dependencies for build targets">
<PackageReference Include="JsonPeek" Version="1.2.0" PrivateAssets="all"/>
</ItemGroup>

<!-- Define the main target -->
<Target Label="Reading properties from swinfo.json" Name="ReadPropertiesFromJson" BeforeTargets="PreBuildEvent;AddGeneratedFile">
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$">
<Output TaskParameter="Result" ItemName="Swinfo"/>
</JsonPeek>

<!-- Extract properties from the JSON -->
<PropertyGroup>
<ModId>@(Swinfo -> '%(mod_id)')</ModId>
<Version>@(Swinfo -> '%(version)')</Version>
<Version Condition="$(Version.Contains('-'))">$(Version.Substring(0, $(Version.IndexOf('-'))))</Version>
<Product>@(Swinfo -> '%(name)')</Product>
<Authors>@(Swinfo -> '%(author)')</Authors>
<Description>@(Swinfo -> '%(description)')</Description>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>@(Swinfo -> '%(source)')</RepositoryUrl>
<SpaceWarpPluginGuid>$(ModId)</SpaceWarpPluginGuid>
<SpaceWarpPluginName>$(Product)</SpaceWarpPluginName>
<SpaceWarpPluginVersion>$(Version)</SpaceWarpPluginVersion>
</PropertyGroup>
</Target>
</Project>
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2023 KSP2 Community

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shoemaker
A tool to enable planet modding for KSP2 via Patch Manager
23 changes: 23 additions & 0 deletions Shoemaker.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{F92A9EF1-DB19-4D70-BD93-CE74B23D05D4}") = "Shoemaker", "src/Shoemaker/Shoemaker.csproj", "{4D27CE61-02F2-4875-AFF5-562E08AED4B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Deploy|Any CPU = Deploy|Any CPU
DeployAndRun|Any CPU = DeployAndRun|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.Release|Any CPU.Build.0 = Release|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.Deploy|Any CPU.Build.0 = Deploy|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.DeployAndRun|Any CPU.ActiveCfg = DeployAndRun|Any CPU
{4D27CE61-02F2-4875-AFF5-562E08AED4B1}.DeployAndRun|Any CPU.Build.0 = DeployAndRun|Any CPU
EndGlobalSection
EndGlobal

23 changes: 23 additions & 0 deletions plugin_template/swinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"spec": "2.0",
"mod_id": "Shoemaker",
"author": "KSP2 Community",
"name": "Shoemaker",
"description": "A tool to enable planet modding for KSP2 via Patch Manager",
"source": "https://github.com/KSP2Community/Shoemaker",
"version": "0.1.0",
"version_check": "https://github.com/KSP2Community/Shoemaker/plugin_template/swinfo.json",
"ksp2_version": {
"min": "0.2.0",
"max": "*"
},
"dependencies": [
{
"id": "com.github.x606.spacewarp",
"version": {
"min": "1.7.0",
"max": "*"
}
}
]
}
2 changes: 2 additions & 0 deletions scripts/build-debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
dotnet build "../Shoemaker.sln" -c Debug
2 changes: 2 additions & 0 deletions scripts/build-deploy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
dotnet build "../Shoemaker.sln" -c Deploy
2 changes: 2 additions & 0 deletions scripts/build-release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
dotnet build "../Shoemaker.sln" -c Release
2 changes: 2 additions & 0 deletions scripts/build-run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
dotnet build "../Shoemaker.sln" -c DeployAndRun
78 changes: 78 additions & 0 deletions src/Shoemaker/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Commands for Windows and Linux -->
<PropertyGroup>
<PowerShellExecutable Condition="'$(OS)' == 'Windows_NT'">powershell</PowerShellExecutable>
<PowerShellExecutable Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellExecutable>
</PropertyGroup>

<!-- Post-build events target -->
<Target Label="Post build events" Name="PostBuild" AfterTargets="PostBuildEvent">
<!-- Cleanup of older builds -->
<Message Text="Cleaning up previous build directory"/>
<RemoveDir Directories="$(SolutionDir)/dist/$(ConfigurationName)"/>
<MakeDir Directories="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/plugins/$(ProjectName)"/>

<!-- Copying general files to build directory -->
<ItemGroup Label="Plugin template folder to be copied">
<PluginTemplate Include="$(SolutionDir)/plugin_template/**/*.*" Exclude="$(SolutionDir)/**/.gitkeep"/>
</ItemGroup>
<Message Text="Copying plugin folder to build directory"/>
<Copy SourceFiles="@(PluginTemplate)"
DestinationFolder="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/plugins/$(ProjectName)/%(RecursiveDir)"/>

<Message Text="Copying LICENSE and README to build directory"/>
<Copy Condition="Exists('$(SolutionDir)/LICENSE')"
SourceFiles="$(SolutionDir)/LICENSE"
DestinationFolder="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/plugins/$(ProjectName)"/>
<Copy Condition="Exists('$(SolutionDir)/README.md')"
SourceFiles="$(SolutionDir)/README.md"
DestinationFiles="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/plugins/$(ProjectName)/README.txt"/>

<!-- Copying compiled plugin to build directory -->
<Message Text="Copying mod DLL to build directory"/>
<ItemGroup Label="Plugin DLLs to be copied">
<PluginDLLs Include="$(PluginBinPath)/**/*.dll"/>
</ItemGroup>
<Copy SourceFiles="@(PluginDLLs)"
DestinationFolder="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/plugins/$(ProjectName)"/>

<Message Text="Copying mod PDB to build directory"
Condition="$(ConfigurationName) == Debug Or $(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"/>
<ItemGroup Label="Plugin PDBs to be copied">
<PluginPDBs Include="$(PluginBinPath)/**/*.pdb"/>
</ItemGroup>
<Copy Condition="$(ConfigurationName) == Debug Or $(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"
SourceFiles="@(PluginPDBs)"
DestinationFolder="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/plugins/$(ProjectName)"/>

<!-- Compressing build directory for release -->
<Message Text="Compressing built plugin folder" Condition="$(ConfigurationName) == Release"/>
<Delete Condition="$(ConfigurationName) == Release"
Files="$(SolutionDir)/dist/$(SolutionName)-$(Version).zip"/>
<Exec Condition="$(ConfigurationName) == Release"
Command="$(PowerShellExecutable) -Command &quot;&amp; {Push-Location '$(SolutionDir)/dist/$(ConfigurationName)'; Compress-Archive -Path './*' -DestinationPath '$(SolutionDir)/dist/$(SolutionName)-$(Version).zip'; Pop-Location}&quot;"/>

<!-- Deploying plugin to game folder -->
<Message Text="Clean up the game's plugin folder" Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"/>
<RemoveDir Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"
Directories="$(KSP2DIR)/BepInEx/plugins/$(ProjectName)"/>
<MakeDir Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"
Directories="$(KSP2DIR)/BepInEx/plugins/$(ProjectName)"/>

<ItemGroup Label="Dist folder to be copied">
<DistFolder Include="$(SolutionDir)/dist/$(ConfigurationName)/BepInEx/**/*.*"/>
</ItemGroup>
<Message Text="Deploy plugin to game folder"
Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"/>
<Copy Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"
SourceFiles="@(DistFolder)"
DestinationFolder="$(KSP2DIR)/BepInEx/%(RecursiveDir)"/>

<!-- Run game after deploy -->
<Message Text="Deploy plugin and run game" Condition="$(ConfigurationName) == DeployAndRun"/>
<Exec Condition="$(ConfigurationName) == DeployAndRun"
Command="$(PowerShellExecutable) &quot;start-process &quot;&quot;$(KSP2DIR)\KSP2_x64.exe&quot;&quot;&quot;"/>
</Target>
</Project>

19 changes: 19 additions & 0 deletions src/Shoemaker/Shoemaker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<!-- Project references -->
<ItemGroup Label="DLL file references">
<!-- Add references to any DLL files you want to use in your mod here -->
</ItemGroup>
<ItemGroup Label="NuGet package references">
<!-- Add references to any NuGet packages you want to use in your mod here -->
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all"/>
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all"/>
<PackageReference Include="BepInEx.Core" Version="5.*"/>
<PackageReference Include="HarmonyX" Version="2.10.1"/>
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.2.0" PrivateAssets="all" Publicize="true"/>
<PackageReference Include="SpaceWarp" Version="1.7.0"/>
<PackageReference Include="SpaceWarp.PluginInfoProps" Version="1.*"/>
<PackageReference Include="UnityEngine.Modules" Version="2022.3.5"/>
</ItemGroup>
</Project>

Loading

0 comments on commit c8fa769

Please sign in to comment.