Skip to content

Commit c0e4b8b

Browse files
committed
Overhaul versioning and packaging
1 parent 48eac4b commit c0e4b8b

File tree

11 files changed

+63
-83
lines changed

11 files changed

+63
-83
lines changed

.github/workflows/build.yaml

+5-13
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,13 @@ jobs:
6060
run: |
6161
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?><Project ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"><PropertyGroup><VALHEIM_INSTALL>$HOME/VHINSTALL/</VALHEIM_INSTALL></PropertyGroup></Project>" > Environment.props
6262
63-
- name: Set plugin version number
64-
run: |
65-
version=$(cat Pokeheim/Package/manifest.json | jq -r .version_number)
66-
sed -e "s/PluginVersion = .*;/PluginVersion = \"$version\";/" \
67-
-i Pokeheim/Pokeheim.cs
68-
sed -e "s/(\"0.0.0.0\")/(\"$version.0\")/" \
69-
-i Pokeheim/Properties/AssemblyInfo.cs
63+
- name: Build debug version
64+
run: ./scripts/build.sh Debug
7065

71-
- name: Build solution
66+
- name: Build release zip
7267
run: |
73-
./scripts/build.sh Debug
74-
./scripts/build.sh Release
75-
76-
- name: Build zip
77-
run: scripts/build-package-zip.sh
68+
# Set a dummy version for CI builds generated on every push.
69+
RELEASE_VERSION="0.0.1" ./scripts/build-package-zip.sh
7870
7971
- uses: actions/upload-artifact@v2
8072
with:

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ DocProject/Help/*.hhp
175175
DocProject/Help/Html2
176176
DocProject/Help/html
177177

178-
# Click-Once directory
179-
publish/
180-
181178
# Publish Web Output
182179
*.[Pp]ublish.xml
183180
*.azurePubxml

Pokeheim/Package/unex.yml

-5
This file was deleted.

Pokeheim/Pokeheim.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,19 @@
2828

2929
using Logger = Jotunn.Logger;
3030

31+
[assembly: AssemblyTitle("Pokeheim")]
32+
[assembly: AssemblyProduct("Pokeheim")]
33+
[assembly: AssemblyCopyright("Copyright © 2021 Joey Parrish")]
34+
[assembly: AssemblyVersion(Pokeheim.ModVersion.String + ".0")]
35+
3136
namespace Pokeheim {
37+
#if DEBUG
38+
// This is generated at build time for releases.
39+
public static class ModVersion {
40+
public const string String = "0.0.1";
41+
}
42+
#endif
43+
3244
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]
3345
// We are incompatible with AllTameable.
3446
[BepInIncompatibility("meldurson.valheim.AllTameable")]
@@ -42,7 +54,7 @@ public class PokeheimMod : BaseUnityPlugin {
4254
// BepInEx' plugin metadata
4355
public const string PluginGUID = "com.pokeheim";
4456
public const string PluginName = "Pokeheim";
45-
public const string PluginVersion = "0.0.0";
57+
public const string PluginVersion = ModVersion.String;
4658

4759
internal static readonly Harmony harmony = new Harmony(PluginName);
4860
private static string PokeheimIntroFlag = "com.pokeheim.IntroSeen";

Pokeheim/Pokeheim.csproj

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<WarningLevel>4</WarningLevel>
3939
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
4040
<Prefer32Bit>false</Prefer32Bit>
41+
<CoreCompileDependsOn>GenerateVersionFile;$(CoreCompileDependsOn)</CoreCompileDependsOn>
4142
</PropertyGroup>
4243
<ItemGroup>
4344
<Reference Include="0Harmony, Version=2.10.0.0, Culture=neutral, PublicKeyToken=null">
@@ -84,7 +85,6 @@
8485
<Reference Include="System.Xml" />
8586
</ItemGroup>
8687
<ItemGroup>
87-
<Compile Include="Properties\AssemblyInfo.cs" />
8888
<Compile Include="Properties\IgnoreAccessModifiers.cs" />
8989
<Compile Include="Pokeheim.cs" />
9090
<Compile Include="Berries.cs" />
@@ -116,6 +116,24 @@
116116
<None Include="packages.config" />
117117
</ItemGroup>
118118
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
119+
<Target Name="GenerateVersionFile">
120+
<PropertyGroup>
121+
<ReleaseVersionCode>
122+
namespace Pokeheim {
123+
public static class ModVersion {
124+
public const string String = "$(RELEASE_VERSION)"%3B
125+
}
126+
}
127+
</ReleaseVersionCode>
128+
</PropertyGroup>
129+
<WriteLinesToFile
130+
File="$(IntermediateOutputPath)ReleaseVersion.g.cs"
131+
Lines="$(ReleaseVersionCode)"
132+
Overwrite="true" />
133+
<ItemGroup>
134+
<Compile Include="$(IntermediateOutputPath)ReleaseVersion.g.cs" />
135+
</ItemGroup>
136+
</Target>
119137
<Target Name="EnsureEnvironmentPropsImport" BeforeTargets="PrepareForBuild">
120138
<PropertyGroup>
121139
<ErrorText>This project needs a Environment.props file with the path to your Valheim installation. See https://github.com/Valheim-Modding/JotunnModStub. {0} is missing.</ErrorText>

Pokeheim/Properties/AssemblyInfo.cs

-53
This file was deleted.
File renamed without changes.
File renamed without changes.

publish/main-menu-screenshot.png

2.49 MB
Loading

Pokeheim/Package/manifest.json renamed to publish/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Pokeheim",
3-
"version_number": "1.0.0",
3+
"version_number": "0.0.1",
44
"website_url": "https://github.com/joeyparrish/pokeheim",
55
"description": "Pokéheim - A Valheim mod about catching 'em all.",
66
"dependencies": [

scripts/build-package-zip.sh renamed to scripts/package.sh

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,51 @@
11
#!/bin/bash
22

3+
if [ -z "$RELEASE_VERSION" ]; then
4+
echo "You must set the environment variable \$RELEASE_VERSION," 1>&2
5+
echo "and use semantic versioning." 1>&2
6+
exit 1
7+
fi
8+
9+
# Fail on error.
310
set -e
4-
set -x
511

12+
# Go to the project's root directory.
613
cd "$(dirname "$0")"/..
714

15+
# Log steps.
16+
set -x
17+
18+
# Build a clean release.
19+
rm -rf Pokeheim/bin/
820
./scripts/build.sh Release
921

22+
# Make a generic zip.
1023
rm -rf staging Pokeheim.zip
1124
mkdir -p staging/Pokeheim/Assets
25+
# Stage mod & assets.
1226
cp Pokeheim/bin/Release/Pokeheim.dll staging/Pokeheim/
1327
cp Pokeheim/Assets/*.png staging/Pokeheim/Assets/
1428
cp Pokeheim/Assets/*.mp3 staging/Pokeheim/Assets/
15-
cp Pokeheim/Package/{icon.png,manifest.json} staging/
16-
cp README.md staging/
1729
cp -a Pokeheim/Assets/Translations staging/Pokeheim/Assets/
30+
# Stage mod metadata.
31+
cp publish/icon.png staging/
32+
cp README.md staging/
33+
cat publish/manifest.json \
34+
| jq ".version_number = \"$RELEASE_VERSION\"" \
35+
> staging/manifest.json
36+
# Zip it.
1837
(cd staging; zip -r9 ../Pokeheim.zip *)
1938

39+
# Stop logging.
2040
set +x
41+
42+
# Double-check versioning.
2143
manifest_version=$(cat staging/manifest.json | jq -r .version_number)
2244
dll_version=$(monodis --assembly staging/Pokeheim/Pokeheim.dll \
2345
| grep Version | cut -f 2 -d : | tr -d ' ')
24-
2546
if [[ "$manifest_version.0" != "$dll_version" ]]; then
2647
echo "Version mismatch!"
2748
echo " Manifest version $manifest_version"
2849
echo " DLL version $dll_version"
2950
exit 1
3051
fi
31-
32-
rm -rf staging

0 commit comments

Comments
 (0)