Skip to content

Commit 5dc2a18

Browse files
authored
Merge pull request #18 from KSP2Community/dev
v0.2.1
2 parents da9901c + e450553 commit 5dc2a18

File tree

9 files changed

+138
-15
lines changed

9 files changed

+138
-15
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Build the solution
15+
run: dotnet build "CommunityResources.sln" -c Release
16+
17+
- name: Find zip
18+
id: find-zip
19+
run: |
20+
echo "zip=$(ls -1 dist/CommunityResources-*.zip | head -n 1)" >> $GITHUB_ENV
21+
echo "artifact_name=CommunityResourcesRelease" >> $GITHUB_ENV
22+
23+
- name: Upload zip artifact
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: ${{ env.artifact_name }}
27+
path: ${{ env.zip }}

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Upload release
2+
env:
3+
MOD_ID: 3484
4+
KSP2_ID: 22407
5+
6+
on:
7+
release:
8+
types: [ "published" ]
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
permissions: write-all
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Download NuGet
19+
id: download-nuget
20+
run: |
21+
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
22+
23+
- name: Install jq
24+
uses: dcarbone/[email protected]
25+
26+
- name: Build the solution
27+
run: |
28+
version=$(jq -r '.version' plugin_template/swinfo.json)
29+
echo "Version is $version"
30+
echo "version=$version" >> $GITHUB_ENV
31+
dotnet build "CommunityResources.sln" -c Release
32+
echo "release_filename=CommunityResources-$version.zip" >> $GITHUB_ENV
33+
echo "zip=$(ls -1 dist/CommunityResources-*.zip | head -n 1)" >> $GITHUB_ENV
34+
echo "upload_url=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].upload_url' | tr -d \")" >> $GITHUB_ENV
35+
echo "changelog=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].body' | tr -d \")" >> $GITHUB_ENV
36+
echo "${{ env.changelog }}" > ./changelog.md
37+
38+
- name: Upload zip to release
39+
uses: shogo82148/[email protected]
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
with:
43+
upload_url: ${{ env.upload_url }}
44+
asset_path: ${{ env.zip }}
45+
asset_name: ${{ env.release_filename }}
46+
asset_content_type: application/zip
47+
48+
- name: Add Mask
49+
run: echo "::add-mask::${{ secrets.SPACEDOCK_PASSWORD }}"
50+
51+
- name: Log in to spacedock
52+
run: |
53+
login_response=$(curl -F username=${{ secrets.SPACEDOCK_USER }} -F password=${{ secrets.SPACEDOCK_PASSWORD }} -c ./cookies "https://spacedock.info/api/login")
54+
login_errored=$(echo $login_response | jq .error)
55+
if [ "$login_errored" == "true" ]; then
56+
echo "Login to space dock errored: $(echo $login_response | jq .reason)"
57+
exit 1
58+
else
59+
echo "Login to space dock successful"
60+
fi
61+
62+
- name: Query latest game version
63+
run: |
64+
echo "LATEST_GAME_VERSION=$(curl 'https://spacedock.info/api/${{ env.KSP2_ID }}/versions' | jq '.[0].friendly_version' | tr -d \")" >> $GITHUB_ENV
65+
66+
- name: Update mod on spacedock
67+
run: |
68+
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")
69+
errored=$(echo $result | jq .error)
70+
if [ "$errored" == "true" ]; then
71+
echo "Upload to space dock errored: $(echo $result | jq .reason)"
72+
exit 1
73+
else
74+
echo "Upload to space dock successful"
75+
fi

.github/workflows/verify.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Verify swinfo.json
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
verify:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Verify KSP2 Mod
16+
uses: Rexicon226/[email protected]

Directory.Build.props

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup Label="Framework and language configuration">
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<LangVersion>latest</LangVersion>
77
<ImplicitUsings>true</ImplicitUsings>
@@ -34,23 +34,24 @@
3434
</ItemGroup>
3535

3636
<!-- Define the main target -->
37-
<Target Label="Reading properties from swinfo.json" Name="ReadPropertiesFromJson" BeforeTargets="PreBuildEvent">
37+
<Target Label="Reading properties from swinfo.json" Name="ReadPropertiesFromJson" BeforeTargets="PreBuildEvent;AddGeneratedFile">
3838
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$">
3939
<Output TaskParameter="Result" ItemName="Swinfo"/>
4040
</JsonPeek>
41-
<JsonPeek ContentPath="$(SolutionDir)/plugin_template/swinfo.json" Query="$.dependencies">
42-
<Output TaskParameter="Result" ItemName="Dependencies"/>
43-
</JsonPeek>
4441

4542
<!-- Extract properties from the JSON -->
4643
<PropertyGroup>
4744
<ModId>@(Swinfo -> '%(mod_id)')</ModId>
4845
<Version>@(Swinfo -> '%(version)')</Version>
46+
<Version Condition="$(Version.Contains('-'))">$(Version.Substring(0, $(Version.IndexOf('-'))))</Version>
4947
<Product>@(Swinfo -> '%(name)')</Product>
5048
<Authors>@(Swinfo -> '%(author)')</Authors>
5149
<Description>@(Swinfo -> '%(description)')</Description>
5250
<RepositoryType>git</RepositoryType>
5351
<RepositoryUrl>@(Swinfo -> '%(source)')</RepositoryUrl>
52+
<BepInExPluginGuid>$(ModId)</BepInExPluginGuid>
53+
<BepInExPluginName>$(Product)</BepInExPluginName>
54+
<BepInExPluginVersion>$(Version)</BepInExPluginVersion>
5455
</PropertyGroup>
5556
</Target>
5657
</Project>

