Skip to content

let's try this again #9

let's try this again

let's try this again #9

Workflow file for this run

name: build
permissions:
contents: write
on:
push:
tags:
- 'v*' # Trigger only if the pushed tag starts with v
env:
name: ChebsNecromancy
jsonf: manifest.json
bepinexdl: https://github.com/BepInEx/BepInEx/releases/download/v5.4.21/BepInEx_unix_5.4.21.0.zip
valheiminstalldir: /home/runner/.local/share/Steam/steamapps/common/Valheim
outf: README.bbc
readmef: README.md
cvldl: https://github.com/jpw1991/chebs-valheim-library/releases/tag/2.5.3/ChebsValheimLibrary.dll
jobs:
convert:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Install markdown_to_bbcodenm tool
run: dotnet tool install -g Converter.MarkdownToBBCodeNM.Tool
- name: Convert README.md to README.bbc
run: markdown_to_bbcodenm -i "README.md" -o "${{env.outf}}"
- name: Archive README.bbc
uses: actions/upload-artifact@v3
with:
name: bbc
path: ${{env.outf}}
build:
runs-on: ubuntu-latest
needs: convert
strategy:
matrix:
dotnet-version: [ '7.0.x' ]
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- uses: actions/download-artifact@v3
with:
name: bbc
- name: Get version
run: |
version="$(jq -r '.version_number' $(find ./${{env.name}}/Package -name ${{env.jsonf}}))"
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Get assets
run : |
assetversion=$(echo ${{env.VERSION}} | cut -d '.' -f 1).$(echo ${{env.VERSION}} | cut -d '.' -f 2).0
mkdir ${{env.name}}/Package/plugins
for asset in chebgonaz chebgonaz.manifest
do
wget https://github.com/jpw1991/chebs-necromancy/releases/download/asset$assetversion/$asset
[ ! -f "$asset" ] && echo "$asset not found!"
mv $asset ${{env.name}}/Package/plugins
done
- name: Install CVL
run: |
wget ${{ env.cvldl }}
- name: Replace paths inside csproj
run: |
sed -i -E "s/(\.\.\\\.\.\\\.\.\\\.local)/\\\\home\\\runner\\\.local/g" ${{env.name}}/${{env.name}}.csproj
sed -i -E "s/(\.\.\\\.\.\\\chebs-valheim-library\\\ChebsValheimLibrary\\\bin\\\Release)/\\\\home\\\runner/g" ${{env.name}}/${{env.name}}.csproj
sed -i -E "s/(\.\.\\\.\.\\\.\.\\\.config\\\r2modmanPlus-local\\\Valheim\\\profiles\\\cheb-development)/\\\\home\\\runner\\\.local\\\share\\\Steam\\\steamapps\\\common\\\Valheim/g" ${{env.name}}/${{env.name}}.csproj
- name: Get Valheim version id
run: |
valheimversion="$(curl -s https://api.steamcmd.net/v1/info/896660 | jq -r ".data.\"896660\".depots.branches.public.buildid")"
echo "VALHEIMVERSION=${valheimversion}" >> $GITHUB_ENV
- name: Cache Valheim
id: cachevalheim
uses: actions/cache@v3
with:
path: ${{env.valheiminstalldir}}
key: ${{ env.VALHEIMVERSION}}-${{hashFiles('**/lockfiles')}}-BepInEx_unix_5.4.21
- name: Download and install SteamCMD (64-bit)
if: steps.cachevalheim.outputs.cache-hit != 'true'
run: |
mkdir steamcmd
cd steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
cd ..
./steamcmd/steamcmd.sh +force_install_dir ${{env.valheiminstalldir}} +login anonymous +app_update 896660 validate +exit
- name: Install BepInEx
if: steps.cachevalheim.outputs.cache-hit != 'true'
run: |
mv ${{env.valheiminstalldir}}/valheim_server_Data/ ${{env.valheiminstalldir}}/valheim_Data/
wget -O BepInEx.zip ${{ env.bepinexdl }}
unzip BepInEx.zip -d ~/BepInEx
mv ~/BepInEx/* ${{env.valheiminstalldir}}/
- name: Replace paths inside csproj
run: |
sed -i -E "s/(\.\.\\\.\.\\\.\.\\\.local)/\\\\home\\\runner\\\.local/g" ${{env.name}}/${{env.name}}.csproj
sed -i -E "s/(\.\.\\\.\.\\\.\.\\\.config\\\r2modmanPlus-local\\\Valheim\\\profiles\\\cheb-development)/\\\\home\\\runner\\\.local\\\share\\\Steam\\\steamapps\\\common\\\Valheim/g" ${{env.name}}/${{env.name}}.csproj
- name: Install NuGet
uses: nuget/setup-nuget@v1
- name: Manual install Jotunn
run: |
echo "For some reason Jotunn via nuget won't work here, so manual install and link it. Remove this whenever possible"
wget https://github.com/Valheim-Modding/Jotunn/releases/download/v2.16.2/Jotunn.dll
mv Jotunn.dll /home/runner
refcontent='<Reference Include="Jotunn"><HintPath>\\home\\runner\\Jotunn.dll</HintPath></Reference>'
sed -i '/<Reference\sInclude="UnityEngine.PhysicsModule">/i\'"$refcontent" ${{env.name}}/${{env.name}}.csproj
- name: Confirm existence of critical files
run : |
for test in "BepInEx/core/BepInEx.dll" "valheim_Data/Managed/assembly_guiutils.dll" "valheim_Data/Managed/assembly_postprocessing.dll" "valheim_Data/Managed/assembly_utils.dll" "valheim_Data/Managed/assembly_valheim.dll" "valheim_Data/Managed/UnityEngine.dll" "valheim_Data/Managed/UnityEngine.AssetBundleModule.dll" "valheim_Data/Managed/UnityEngine.CoreModule.dll" "valheim_Data/Managed/UnityEngine.ParticleSystemModule.dll" "valheim_Data/Managed/UnityEngine.Physics2DModule.dll" "valheim_Data/Managed/UnityEngine.PhysicsModule.dll"; do
[ ! -f "${{env.valheiminstalldir}}/$test" ] && echo "$test not found!"
done
[ ! -f "/home/runner/Jotunn.dll" ] && echo "Jotunn.dll not found!"
cat ${{env.name}}/${{env.name}}.csproj
- name: Install dependencies and Build
run: |
mkdir packages
dotnet restore
nuget restore -PackagesDirectory packages ${{env.name}}/packages.config
dotnet tool restore
dotnet build --configuration Release --no-restore
- name: Package
run: |
cp -f ${{env.name}}/bin/Release/${{env.name}}.dll ${{env.name}}/Package/plugins
cp -f README.md ${{env.name}}/Package
(cd ${{env.name}}/Package && zip -r ../../${{env.name}}.${{env.VERSION}}.zip .)
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ env.VERSION }}
body: ${{github.event.workflow_run.head_commit.message}}
files: |
${{env.name}}.${{env.VERSION}}.zip
${{env.outf}}