-
-
Notifications
You must be signed in to change notification settings - Fork 4
149 lines (125 loc) · 5.39 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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
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/net48/${{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}}