Skip to content

SpaceWarp 1.9.5

SpaceWarp 1.9.5 #9

Workflow file for this run

name: Publish NuGet Package
env:
MOD_ID: 3277
KSP2_ID: 22407
FORUM_URL: 'https://forum.kerbalspaceprogram.com/topic/218490-space-warp-v190-for-ksp2-0200/'
FORUM_TITLE: 'Space Warp [v{version} for KSP2 {ksp2_version}]'
on:
release:
types: [ "published" ]
jobs:
publish:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install jq
uses: dcarbone/[email protected]
- name: Download NuGet
id: download-nuget
run: |
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
- name: Build the solution
run: dotnet build "SpaceWarp.sln" -c Release
- name: Extract current version
id: get-version
run: |
version=$(jq -r '.version' plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json)
echo "Version is $version"
echo "version=$version" >> $GITHUB_ENV
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
wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq -r '.[0].body' > ./changelog.md
- name: Check if version exists
id: check-version
run: |
version=${{ env.version }}
response=$(curl -s "https://nuget.spacewarp.org/v3/search?q=SpaceWarp")
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"
else
echo "Version $version does not exist in the NuGet repository"
echo "should_publish=true" >> $GITHUB_ENV
fi
- name: Publish NuGet package
if: env.should_publish == 'true'
run: |
nupkg_path=$(ls -1 nuget/SpaceWarp.*.nupkg | head -n 1)
dotnet nuget push "$nupkg_path" -s https://nuget.spacewarp.org/v3/index.json -k ${{ secrets.NUGET_SERVER_KEY }}
- name: Upload Zip
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.upload_url }}
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: Update spacedock
uses: KSP2Community/[email protected]
with:
username: ${{ secrets.SPACEDOCK_USER }}
password: ${{ secrets.SPACEDOCK_PASSWORD }}
game_id: 22407
mod_id: 3277
version: ${{ env.version }}
zipball: ${{ env.zip }}
changelog: ./changelog.md
- name: Update mod topic
uses: Kerbalight/ksp2-forum-post-action@latest
with:
username: ${{ secrets.FORUM_USER }}
password: ${{ secrets.FORUM_PASSWORD }}
forum_topic_url: ${{ env.FORUM_URL }}
forum_topic_title: ${{ env.FORUM_TITLE }}
spacedock_url: https://spacedock.info/mod/3277/Space%20Warp%20+%20BepInEx
version: ${{ env.version }}
swinfo_path: 'plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json'
changelog: ./changelog.md
- name: Prepare content
shell: bash
run: |
echo -e "## SpaceWarp v${version}\n" > ./content.md
cat ./changelog.md >> ./content.md
{
echo 'discord_message<<EOF'
cat ./content.md
echo EOF
} >> "$GITHUB_ENV"