fix: multiplayer compatibility #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - 'CHANGELOG.md' | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 | |
| with: | |
| dotnet-version: "8.0.x" | |
| - name: Install cocogitto | |
| uses: cocogitto/cocogitto-action@c7a74f5406bab86da17da0f0e460a69f8219a68c # v3 | |
| with: | |
| check: false | |
| git-user: "github-actions[bot]" | |
| git-user-email: "41898282+github-actions[bot]@users.noreply.github.com" | |
| # Build runs before the version bump so a broken build never creates a | |
| # tag. The pre_bump_hooks in cog.toml rebuild with the stamped version. | |
| # Only net48 — net8.0 needs real game DLLs which aren't available in CI. | |
| - name: Build (pre-flight) | |
| run: dotnet build 1.6/Source/KeyzAllowUtilities/KeyzAllowUtilities.csproj -c Release -p:TargetFramework=net48 | |
| # Falls back to the vendored 1.6/Source/lib/0MultiplayerAPI.dll — no SteamWorkshopDir | |
| # available in CI. | |
| - name: Build Multiplayer compat (pre-flight) | |
| run: dotnet build 1.6/Source/KeyzAllowUtilities.Multiplayer/KeyzAllowUtilities.Multiplayer.csproj -c Release -p:TargetFramework=net48 | |
| # Pre-flight build modifies the committed DLLs — discard so cog sees a | |
| # clean tree. The pre_bump_hooks will rebuild with the version stamp. | |
| - name: Clean pre-flight artifacts | |
| run: git checkout -- 1.6/Assemblies/ Compatibility/ | |
| # Requires a v* base tag to exist (bootstrap: git tag v1.0.0 && git push origin v1.0.0). | |
| # cog bump --auto reads conventional commits since the last tag and bumps accordingly. | |
| # pre_bump_hooks (cog.toml) rebuild the DLL with the stamped version and stage it. | |
| - name: Bump version and update changelog | |
| id: version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BEFORE=$(git describe --tags --abbrev=0) | |
| if cog bump --auto; then | |
| AFTER=$(git describe --tags --abbrev=0) | |
| if [ "$BEFORE" = "$AFTER" ]; then | |
| echo "No version change ($BEFORE) — skipping release" | |
| echo "bumped=false" >> "$GITHUB_OUTPUT" | |
| else | |
| cog changelog > CHANGELOG.md | |
| git add CHANGELOG.md | |
| git commit -m "docs: update changelog for ${AFTER}" | |
| git push origin main | |
| git push origin "refs/tags/${AFTER}" | |
| echo "version=$AFTER" >> "$GITHUB_OUTPUT" | |
| echo "bumped=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "bumped=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Package mod | |
| if: steps.version.outputs.bumped == 'true' | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist/KeyzAllowUtils | |
| cp -r About dist/KeyzAllowUtils/ | |
| cp -r Common dist/KeyzAllowUtils/ | |
| cp -r Compatibility dist/KeyzAllowUtils/ | |
| cp -r 1.6 dist/KeyzAllowUtils/ | |
| rm -rf dist/KeyzAllowUtils/1.6/Source | |
| cp loadFolders.xml LICENSE dist/KeyzAllowUtils/ | |
| cd dist | |
| zip -r "../KeyzAllowUtils-${VERSION}.zip" KeyzAllowUtils/ | |
| - name: Generate release notes | |
| if: steps.version.outputs.bumped == 'true' | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| cog changelog --at "$VERSION" > release-notes.md | |
| - name: Create GitHub Release | |
| if: steps.version.outputs.bumped == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| set -euo pipefail | |
| gh release create "$VERSION" \ | |
| --title "KeyzAllowUtils $VERSION" \ | |
| --notes-file release-notes.md \ | |
| "KeyzAllowUtils-${VERSION}.zip#KeyzAllowUtils Mod Package" |