Skip to content

Commit

Permalink
Merge pull request #18 from KSP2Community/dev
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
cheese3660 authored Jan 5, 2024
2 parents da9901c + e450553 commit 5dc2a18
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 15 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 "CommunityResources.sln" -c Release

- name: Find zip
id: find-zip
run: |
echo "zip=$(ls -1 dist/CommunityResources-*.zip | head -n 1)" >> $GITHUB_ENV
echo "artifact_name=CommunityResourcesRelease" >> $GITHUB_ENV
- name: Upload zip artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: ${{ env.zip }}
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Upload release
env:
MOD_ID: 3484
KSP2_ID: 22407

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"
echo "version=$version" >> $GITHUB_ENV
dotnet build "CommunityResources.sln" -c Release
echo "release_filename=CommunityResources-$version.zip" >> $GITHUB_ENV
echo "zip=$(ls -1 dist/CommunityResources-*.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
echo "changelog=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].body' | tr -d \")" >> $GITHUB_ENV
echo "${{ env.changelog }}" > ./changelog.md
- 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

- name: Add Mask
run: echo "::add-mask::${{ secrets.SPACEDOCK_PASSWORD }}"

- name: Log in to spacedock
run: |
login_response=$(curl -F username=${{ secrets.SPACEDOCK_USER }} -F password=${{ secrets.SPACEDOCK_PASSWORD }} -c ./cookies "https://spacedock.info/api/login")
login_errored=$(echo $login_response | jq .error)
if [ "$login_errored" == "true" ]; then
echo "Login to space dock errored: $(echo $login_response | jq .reason)"
exit 1
else
echo "Login to space dock successful"
fi
- name: Query latest game version
run: |
echo "LATEST_GAME_VERSION=$(curl 'https://spacedock.info/api/${{ env.KSP2_ID }}/versions' | jq '.[0].friendly_version' | tr -d \")" >> $GITHUB_ENV
- name: Update mod on spacedock
run: |
result=$(curl -b ./cookies -F "version=${{ env.version }}" -F "changelog=@./changelog.md" -F "game-version=${{ env.LATEST_GAME_VERSION }}" -F "notify-followers=yes" -F "zipball=@${{ env.zip }}" "https://spacedock.info/api/mod/${{ env.MOD_ID }}/update")
errored=$(echo $result | jq .error)
if [ "$errored" == "true" ]; then
echo "Upload to space dock errored: $(echo $result | jq .reason)"
exit 1
else
echo "Upload to space dock successful"
fi
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]
11 changes: 6 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup Label="Framework and language configuration">
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
Expand Down Expand Up @@ -34,23 +34,24 @@
</ItemGroup>

<!-- Define the main target -->
<Target Label="Reading properties from swinfo.json" Name="ReadPropertiesFromJson" BeforeTargets="PreBuildEvent">
<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>
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$.dependencies">
<Output TaskParameter="Result" ItemName="Dependencies"/>
</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>
<BepInExPluginGuid>$(ModId)</BepInExPluginGuid>
<BepInExPluginName>$(Product)</BepInExPluginName>
<BepInExPluginVersion>$(Version)</BepInExPluginVersion>
</PropertyGroup>
</Target>
</Project>
4 changes: 2 additions & 2 deletions plugin_template/patches/gasses.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
massPerUnit: 1;
volumePerUnit: 4;
specificHeatCapacityPerUnit: 920;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: true;
Expand All @@ -51,7 +51,7 @@
massPerUnit: 1;
volumePerUnit: 4;
specificHeatCapacityPerUnit: 850;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: false;
Expand Down
4 changes: 2 additions & 2 deletions plugin_template/patches/liquids.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
massPerUnit: 0.001;
volumePerUnit: 1;
specificHeatCapacityPerUnit: 4.184;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: true;
Expand All @@ -51,7 +51,7 @@
massPerUnit: 0.001;
volumePerUnit: 1;
specificHeatCapacityPerUnit: 4.184;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: false;
Expand Down
6 changes: 3 additions & 3 deletions plugin_template/patches/solids.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
massPerUnit: 1;
volumePerUnit: 5;
specificHeatCapacityPerUnit: 1000;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: true;
Expand All @@ -51,7 +51,7 @@
massPerUnit: 1;
volumePerUnit: 3;
specificHeatCapacityPerUnit: 800;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: false;
Expand All @@ -68,7 +68,7 @@
massPerUnit: 1;
volumePerUnit: 3;
specificHeatCapacityPerUnit: 800;
flowMode: $FM_STAGE_PRIORITY_FLOW;
flowMode: $FM_STACK_PRIORITY_SEARCH;
transferMode: $TM_PUMP;
costPerUnit: 0.8;
NonStageable: false;
Expand Down
2 changes: 1 addition & 1 deletion plugin_template/swinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Community Resources",
"description": "Adds generic resources for mods to use",
"source": "https://github.com/KSP2Community/CommunityResources",
"version": "0.2.0",
"version": "0.2.1",
"version_check": "https://raw.githubusercontent.com/KSP2Community/CommunityResources/main/plugin_template/swinfo.json",
"ksp2_version": {
"min": "0.1.5",
Expand Down
8 changes: 6 additions & 2 deletions src/CommunityResources/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<PowerShellExecutable Condition="'$(OS)' == 'Windows_NT'">powershell</PowerShellExecutable>
<PowerShellExecutable Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellExecutable>
</PropertyGroup>
<Target Label="Post build events" Name="PostBuild" AfterTargets="PostBuildEvent">
<Message Text="Cleaning up previous build directory"/>
<RemoveDir Directories="$(SolutionDir)/dist/$(ConfigurationName)"/>
Expand Down Expand Up @@ -33,8 +37,8 @@
<Message Text="Compressing built plugin folder" Condition="$(ConfigurationName) == Release"/>
<Delete Condition="$(ConfigurationName) == Release"
Files="$(SolutionDir)/dist/$(SolutionName)-$(Version).zip"/>
<Exec Condition="$(ConfigurationName) == Release"
Command="powershell Compress-Archive -Path '$(SolutionDir)/dist/$(ConfigurationName)/BepInEx' -DestinationPath '$(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;"/>

<Message Text="Clean up the game's plugin folder" Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"/>
<RemoveDir Condition="$(ConfigurationName) == Deploy Or $(ConfigurationName) == DeployAndRun"
Expand Down

0 comments on commit 5dc2a18

Please sign in to comment.