plugin_template/patches/gasses.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
massPerUnit: 1;
3535
volumePerUnit: 4;
3636
specificHeatCapacityPerUnit: 920;
37-
flowMode: $FM_STAGE_PRIORITY_FLOW;
37+
flowMode: $FM_STACK_PRIORITY_SEARCH;
3838
transferMode: $TM_PUMP;
3939
costPerUnit: 0.8;
4040
NonStageable: true;
@@ -51,7 +51,7 @@
5151
massPerUnit: 1;
5252
volumePerUnit: 4;
5353
specificHeatCapacityPerUnit: 850;
54-
flowMode: $FM_STAGE_PRIORITY_FLOW;
54+
flowMode: $FM_STACK_PRIORITY_SEARCH;
5555
transferMode: $TM_PUMP;
5656
costPerUnit: 0.8;
5757
NonStageable: false;

plugin_template/patches/liquids.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
massPerUnit: 0.001;
3535
volumePerUnit: 1;
3636
specificHeatCapacityPerUnit: 4.184;
37-
flowMode: $FM_STAGE_PRIORITY_FLOW;
37+
flowMode: $FM_STACK_PRIORITY_SEARCH;
3838
transferMode: $TM_PUMP;
3939
costPerUnit: 0.8;
4040
NonStageable: true;
@@ -51,7 +51,7 @@
5151
massPerUnit: 0.001;
5252
volumePerUnit: 1;
5353
specificHeatCapacityPerUnit: 4.184;
54-
flowMode: $FM_STAGE_PRIORITY_FLOW;
54+
flowMode: $FM_STACK_PRIORITY_SEARCH;
5555
transferMode: $TM_PUMP;
5656
costPerUnit: 0.8;
5757
NonStageable: false;

plugin_template/patches/solids.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
massPerUnit: 1;
3535
volumePerUnit: 5;
3636
specificHeatCapacityPerUnit: 1000;
37-
flowMode: $FM_STAGE_PRIORITY_FLOW;
37+
flowMode: $FM_STACK_PRIORITY_SEARCH;
3838
transferMode: $TM_PUMP;
3939
costPerUnit: 0.8;
4040
NonStageable: true;
@@ -51,7 +51,7 @@
5151
massPerUnit: 1;
5252
volumePerUnit: 3;
5353
specificHeatCapacityPerUnit: 800;
54-
flowMode: $FM_STAGE_PRIORITY_FLOW;
54+
flowMode: $FM_STACK_PRIORITY_SEARCH;
5555
transferMode: $TM_PUMP;
5656
costPerUnit: 0.8;
5757
NonStageable: false;
@@ -68,7 +68,7 @@
6868
massPerUnit: 1;
6969
volumePerUnit: 3;
7070
specificHeatCapacityPerUnit: 800;
71-
flowMode: $FM_STAGE_PRIORITY_FLOW;
71+
flowMode: $FM_STACK_PRIORITY_SEARCH;
7272
transferMode: $TM_PUMP;
7373
costPerUnit: 0.8;
7474
NonStageable: false;

plugin_template/swinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Community Resources",
66
"description": "Adds generic resources for mods to use",
77
"source": "https://github.com/KSP2Community/CommunityResources",
8-
"version": "0.2.0",
8+
"version": "0.2.1",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/CommunityResources/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.1.5",

src/CommunityResources/Directory.Build.targets

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3+
<PropertyGroup>
4+
<PowerShellExecutable Condition="'$(OS)' == 'Windows_NT'">powershell</PowerShellExecutable>
5+
<PowerShellExecutable Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellExecutable>
6+
</PropertyGroup>
37
<Target Label="Post build events" Name="PostBuild" AfterTargets="PostBuildEvent">
48
<Message Text="Cleaning up previous build directory"/>
59
<RemoveDir Directories="$(SolutionDir)/dist/$(ConfigurationName)"/>
@@ -33,8 +37,8 @@
3337
<Message Text="Compressing built plugin folder" Condition="$(ConfigurationName) == Release"/>
3438
<Delete Condition="$(ConfigurationName) == Release"
3539
Files="$(SolutionDir)/dist/$(SolutionName)-$(Version).zip"/>
36-
<Exec Condition="$(ConfigurationName) == Release"
37-
Command="powershell Compress-Archive -Path '$(SolutionDir)/dist/$(ConfigurationName)/BepInEx' -DestinationPath '$(SolutionDir)/dist/$(SolutionName)-$(Version).zip'"/>
40+
<Exec Condition="$(ConfigurationName) == 'Release'"
41+
Command="$(PowerShellExecutable) -Command &quot;&amp; {Push-Location '$(SolutionDir)/dist/$(ConfigurationName)'; Compress-Archive -Path './*' -DestinationPath '$(SolutionDir)/dist/$(SolutionName)-$(Version).zip'; Pop-Location}&quot;"/>
3842

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

0 commit comments

Comments
 (0)