Skip to content

Commit

Permalink
Update on-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cheese3660 authored Jan 2, 2024
1 parent 4a7cd46 commit 1240cdb
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish NuGet and upload release
env:
MOD_ID: 3482
LATEST_GAME_VERSION: 0.2.0
LATEST_GAME_VERSION: 0.2.0.0

on:
release:
Expand Down Expand Up @@ -35,7 +35,7 @@ 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 \")" >> $GITHUB_ENV
echo "changelog=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].body' | tr -d \" | sed 's/@/%40/g')" >> $GITHUB_ENV
- name: Check if version exists
id: check-version
Expand All @@ -45,7 +45,6 @@ jobs:
exists=$(echo "$response" | jq -r --arg id "PatchManager" --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
Expand All @@ -66,12 +65,15 @@ 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
if [ "$login_errored" == "true" ]; then
echo "Login to space dock errored: $(echo $login_response | jq .reason)"
exit 1
else
Expand All @@ -80,5 +82,12 @@ jobs:
- name: Update mod on spacedock
run: |
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"
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

0 comments on commit 1240cdb

Please sign in to comment.