-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae36a89
commit e450553
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
name: Upload release | ||
env: | ||
MOD_ID: 3484 | ||
KSP2_ID: 22407 | ||
|
||
on: | ||
release: | ||
|
@@ -24,10 +27,13 @@ jobs: | |
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] | ||
|
@@ -38,3 +44,32 @@ jobs: | |
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 |