-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bedb2f
commit 1dee95d
Showing
108 changed files
with
749 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
root = true | ||
|
||
[*] | ||
trim_trailing_whitespace = true | ||
csharp_using_directive_placement = outside_namespace:silent | ||
csharp_style_namespace_declarations = file_scoped:silent | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.{proj,csproj,vbproj,props,targets,resx,vsixmanifest}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.cs] | ||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0290 | ||
csharp_style_prefer_primary_constructors = false | ||
dotnet_diagnostic.IDE0290.severity = none | ||
|
||
# https://www.jetbrains.com/help/rider/ConvertToPrimaryConstructor.html | ||
resharper_convert_to_primary_constructor_highlighting = none |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'NuGet Pack' | ||
description: 'Packs RocketModFix NuGet packages' | ||
inputs: | ||
nuspec_path: | ||
description: 'Path to .nuspec' | ||
required: true | ||
nuget_push: | ||
description: 'Push to Nuget?' | ||
required: false | ||
default: false | ||
nuget_key: | ||
description: 'NuGet deploy key' | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Pack | ||
run: nuget pack ${{ inputs.nuspec_path }} | ||
shell: bash | ||
- name: Push to NuGet (Release) | ||
run: if ${{ inputs.nuget_push == 'true' }}; then | ||
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{ inputs.nuget_key }} --source https://api.nuget.org/v3/index.json; | ||
fi | ||
shell: bash |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: 'Project Build' | ||
description: 'Builds FixLibrary project' | ||
inputs: | ||
project_path: | ||
description: 'Path to project folder' | ||
required: true | ||
runtime_version: | ||
description: 'Build runtime version default linux-x64' | ||
required: false | ||
default: 'linux-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:FixLibraryVersion=${{ 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/UnturnedCommunity/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 |
26 changes: 26 additions & 0 deletions
26
.github/actions/project-build/run-command-for-every-tests-project.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Finds all tests projects for a project passed as the first argument | ||
# and runs a command passed as the second argument for every tests project found. | ||
# Also sets PROJECT_PATH environment variables with value of the tests project folder path. | ||
# | ||
# Example usage: | ||
# pwsh -f .github/actions/project-build/run-command-for-every-tests-project.ps1 "framework/OpenMod.Core" "echo \$PROJECT_PATH" | ||
# | ||
# Example output: | ||
# Tests project found: framework/OpenMod.Core/../tests/OpenMod.Core.Tests. Executing a command: echo $PROJECT_PATH | ||
# framework/OpenMod.Core/../tests/OpenMod.Core.Tests | ||
|
||
$projectPath = $args[0] | ||
$projectName = Split-Path -Path $projectPath -Leaf | ||
$testsFolderPath = Join-Path -Path $projectPath -ChildPath "../tests" | ||
|
||
$commandToExecute = $args[1] | ||
|
||
Get-ChildItem -Path $testsFolderPath -Directory -Recurse ` | ||
| Where-Object { $_.Name -match "^$projectName.*Tests$" } ` | ||
| ForEach-Object { | ||
$testsProjectName = $_.Name | ||
$testsProjectPath = Join-Path -Path $testsFolderPath -ChildPath $testsProjectName | ||
Write-Output "Tests project found: $testsProjectPath. Executing a command: $commandToExecute" | ||
bash -c "PROJECT_PATH=$testsProjectPath && $commandToExecute" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: FixLibrary | ||
|
||
on: | ||
create: | ||
tags: | ||
- "*" | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- '.github/workflows/FixLibrary.yml' | ||
- 'Module.cs' | ||
- 'Module/RuntimeLibs/**' | ||
- 'FixLibrary.csproj' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/FixLibrary.yml' | ||
- 'Module.cs' | ||
- 'Module/RuntimeLibs/**' | ||
- 'FixLibrary.csproj' | ||
|
||
jobs: | ||
Build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-dotnet@v4 | ||
name: Setup .NET | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- name: Install zip | ||
run: sudo apt-get install zip | ||
|
||
- name: Build FixLibrary.Module | ||
uses: ./.github/actions/project-build | ||
id: fixlibrary-module-build | ||
with: | ||
project_path: '.' # Use current directory for the project | ||
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }} | ||
nuget_push: false | ||
github_token: ${{ secrets.PAT }} | ||
|
||
- name: Zip FixLibrary artifacts | ||
run: "cd bin/Release/net461/linux-x64/FixLibrary && zip -qq -r ./FixLibrary.Module.zip *" | ||
|
||
- name: Upload FixLibrary | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: FixLibrary.Module.zip | ||
path: "bin/Release/net461/linux-x64/FixLibrary/FixLibrary.Module.zip" | ||
if-no-files-found: error | ||
|
||
- name: Create Release | ||
if: github.event_name == 'create' && github.event.ref_type == 'tag' | ||
uses: ncipollo/[email protected] | ||
with: | ||
name: FixLibrary Release v${{ steps.auto-installer-build.outputs.version }} | ||
tag: ${{ steps.auto-installer-build.outputs.version }} | ||
artifacts: bin/Release/net461/linux-x64/FixLibrary/FixLibrary.Module.zip | ||
token: ${{ secrets.PAT }} | ||
prerelease: ${{ steps.auto-installer-build.outputs.is_prerelease }} | ||
allowUpdates: true | ||
draft: true |
Oops, something went wrong.