Skip to content

Commit

Permalink
Merge pull request #31 from RocketModFix/dev
Browse files Browse the repository at this point in the history
Bump new version v4.15.0
  • Loading branch information
sunnamed434 committed Nov 3, 2023
2 parents 206913b + 85c3c4b commit b069441
Show file tree
Hide file tree
Showing 60 changed files with 747 additions and 948 deletions.
15 changes: 11 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
trim_trailing_whitespace = true
csharp_using_directive_placement = outside_namespace:silent
csharp_style_namespace_declarations = file_scoped:silent
indent_style = tab
insert_final_newline = true

# Match style of legacy RocketMod code
[*.cs]
indent_style = space
indent_size = 4
insert_final_newline = false

[*.yml]
indent_size = 2
indent_style = space

[*.{proj,csproj,vbproj,props,targets,resx,vsixmanifest}]
indent_size = 2
indent_style = space
24 changes: 24 additions & 0 deletions .github/actions/nuget-pack/action.yaml
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
90 changes: 90 additions & 0 deletions .github/actions/project-build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: 'Project Build'
description: 'Builds RocketModFix projects'
inputs:
project_path:
description: 'Path to project folder'
required: true
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" >> $GITHUB_OUTPUT
echo "dotnet-build=dotnet build \$PROJECT_PATH --configuration Release --no-restore -p:Version=${{ steps.get-version.outputs.version }} -p:PackageVersion=${{ steps.get-version.outputs.version }} -p:InformationalVersion=${{ steps.get-version.outputs.version }}" >> $GITHUB_OUTPUT
echo "dotnet-test=dotnet test \$PROJECT_PATH --configuration Release --no-restore --no-build" >> $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)
run: if ${{ inputs.nuget_push == 'true' && (github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag')) }}; then
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;
fi
shell: bash

# Push to NuGet on each tag, but only if the tag is not a pre-release version
- name: Push to NuGet (Release)
run: if ${{ inputs.nuget_push == 'true' && github.event_name == 'create' && github.event.ref_type == 'tag' && steps.check-prerelease.outputs.is_prerelease == 'false' }}; then
dotnet nuget push ${{ inputs.project_path }}/bin/Release/*.nupkg --api-key ${{ inputs.nuget_key }} --skip-duplicate --source https://api.nuget.org/v3/index.json;
fi
shell: bash
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"
}
39 changes: 39 additions & 0 deletions .github/workflows/Rocket.API.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: NuGet Package for Rocket.API

on:
create:
tags:
- "*"
push:
branches: [ master ]
paths:
- '.github/workflows/Rocket.API.yaml'
- 'Rocket/Rocket.API/**'
pull_request:
branches: [ master ]
paths:
- '.github/workflows/Rocket.API.yaml'
- 'Rocket/Rocket.API/**'

jobs:
build:
name: "Rocket.API Build"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v3
name: Setup .NET
with:
dotnet-version: 7.x

- uses: ./.github/actions/project-build
id: project-build
with:
project_path: Rocket/Rocket.API
github_token: ${{ secrets.PAT }}
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }}
nuget_push: true
39 changes: 39 additions & 0 deletions .github/workflows/Rocket.Core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: NuGet Package for Rocket.Core

on:
create:
tags:
- "*"
push:
branches: [ master ]
paths:
- '.github/workflows/Rocket.Core.yaml'
- 'Rocket/Rocket.Core/**'
pull_request:
branches: [ master ]
paths:
- '.github/workflows/Rocket.Core.yaml'
- 'Rocket/Rocket.Core/**'

jobs:
build:
name: "Rocket.Core Build"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v3
name: Setup .NET
with:
dotnet-version: 7.x

- uses: ./.github/actions/project-build
id: project-build
with:
project_path: Rocket/Rocket.Core
github_token: ${{ secrets.PAT }}
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }}
nuget_push: true
35 changes: 35 additions & 0 deletions .github/workflows/Rocket.Unturned.Module.PR.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Artifacts for the RocketMod.Unturned Module on PR

on:
pull_request:
paths:
- '.github/workflows/Rocket.Unturned.Module.PR.yaml'
- '.github/workflows/Rocket.Unturned.Module.yaml'
- 'Rocket/**'
- 'Rocket.Unturned/**'

jobs:
Build:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-dotnet@v3
name: Setup .NET
with:
dotnet-version: 7.x

- name: Build
run: dotnet build ./Rocket.Unturned/Rocket.Unturned.csproj /p:RocketModVersion=0.0.0-preview /p:CreateRocketModUnturnedModuleArtifacts=true --configuration Release

- run: echo "::set-output name=commit_hash::$(git rev-parse --short ${{ github.sha }})"
id: commit_hash

- name: Upload Rocket.Unturned.Module Artifacts
uses: actions/upload-artifact@v2
with:
name: Rocket.Unturned.Module.Build-${{ steps.commit_hash.outputs.commit_hash }}
path: "./Rocket.Unturned/Rocket.Unturned.Module-v0.0.0-preview.zip"
if-no-files-found: error
53 changes: 53 additions & 0 deletions .github/workflows/Rocket.Unturned.Module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Artifacts for the RocketMod.Unturned Module

on:
create:
tags:
- "*"

jobs:
Build:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-dotnet@v3
name: Setup .NET
with:
dotnet-version: 7.x

- name: Build
run: dotnet build ./Rocket.Unturned/Rocket.Unturned.csproj /p:RocketModVersion=${{ github.ref_name }} /p:CreateRocketModUnturnedModuleArtifacts=true --configuration Release

- name: Upload build
uses: actions/upload-artifact@v2
with:
name: build
path: "./Rocket.Unturned/Rocket.Unturned.Module-v${{ github.ref_name }}.zip"
if-no-files-found: error

Release:
needs: [Build]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download build
uses: actions/download-artifact@v2
with:
name: build
path: ./build/

- name: Create Release & Upload Assets
uses: ncipollo/release-action@v1
with:
name: v${{ github.ref_name }}
tag: v${{ github.ref_name }}
artifacts: "./build/Rocket.Unturned.Module-v${{ github.ref_name }}.zip"
token: ${{secrets.PAT}}
prerelease: false
allowUpdates: true
39 changes: 39 additions & 0 deletions .github/workflows/Rocket.Unturned.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: NuGet Package for Rocket.Unturned

on:
create:
tags:
- "*"
push:
branches: [ master ]
paths:
- '.github/workflows/Rocket.Unturned.yaml'
- 'Rocket.Unturned/**'
pull_request:
branches: [ master ]
paths:
- '.github/workflows/Rocket.Unturned.yaml'
- 'Rocket.Unturned/**'

jobs:
build:
name: "Rocket.Unturned Build"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v3
name: Setup .NET
with:
dotnet-version: 7.x

- uses: ./.github/actions/project-build
id: project-build
with:
project_path: Rocket.Unturned
github_token: ${{ secrets.PAT }}
nuget_key: ${{ secrets.NUGET_DEPLOY_KEY }}
nuget_push: true

0 comments on commit b069441

Please sign in to comment.