Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
112 changes: 112 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion IceSkates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ItemGroup>

<!-- Copy built DLL into the mod folder for testing -->
<Target Name="CopyToMods" AfterTargets="Build">
<Target Name="CopyToMods" AfterTargets="Build" Condition="Exists('$(VintageStoryDataPath)')">
<PropertyGroup>
<ModOutputDir>$(VintageStoryDataPath)/Mods/IceSkates</ModOutputDir>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": ""
Expand Down
Loading