diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f03cb7a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build + +on: + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Cache VS DLLs + id: cache + uses: actions/cache@v4 + with: + path: ~/vs-game + key: vs-game-1.21.6 + + - name: Download VS DLLs + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p ~/vs-game/Mods ~/vs-game/Lib /tmp/vs-extract + curl -sSL https://cdn.vintagestory.at/gamefiles/stable/vs_client_linux-x64_1.21.6.tar.gz \ + | tar xz -C /tmp/vs-extract + VS_ROOT=$(find /tmp/vs-extract -name "VintagestoryAPI.dll" -printf '%h\n' -quit) + cp "$VS_ROOT"/VintagestoryAPI.dll ~/vs-game/ + cp "$VS_ROOT"/VintagestoryLib.dll ~/vs-game/ + cp "$VS_ROOT"/Vintagestory.dll ~/vs-game/ + cp "$VS_ROOT"/Mods/VSSurvivalMod.dll ~/vs-game/Mods/ + cp "$VS_ROOT"/Lib/SkiaSharp.dll ~/vs-game/Lib/ + cp "$VS_ROOT"/Lib/Newtonsoft.Json.dll ~/vs-game/Lib/ + rm -rf /tmp/vs-extract + + - name: Build + run: dotnet build -c Release -p:VintageStoryPath=$HOME/vs-game diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f8f63ba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,112 @@ +name: Release + +on: + push: + branches: [main] + +permissions: + contents: write + +concurrency: + group: release + cancel-in-progress: false + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Determine version bump + id: bump + env: + GH_TOKEN: ${{ github.token }} + run: | + PR_NUMBER=$(gh pr list --state merged --base main --json number,mergeCommit \ + --jq ".[] | select(.mergeCommit.oid == \"$GITHUB_SHA\") | .number") + BUMP="patch" + if [ -n "$PR_NUMBER" ]; then + LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name') + if echo "$LABELS" | grep -q "version:major"; then + BUMP="major" + elif echo "$LABELS" | grep -q "version:minor"; then + BUMP="minor" + fi + fi + echo "bump=$BUMP" >> "$GITHUB_OUTPUT" + + - name: Calculate next version + id: version + run: | + LATEST=$(git tag -l 'v*' --sort=-v:refname | head -n1) + if [ -z "$LATEST" ]; then + NEXT="1.0.0" + else + VER="${LATEST#v}" + IFS='.' read -r MAJOR MINOR PATCH <<< "$VER" + BUMP="${{ steps.bump.outputs.bump }}" + if [ "$BUMP" = "major" ]; then + NEXT="$((MAJOR + 1)).0.0" + elif [ "$BUMP" = "minor" ]; then + NEXT="${MAJOR}.$((MINOR + 1)).0" + else + NEXT="${MAJOR}.${MINOR}.$((PATCH + 1))" + fi + fi + echo "version=$NEXT" >> "$GITHUB_OUTPUT" + + - name: Inject version into modinfo.json + run: | + jq --arg v "${{ steps.version.outputs.version }}" \ + '.version = $v' modinfo.json > modinfo.tmp && mv modinfo.tmp modinfo.json + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Cache VS DLLs + id: cache + uses: actions/cache@v4 + with: + path: ~/vs-game + key: vs-game-1.21.6 + + - name: Download VS DLLs + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p ~/vs-game/Mods ~/vs-game/Lib /tmp/vs-extract + curl -sSL https://cdn.vintagestory.at/gamefiles/stable/vs_client_linux-x64_1.21.6.tar.gz \ + | tar xz -C /tmp/vs-extract + VS_ROOT=$(find /tmp/vs-extract -name "VintagestoryAPI.dll" -printf '%h\n' -quit) + cp "$VS_ROOT"/VintagestoryAPI.dll ~/vs-game/ + cp "$VS_ROOT"/VintagestoryLib.dll ~/vs-game/ + cp "$VS_ROOT"/Vintagestory.dll ~/vs-game/ + cp "$VS_ROOT"/Mods/VSSurvivalMod.dll ~/vs-game/Mods/ + cp "$VS_ROOT"/Lib/SkiaSharp.dll ~/vs-game/Lib/ + cp "$VS_ROOT"/Lib/Newtonsoft.Json.dll ~/vs-game/Lib/ + rm -rf /tmp/vs-extract + + - name: Build + run: dotnet build -c Release -p:VintageStoryPath=$HOME/vs-game + + - name: Package ZIP + run: | + VERSION="${{ steps.version.outputs.version }}" + mkdir -p /tmp/package + cp bin/Release/IceSkates.dll /tmp/package/ + cp modinfo.json /tmp/package/ + cp -r assets /tmp/package/ + cd /tmp/package + zip -r "$GITHUB_WORKSPACE/IceSkates-v${VERSION}.zip" . + + - name: Create GitHub Release + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION="${{ steps.version.outputs.version }}" + gh release create "v${VERSION}" "IceSkates-v${VERSION}.zip" \ + --title "Ice Skates v${VERSION}" \ + --generate-notes diff --git a/IceSkates.csproj b/IceSkates.csproj index 5c933db..9b09ab1 100644 --- a/IceSkates.csproj +++ b/IceSkates.csproj @@ -44,7 +44,7 @@ - + $(VintageStoryDataPath)/Mods/IceSkates diff --git a/modinfo.json b/modinfo.json index 7a89bf2..3f03311 100644 --- a/modinfo.json +++ b/modinfo.json @@ -4,7 +4,7 @@ "name": "Ice Skates", "authors": ["illmatix"], "description": "Forge ice skate blades, strap them up with hide, leather, or fur, and glide across frozen lakes!", - "version": "1.0.0", + "version": "0.0.0-dev", "requiredOnClient": true, "dependencies": { "game": ""