Skip to content

Commit

Permalink
Merge pull request #30 from KSP2Community/dev
Browse files Browse the repository at this point in the history
0.8.1 Hotfix
  • Loading branch information
jan-bures authored Jan 6, 2024
2 parents 16f6538 + 6bad32d commit 5e9a3e7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
43 changes: 12 additions & 31 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Publish NuGet and upload release
env:
MOD_ID: 3482
KSP2_ID: 22407


on:
release:
types: [ "published" ]
Expand Down Expand Up @@ -35,7 +32,8 @@ jobs:
echo "artifact_name=PatchManager-$version.zip" >> $GITHUB_ENV
echo "zip=$(ls -1 dist/PatchManager-*.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 \" | jq -Rr @uri)" >> $GITHUB_ENV
echo "changelog=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq -r '.[0].body')" >> $GITHUB_ENV
echo "${{ env.changelog }}" > ./changelog.md
- name: Check if version exists
id: check-version
Expand Down Expand Up @@ -69,29 +67,12 @@ jobs:
- 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=${{ env.changelog }}" -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
- name: Update spacedock
uses: KSP2Community/[email protected]
with:
username: ${{ secrets.SPACEDOCK_USER }}
password: ${{ secrets.SPACEDOCK_PASSWORD }}
game_id: 22407
mod_id: 3482
version: ${{ env.version }}
changelog: ./changelog.md
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": "Patch Manager",
"description": "A mod for generic patching needs similar to KSP 1's Module Manager.",
"source": "https://github.com/KSP2Community/PatchManager",
"version": "0.9.0",
"version": "0.9.1",
"version_check": "https://raw.githubusercontent.com/KSP2Community/PatchManager/main/plugin_template/swinfo.json",
"ksp2_version": {
"min": "0.2.0",
Expand Down
7 changes: 2 additions & 5 deletions src/PatchManager.Resources/Rulesets/ResourceRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ public class ResourceRuleset : IPatcherRuleSet
public ISelectable ConvertToSelectable(string type, string name, string jsonData)
{
var obj = JObject.Parse(jsonData);
if (obj.ContainsKey("isRecipe") && obj["isRecipe"].Value<bool>())
if (obj.ContainsKey("isRecipe") && obj["isRecipe"]!.Value<bool>())
{
return new RecipeSelectable(jsonData);
}
else
{
return new ResourceSelectable(jsonData);
}
return new ResourceSelectable(jsonData);
}

/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion src/PatchManager.Resources/Selectables/RecipeSelectable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override bool MatchesClass(string @class, out DataValue classValue)
public override bool IsSameAs(ISelectable other) => other is RecipeSelectable rs && rs.Name == Name;

/// <inheritdoc />
public override IModifiable OpenModification() => new JTokenModifiable(JObject["data"], SetModified);
public override IModifiable OpenModification() => new JTokenModifiable(JObject["recipeData"], SetModified);

/// <inheritdoc />
public override ISelectable AddElement(string elementType)
Expand Down

0 comments on commit 5e9a3e7

Please sign in to comment.