Skip to content

Commit 5926f56

Browse files
Merge pull request #1 from Shuits-CU-Mods/inProg
Update template to live
2 parents 57768e6 + a5617ed commit 5926f56

13 files changed

Lines changed: 183 additions & 43 deletions

.github/workflows/dotnet.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: Build and Release Mod
5+
6+
on:
7+
push:
8+
branches:
9+
- "main"
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: windows-latest
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout Code
19+
uses: actions/checkout@v4
20+
21+
- name: Check version
22+
id: check
23+
shell: bash
24+
run: |
25+
set -euo pipefail
26+
export LC_ALL=C.UTF-8
27+
export LANG=C.UTF-8
28+
29+
die() {
30+
local MSG="$1"
31+
{
32+
printf 'version=\n'
33+
printf 'latest_tag=\n'
34+
printf 'project_name=\n'
35+
printf 'should_release=false\n'
36+
} >> "$GITHUB_OUTPUT"
37+
printf '%s\n' "$MSG" >&2
38+
exit 1
39+
}
40+
41+
PROJECT_NAME=$(ls *.csproj | head -n1 | xargs -n1 basename -s .csproj)
42+
43+
FILE="./main.cs"
44+
if [ ! -f "$FILE" ]; then
45+
die "No $FILE found; skipping release."
46+
fi
47+
48+
ATTR=$(grep -m1 -Po '\[BepInPlugin\([^)]*\)\]' "$FILE" || true)
49+
if [ -z "$ATTR" ]; then
50+
die "Could not find BepInPlugin attribute"
51+
else
52+
ARG3=$(printf '%s' "$ATTR" | grep -Po '(?:[^,]+,\s*){2}\K([^)]+)' || true)
53+
if [ -z "$ARG3" ]; then
54+
die "Cannot find BepInPlugin argument 3 (version)"
55+
fi
56+
ARG3="$(printf '%s' "$ARG3" | xargs)"
57+
58+
if [[ "$ARG3" == \"*\" ]]; then
59+
VER="${ARG3%\"}"
60+
VER="${VER#\"}"
61+
else
62+
VER=$(grep -m1 -Po "\b$ARG3\b[\s=]+\"\K[^\"]+" "$FILE" || true)
63+
if [ -z "$VER" ]; then
64+
die "Could not find BepInPlugin version variable assignment matching version formatting"
65+
fi
66+
fi
67+
fi
68+
69+
VERSION_TEST_REGEX='^[0-9]+(\.[0-9]+)*$'
70+
if [[ ! "$VER" =~ $VERSION_TEST_REGEX ]]; then
71+
die "Invalid version format: $VER"
72+
fi
73+
74+
VERSION_ZERO_REGEX='^0+(\.0+)*$'
75+
if [[ "$VER" =~ $VERSION_ZERO_REGEX ]]; then
76+
{
77+
printf 'version=%s\n' "$VER"
78+
printf 'latest_tag=\n'
79+
printf 'project_name=%s\n' "$PROJECT_NAME"
80+
printf 'should_release=false\n'
81+
} >> "$GITHUB_OUTPUT"
82+
echo "Version is zero (no release): $VER" >&2
83+
exit 0
84+
fi
85+
86+
git fetch --tags --force
87+
LATEST_TAG_RAW="$(git tag | grep -E '^v?[0-9]+(\.[0-9]+)*$' | sort -V | tail -n1 || true)"
88+
if [ -z "$LATEST_TAG_RAW" ]; then
89+
LATEST_TAG=""
90+
SHOULD_RELEASE=true
91+
else
92+
LATEST_TAG="${LATEST_TAG_RAW#v}"
93+
94+
NEWEST="$(printf '%s\n%s\n' "$LATEST_TAG" "$VER" | sort -V | tail -n1)"
95+
if [ "$NEWEST" = "$VER" ] && [ "$VER" != "$LATEST_TAG" ]; then
96+
SHOULD_RELEASE=true
97+
else
98+
SHOULD_RELEASE=false
99+
fi
100+
101+
OLDEST="$(printf '%s\n%s\n' "$LATEST_TAG" "$VER" | sort -V | head -n1)"
102+
if [ "$OLDEST" = "$VER" ] && [ "$VER" != "$LATEST_TAG" ]; then
103+
die "Version downgrade has been caught: $VER is older than latest tag $LATEST_TAG"
104+
fi
105+
fi
106+
107+
{
108+
printf 'version=%s\n' "$VER"
109+
printf 'latest_tag=%s\n' "$LATEST_TAG"
110+
printf 'project_name=%s\n' "$PROJECT_NAME"
111+
printf 'should_release=%s\n' "$SHOULD_RELEASE"
112+
} >> "$GITHUB_OUTPUT"
113+
114+
- name: Build mod
115+
if: steps.check.outputs.should_release == 'true'
116+
id: build
117+
env:
118+
PROJECT_NAME: ${{ steps.check.outputs.project_name }}
119+
shell: bash
120+
run: |
121+
dotnet build -c Release
122+
ASSET_PATH=$(find . -type f -iname "$PROJECT_NAME.dll" | head -n1)
123+
if [ -z "$ASSET_PATH" ]; then
124+
echo "Build DLL not found!" >&2
125+
exit 1
126+
fi
127+
echo "asset_path=$ASSET_PATH" >> "$GITHUB_OUTPUT"
128+
129+
- name: Create Github Release
130+
if: steps.check.outputs.should_release == 'true'
131+
id: create_release
132+
uses: actions/create-release@v1
133+
with:
134+
tag_name: v${{ steps.check.outputs.version }}
135+
release_name: Release v${{ steps.check.outputs.version }}
136+
draft: false
137+
prerelease: false
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
141+
- name: Upload Release Asset
142+
if: steps.check.outputs.should_release == 'true'
143+
uses: actions/upload-release-asset@v1
144+
with:
145+
upload_url: ${{ steps.create_release.outputs.upload_url }}
146+
asset_path: ${{ steps.build.outputs.asset_path }}
147+
asset_name: ${{ steps.check.outputs.project_name }}-v${{ steps.check.outputs.version }}.dll
148+
asset_content_type: application/octet-stream
149+
env:
150+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

BepInEx-Mod-Template.csproj

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ProjectGuid>{CAB60128-2C09-4ABD-8786-16839DB58CFC}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>BepInExModTemplate</RootNamespace>
11-
<AssemblyName>BepInExModTemplate</AssemblyName>
10+
<RootNamespace>BepInEx-Mod-Template</RootNamespace>
11+
<AssemblyName>BepInEx-Mod-Template</AssemblyName>
1212
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<Deterministic>true</Deterministic>
@@ -31,59 +31,49 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="0Harmony">
35-
<HintPath>..\Libraries\0Harmony.dll</HintPath>
34+
<Compile Include="Helpers\CustomAudioManager.cs" />
35+
<Compile Include="Helpers\FileLoader.cs" />
36+
<Compile Include="main.cs" />
37+
<Compile Include="Properties\AssemblyInfo.cs" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<SpecificVersion>False</SpecificVersion>
42+
<HintPath>Libraries\0Harmony.dll</HintPath>
3643
</Reference>
37-
<Reference Include="Assembly-CSharp">
38-
<HintPath>..\Libraries\Assembly-CSharp.dll</HintPath>
44+
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
45+
<SpecificVersion>False</SpecificVersion>
46+
<HintPath>Libraries\Assembly-CSharp.dll</HintPath>
3947
</Reference>
40-
<Reference Include="BepInEx">
41-
<HintPath>..\Libraries\BepInEx.dll</HintPath>
48+
<Reference Include="BepInEx, Version=5.4.23.4, Culture=neutral, processorArchitecture=MSIL">
49+
<SpecificVersion>False</SpecificVersion>
50+
<HintPath>Libraries\BepInEx.dll</HintPath>
4251
</Reference>
4352
<Reference Include="NAudio">
44-
<HintPath>..\Libraries\NAudio.dll</HintPath>
53+
<HintPath>Libraries\NAudio.dll</HintPath>
4554
</Reference>
4655
<Reference Include="NAudio.Core">
47-
<HintPath>..\Libraries\NAudio.Core.dll</HintPath>
56+
<HintPath>Libraries\NAudio.Core.dll</HintPath>
4857
</Reference>
49-
<Reference Include="System" />
50-
<Reference Include="System.Core" />
51-
<Reference Include="System.Xml.Linq" />
52-
<Reference Include="System.Data.DataSetExtensions" />
53-
<Reference Include="Microsoft.CSharp" />
54-
<Reference Include="System.Data" />
55-
<Reference Include="System.Net.Http" />
56-
<Reference Include="System.Xml" />
57-
<Reference Include="Unity.RenderPipelines.Core.Runtime">
58-
<HintPath>..\Libraries\Unity.RenderPipelines.Core.Runtime.dll</HintPath>
58+
<Reference Include="Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
59+
<SpecificVersion>False</SpecificVersion>
60+
<HintPath>Libraries\Unity.TextMeshPro.dll</HintPath>
5961
</Reference>
60-
<Reference Include="Unity.TextMeshPro">
61-
<HintPath>..\Libraries\Unity.TextMeshPro.dll</HintPath>
62+
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
63+
<SpecificVersion>False</SpecificVersion>
64+
<HintPath>Libraries\UnityEngine.dll</HintPath>
6265
</Reference>
63-
<Reference Include="UnityEngine">
64-
<HintPath>..\Libraries\UnityEngine.dll</HintPath>
66+
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
67+
<SpecificVersion>False</SpecificVersion>
68+
<HintPath>Libraries\UnityEngine.AudioModule.dll</HintPath>
6569
</Reference>
66-
<Reference Include="UnityEngine.AudioModule">
67-
<HintPath>..\Libraries\UnityEngine.AudioModule.dll</HintPath>
68-
</Reference>
69-
<Reference Include="UnityEngine.CoreModule">
70-
<HintPath>..\Libraries\UnityEngine.CoreModule.dll</HintPath>
70+
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
71+
<SpecificVersion>False</SpecificVersion>
72+
<HintPath>Libraries\UnityEngine.CoreModule.dll</HintPath>
7173
</Reference>
7274
<Reference Include="UnityEngine.ImageConversionModule">
73-
<HintPath>..\Libraries\UnityEngine.ImageConversionModule.dll</HintPath>
74-
</Reference>
75-
<Reference Include="UnityEngine.ParticleSystemModule">
76-
<HintPath>..\Libraries\UnityEngine.ParticleSystemModule.dll</HintPath>
75+
<HintPath>Libraries\UnityEngine.ImageConversionModule.dll</HintPath>
7776
</Reference>
78-
<Reference Include="UnityEngine.UI">
79-
<HintPath>..\Libraries\UnityEngine.UI.dll</HintPath>
80-
</Reference>
81-
</ItemGroup>
82-
<ItemGroup>
83-
<Compile Include="Helpers\CustomAudioManager.cs" />
84-
<Compile Include="Helpers\FileLoader.cs" />
85-
<Compile Include="main.cs" />
86-
<Compile Include="Properties\AssemblyInfo.cs" />
8777
</ItemGroup>
8878
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8979
</Project>

Libraries/0Harmony.dll

200 KB
Binary file not shown.

Libraries/Assembly-CSharp.dll

631 KB
Binary file not shown.

Libraries/BepInEx.dll

125 KB
Binary file not shown.

Libraries/NAudio.Core.dll

184 KB
Binary file not shown.

Libraries/NAudio.dll

7.5 KB
Binary file not shown.

Libraries/Unity.TextMeshPro.dll

372 KB
Binary file not shown.
69.9 KB
Binary file not shown.
1.33 MB
Binary file not shown.

0 commit comments

Comments
 (0)