2626jobs :
2727 build-and-release :
2828 runs-on : ubuntu-latest
29+ permissions :
30+ contents : write
31+ packages : write
2932
3033 steps :
3134 - name : Checkout repository
3235 uses : actions/checkout@v4
3336 with :
34- # Don't use submodules: recursive here - it will fail!
37+ submodules : recursive
3538 fetch-depth : 0
3639
3740 - name : Setup .NET
3841 uses : actions/setup-dotnet@v4
39- # Let it auto-detect and install required versions
42+ with :
43+ dotnet-version : |
44+ 3.0.x
45+ 3.1.x
46+ 5.0.x
47+ 6.0.x
48+ 7.0.x
49+ 8.0.x
50+ 9.0.x
4051
4152 - name : Determine version
4253 id : version
@@ -62,50 +73,92 @@ jobs:
6273 BASE_VERSION=$(echo $VERSION | sed 's/-.*//')
6374 PRERELEASE_SUFFIX=$(echo $VERSION | grep -oP '\-.*' || echo "")
6475
65- # Update Directory.Build.props - use MonoMod from NuGet
76+ # Update Directory.Build.props
6677 sed -i "s|<HarmonyVersion>.*</HarmonyVersion>|<HarmonyVersion>${BASE_VERSION}.0</HarmonyVersion>|" Directory.Build.props
6778 sed -i "s|<HarmonyPrerelease>.*</HarmonyPrerelease>|<HarmonyPrerelease>${PRERELEASE_SUFFIX}</HarmonyPrerelease>|" Directory.Build.props
6879
69- # IMPORTANT: Set MonoModCoreVersion to avoid submodule dependency
70- sed -i "s|<MonoModCoreVersion>.*</MonoModCoreVersion>|<MonoModCoreVersion>1.3.0 </MonoModCoreVersion>|" Directory.Build.props
80+ # Use current git submodule state for MonoMod.Core - set empty to use submodule
81+ sed -i "s|<MonoModCoreVersion>.*</MonoModCoreVersion>|<MonoModCoreVersion></MonoModCoreVersion>|" Directory.Build.props
7182
7283 echo "Updated Directory.Build.props:"
7384 grep -E "HarmonyVersion|HarmonyPrerelease|MonoModCoreVersion" Directory.Build.props
7485
86+ - name : Restore dependencies
87+ run : dotnet restore Harmony.sln
88+
7589 - name : Build Solution
7690 run : |
77- # Use the same build command as test-build.yml
78- dotnet build -c Release Harmony.sln
91+ # Build all three library variants as required by pardeike
92+ echo "Building Lib.Harmony (full package with dependencies merged)..."
93+ dotnet build -c Release Lib.Harmony/Lib.Harmony.csproj
94+
95+ echo "Building Lib.Harmony.Thin (lightweight without merged dependencies)..."
96+ dotnet build -c Release Lib.Harmony.Thin/Lib.Harmony.Thin.csproj
97+
98+ echo "Building Lib.Harmony.Ref (reference assemblies only)..."
99+ dotnet build -c Release Lib.Harmony.Ref/Lib.Harmony.Ref.csproj
79100
80101 - name : Run Tests
81102 run : |
82- dotnet test -c Release --no-build --verbosity normal || echo "Tests completed with warnings"
103+ # Tests MUST pass before release - no bypassing failures
104+ echo "Running all test projects..."
105+ dotnet test -c Release --no-build --verbosity normal HarmonyTests/HarmonyTests.csproj
106+ TEST_RESULT=$?
107+ if [ $TEST_RESULT -ne 0 ]; then
108+ echo "❌ Tests failed with exit code $TEST_RESULT. Release cannot proceed."
109+ echo "Please fix all test failures before creating a release."
110+ exit 1
111+ fi
112+ echo "✅ All tests passed successfully!"
83113
84114 - name : Create NuGet Packages
85115 run : |
86- # Build the actual NuGet packages
116+ # Build NuGet packages for all three library variants
87117 dotnet pack Lib.Harmony/Lib.Harmony.csproj -c Release --no-build --output ./artifacts
88118 dotnet pack Lib.Harmony.Thin/Lib.Harmony.Thin.csproj -c Release --no-build --output ./artifacts
89119 dotnet pack Lib.Harmony.Ref/Lib.Harmony.Ref.csproj -c Release --no-build --output ./artifacts
90120
91121 echo "Generated packages:"
92122 ls -la ./artifacts/
93123
124+ - name : Create Release Zip Files
125+ run : |
126+ # Create zip files for each library variant
127+ mkdir -p ./release-zips
128+
129+ # Zip Lib.Harmony
130+ cd Lib.Harmony/bin/Release
131+ zip -r ../../../release-zips/Lib.Harmony-v${{ steps.version.outputs.version }}.zip .
132+ cd ../../..
133+
134+ # Zip Lib.Harmony.Thin
135+ cd Lib.Harmony.Thin/bin/Release
136+ zip -r ../../../release-zips/Lib.Harmony.Thin-v${{ steps.version.outputs.version }}.zip .
137+ cd ../../..
138+
139+ # Zip Lib.Harmony.Ref
140+ cd Lib.Harmony.Ref/bin/Release
141+ zip -r ../../../release-zips/Lib.Harmony.Ref-v${{ steps.version.outputs.version }}.zip .
142+ cd ../../..
143+
144+ echo "Generated zip files:"
145+ ls -la ./release-zips/
146+
94147 - name : Upload Artifacts
95148 uses : actions/upload-artifact@v4
96149 with :
97150 name : nuget-packages
98151 path : ./artifacts/*.nupkg
99152 if-no-files-found : warn
100153
101- - name : Upload Harmony Zip
154+ - name : Upload Release Zips
102155 uses : actions/upload-artifact@v4
103156 with :
104- name : Harmony-Release
105- path : Harmony/bin /*.zip
106- if-no-files-found : warn
157+ name : Harmony-Release-Zips
158+ path : ./release-zips /*.zip
159+ if-no-files-found : error
107160
108- # Publishing steps (only on tag push or manual trigger from master)
161+ # Publishing steps (only on tag push or manual trigger from master after tests pass )
109162 - name : Publish to NuGet
110163 if : success() && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'))
111164 run : |
@@ -169,7 +222,7 @@ jobs:
169222 - [Changelog](https://github.com/${{ github.repository }}/commits/v${{ steps.version.outputs.version }})
170223 files : |
171224 ./artifacts/*.nupkg
172- Harmony/bin /*.zip
225+ ./release-zips /*.zip
173226 prerelease : ${{ steps.version.outputs.is_prerelease == 'true' }}
174- draft : false
227+ draft : true
175228 token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments