Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions .github/actions/compatibility-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: 'Compatibility Check'
description: 'Check for breaking changes against the original Legally-Distinct-Missile repository'

inputs:
original-repo:
description: 'Original repository to compare against'
required: false
default: 'SmartlyDressedGames/Legally-Distinct-Missile'
original-branch:
description: 'Branch of original repository to compare against'
required: false
default: 'master'
runtime-version:
description: 'Runtime version for build paths'
required: false
default: 'linux-x64'
fail-on-breaking-changes:
description: 'Whether to fail the workflow if breaking changes are detected'
required: false
default: 'true'

outputs:
has-breaking-changes:
description: 'Whether breaking changes were detected'
value: ${{ steps.check.outputs.has-breaking-changes }}
compatibility-report:
description: 'Path to the compatibility report'
value: ${{ steps.check.outputs.report-path }}

runs:
using: 'composite'
steps:
- name: Checkout original repository
uses: actions/checkout@v5
with:
repository: ${{ inputs.original-repo }}
ref: ${{ inputs.original-branch }}
path: original-repo
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: Build original repo's Rocket.API
run: |
cd original-repo
dotnet build Rocket/Rocket.API/Rocket.API.csproj --configuration Release --verbosity minimal
shell: bash

- name: Build original repo's Rocket.Core
run: |
cd original-repo
dotnet build Rocket/Rocket.Core/Rocket.Core.csproj --configuration Release --verbosity minimal
shell: bash

- name: Build original repo's Rocket.Unturned
run: |
cd original-repo
dotnet build Rocket.Unturned/Rocket.Unturned.csproj --configuration Release --verbosity minimal
shell: bash

- name: Install API compatibility tools
shell: bash
run: |
dotnet tool install --global Microsoft.DotNet.ApiCompat.Tool

- name: Run compatibility checks
id: check
shell: bash
run: |
# Create reports directory
mkdir -p compatibility-reports

# Check Rocket.API compatibility
apicompat \
--left ./original-repo/Rocket/Rocket.API/bin/Release/Rocket.API.dll \
--right ./Rocket/Rocket.API/bin/Release/net461/${{ inputs.runtime-version }}/Rocket.API.dll \
> ./compatibility-reports/api-compat-report.txt 2>&1 || true

# Check Rocket.Core compatibility
apicompat \
--left ./original-repo/Rocket/Rocket.Core/bin/Release/Rocket.Core.dll \
--right ./Rocket/Rocket.Core/bin/Release/net461/${{ inputs.runtime-version }}/Rocket.Core.dll \
> ./compatibility-reports/core-compat-report.txt 2>&1 || true

# Check Rocket.Unturned compatibility
apicompat \
--left ./original-repo/Rocket.Unturned/bin/Release/Rocket.Unturned.dll \
--right ./Rocket.Unturned/bin/Release/net461/${{ inputs.runtime-version }}/Rocket.Unturned.dll \
> ./compatibility-reports/unturned-compat-report.txt 2>&1 || true

# Check for breaking changes
has_breaking_changes=false

for report in ./compatibility-reports/*.txt; do
if grep -q "Breaking Changes\|Error" "$report"; then
has_breaking_changes=true
break
fi
done

echo "has-breaking-changes=$has_breaking_changes" >> $GITHUB_OUTPUT
echo "report-path=./compatibility-reports" >> $GITHUB_OUTPUT

# Create summary report
cat > ./compatibility-reports/summary.md << EOF
# Compatibility Check Summary

## Results
- **Breaking Changes Detected**: $has_breaking_changes
- **Check Date**: $(date -u)
- **Original Repository**: ${{ inputs.original-repo }}
- **Original Branch**: ${{ inputs.original-branch }}

## Detailed Reports
- [API Compatibility](./api-compat-report.txt)
- [Core Compatibility](./core-compat-report.txt)
- [Unturned Compatibility](./unturned-compat-report.txt)

## Recommendations
EOF

if [ "$has_breaking_changes" = "true" ]; then
cat >> ./compatibility-reports/summary.md << EOF

⚠️ **BREAKING CHANGES DETECTED**

Your changes may break existing plugins. Please review the detailed reports above.
Consider:
1. Reverting breaking changes if possible
2. Adding compatibility layers
3. Documenting migration steps for plugin developers
EOF
else
cat >> ./compatibility-reports/summary.md << EOF

✅ **No breaking changes detected**

Your changes appear to be compatible with the original repository.
Existing plugins should continue to work without modification.
EOF
fi

- name: Upload compatibility reports
uses: actions/upload-artifact@v4
with:
name: compatibility-reports
path: ./compatibility-reports

- name: Comment on PR if breaking changes detected
if: github.event_name == 'pull_request' && steps.check.outputs.has-breaking-changes == 'true'
uses: actions/github-script@v7
with:
script: |
const workflowRunId = context.runId;
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;

const comment = `❌ **Breaking changes detected**

Your changes may break existing plugins. Check the [compatibility reports](https://github.com/${repoOwner}/${repoName}/actions/runs/${workflowRunId}/artifacts) for details.

### Detailed Reports
- [API Compatibility Report](./api-compat-report.txt)
- [Core Compatibility Report](./core-compat-report.txt)
- [Unturned Compatibility Report](./unturned-compat-report.txt)
`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});

- name: Fail on breaking changes
if: inputs.fail-on-breaking-changes == 'true' && steps.check.outputs.has-breaking-changes == 'true'
shell: bash
run: |
echo "❌ Breaking changes detected! Check the compatibility reports for details."
exit 1
96 changes: 96 additions & 0 deletions .github/actions/project-build-windows/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: 'Project Build Windows'
description: 'Builds RocketModFix projects on Windows runners (for .NET Framework compatibility)'
inputs:
project_path:
description: 'Path to project folder'
required: true
runtime_version:
description: 'Build runtime version default win-x64'
required: false
default: 'win-x64'
nuget_push:
description: 'Push to Nuget on release?'
required: false
default: false
nuget_key:
description: 'NuGet deploy key'
required: false
github_token:
description: 'GitHub token'
required: false
outputs:
version:
description: "Generated version (SemVersion compatible)"
value: ${{ steps.get-version.outputs.version }}
is_prerelease:
description: 'Gets if the version is a prerelease'
value: ${{ steps.check-prerelease.outputs.is_prerelease }}
runs:
using: "composite"
steps:
# Generate semver compatible version from current tag and commit hash
- name: Create version
id: get-version
run: echo "version=$(git describe --tags `git rev-list --tags --max-count=1`)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
shell: bash

- name: Check Prerelease
id: check-prerelease
run: "if ${{ contains(steps.get-version.outputs.version, '-') }}; then
echo is_prerelease=true >> $GITHUB_OUTPUT;
else
echo is_prerelease=false >> $GITHUB_OUTPUT;
fi"
shell: bash

# Commands that are used multiple times.
# Placed in one place to make sure that the arguments would always be the same
- name: Common commands
id: common-commands
run: |
echo "dotnet-restore=dotnet restore \$PROJECT_PATH --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore -p:RocketModFixVersion=${{ steps.get-version.outputs.version }} --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build --runtime ${{ inputs.runtime_version }}" >> $GITHUB_OUTPUT
shell: bash

# Install dependencies (this needs to be a separate step from build for caching)
- name: Install dependencies
run: |
${{ steps.common-commands.outputs.dotnet-restore }}
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-restore }}'
env:
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
shell: bash

# Build project
- name: Build
run: |
${{ steps.common-commands.outputs.dotnet-build }}
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-build }}'
env:
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
shell: bash

# Test project
- name: Test
run: |
pwsh -File .github/actions/project-build/run-command-for-every-tests-project.ps1 "$PROJECT_PATH" '${{ steps.common-commands.outputs.dotnet-test }}'
env:
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
shell: bash

# Push to GitHub packages on each commit and release
- name: Push to NuGet (Nightly)
if: |
inputs.nuget_push == 'true' && (github.event_name == 'push' ||
github.event_name == 'create' && github.event.ref_type == 'tag')
run: dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.github_token }} --skip-duplicate --source https://nuget.pkg.github.com/RocketModFix/index.json;
shell: bash

# Push to NuGet on each tag, but only if the tag is not a pre-release version
- name: Push to NuGet (Release)
if: |
inputs.nuget_push == 'true' && steps.check-prerelease.outputs.is_prerelease == 'false' &&
github.event_name == 'create' && github.event.ref_type == 'tag'
run: dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.nuget_key }} --skip-duplicate --source https://api.nuget.org/v3/index.json;
shell: bash
24 changes: 24 additions & 0 deletions .github/actions/project-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ outputs:
runs:
using: "composite"
steps:
# Install .NET Framework reference assemblies for .NET Framework 4.8
- name: Install .NET Framework Reference Assemblies
run: |
# Download and install .NET Framework 4.8 reference assemblies from official source
mkdir -p /tmp/net48-refs
curl -L -o /tmp/net48.zip "https://api.nuget.org/v3-flatcontainer/microsoft.netframework.referenceassemblies/1.0.3/microsoft.netframework.referenceassemblies.1.0.3.nupkg"
unzip -q /tmp/net48.zip -d /tmp/net48-refs/

# Create the target directory
mkdir -p /usr/share/dotnet/reference-assemblies/microsoft/framework/.netframework/v4.8

# Copy reference assemblies to the expected location
if [ -d "/tmp/net48-refs/build/.NETFramework/v4.8" ]; then
cp -r /tmp/net48-refs/build/.NETFramework/v4.8/* /usr/share/dotnet/reference-assemblies/microsoft/framework/.netframework/v4.8/
elif [ -d "/tmp/net48-refs/ref/net48" ]; then
cp -r /tmp/net48-refs/ref/net48/* /usr/share/dotnet/reference-assemblies/microsoft/framework/.netframework/v4.8/
fi

# Clean up
rm -rf /tmp/net48-refs /tmp/net48.zip
shell: bash

# Generate semver compatible version from current tag and commit hash
- name: Create version
id: get-version
Expand Down Expand Up @@ -71,6 +93,8 @@ runs:
PROJECT_PATH: ${{ inputs.project_path }} # Used by commands in `common-commands` step
shell: bash



# Test project
- name: Test
run: |
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/Rocket.API.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,29 @@ on:
- 'Rocket/Rocket.API/**'

jobs:
Compatibility-Check:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v4
name: Setup .NET
with:
dotnet-version: 8.x

- name: Check compatibility with original repository
uses: ./.github/actions/compatibility-check
with:
fail-on-breaking-changes: true

build:
name: "Rocket.API Build"
runs-on: ubuntu-latest
needs: Compatibility-Check

steps:
- uses: actions/checkout@v5
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/Rocket.Core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,29 @@ on:
- 'Rocket/Rocket.Core/**'

jobs:
Compatibility-Check:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v4
name: Setup .NET
with:
dotnet-version: 8.x

- name: Check compatibility with original repository
uses: ./.github/actions/compatibility-check
with:
fail-on-breaking-changes: true

build:
name: "Rocket.Core Build"
runs-on: ubuntu-latest
needs: Compatibility-Check

steps:
- uses: actions/checkout@v5
Expand Down
Loading
Loading