From 49354d0c06d94fd438bac4723bc0afc8592b4f0a Mon Sep 17 00:00:00 2001 From: cheese3660 Date: Mon, 1 Jan 2024 19:28:58 -0500 Subject: [PATCH] Update release_nuget.yml --- .github/workflows/release_nuget.yml | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_nuget.yml b/.github/workflows/release_nuget.yml index 5d7df16..882f1ae 100644 --- a/.github/workflows/release_nuget.yml +++ b/.github/workflows/release_nuget.yml @@ -1,4 +1,7 @@ name: Publish NuGet Package +env: + MOD_ID: 3277 + KSP2_ID: 22407 on: release: @@ -32,6 +35,7 @@ jobs: echo "artifact_name=spacewarp-release-$version.zip" >> $GITHUB_ENV echo "zip=$(ls -1 dist/SpaceWarp-*.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 - name: Check if version exists id: check-version @@ -41,7 +45,6 @@ jobs: exists=$(echo "$response" | jq -r --arg id "SpaceWarp" --arg version "$version" '.data[] | select(.id == $id) | .versions[] | select(.version == $version) | .version') if [ "$exists" == "$version" ]; then echo "Version $version already exists in the NuGet repository" - exit 1 else echo "Version $version does not exist in the NuGet repository" echo "should_publish=true" >> $GITHUB_ENV @@ -62,4 +65,32 @@ jobs: asset_path: ${{ env.zip }} asset_name: ${{ env.artifact_name }} 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.GAME_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