Skip to content

round 3

round 3 #22

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
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: 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
cat ${{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: 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: Install dependencies
run: |
mkdir packages
dotnet restore
nuget restore -PackagesDirectory packages ${{env.name}}/packages.config
dotnet tool restore
# uncomment below and remove "Manually publicize" step once this is resolved: https://github.com/BepInEx/BepInEx.AssemblyPublicizer/issues/11
#dotnet build --configuration Release --no-restore
- name: Manually publicize and build
run: |
# as described above in "Install dependencies": remove entire step once that issue is resolved
dotnet tool install -g BepInEx.AssemblyPublicizer.Cli
# <HintPath>\home\runner\.local\share\Steam\steamapps\common\Valheim\valheim_Data\Managed\assembly_valheim.dll</HintPath>
# /home/runner/.local/share/Steam/steamapps/common/Valheim/valheim_Data/Managed/assembly_valheim.dll
assembly-publicizer --overwrite ${{env.valheiminstalldir}}/valheim_Data/Managed/assembly_valheim.dll
dotnet build --configuration Release --no-restore
- name: Package
run: |
find packages -name 'ChebsValheimLibrary.dll' -path '*/lib/net48/*' -exec cp -f {} ${{env.name}}/Package/plugins \;
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}}