12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Expand Up @@ -7,6 +7,18 @@
"commands": [
"tcli"
]
},
"husky": {
"version": "0.6.4",
"commands": [
"husky"
]
},
"minver-cli": {
"version": "4.3.0",
"commands": [
"minver"
]
}
}
}
7 changes: 5 additions & 2 deletions .editorconfig
@@ -1,5 +1,6 @@
root = true

# noinspection EditorConfigKeyCorrectness
[*.cs]
indent_size = 4
indent_style = space
Expand All @@ -11,10 +12,12 @@ insert_final_newline = true
dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1309.severity = none

# noinspection EditorConfigKeyCorrectness
[**/Patch/**.cs]
dotnet_diagnostic.SA1313.severity = none
dotnet_diagnostic.SA1600.severity = none

[{MyPluginInfo.cs,IgnoresAccessChecksToAttribute.cs}]
dotnet_diagnostic.SA1633.severity = none
# noinspection EditorConfigKeyCorrectness
[MyPluginInfo.cs]
dotnet_diagnostic.CS1591.severity = none
generated_code = true
38 changes: 25 additions & 13 deletions .github/workflows/build.yml
Expand Up @@ -11,18 +11,30 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- uses: actions/checkout@v4

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

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

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

- uses: actions/upload-artifact@v3
name: Upload Artifacts
with:
if-no-files-found: error
name: ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}.zip
path: "${{ github.workspace }}/**/bin/**/*.dll"
34 changes: 34 additions & 0 deletions .github/workflows/changelog.yml
@@ -0,0 +1,34 @@
name: "Changelog"

on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# updated CHANGELOG back to the repository.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.tag_name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
73 changes: 22 additions & 51 deletions .github/workflows/publish.yml
Expand Up @@ -2,7 +2,7 @@

on:
release:
types: [ released, prereleased ]
types: [ released ]

jobs:
build:
Expand Down Expand Up @@ -30,6 +30,9 @@ jobs:
run: |
dotnet pack --configuration Release
- name: Calculate Version
run: echo "PACKAGE_VERSION=$( dotnet minver --tag-prefix v --verbosity error | tail -1 | sed 's/v//' )" >> $GITHUB_ENV

- name: Upload Thunderstore Artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -40,65 +43,33 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: nupkg-build
path: ContentSettings/bin/Release/*.nupkg

upload-release-artifacts:
needs: build
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4

- name: Download all Artifacts
uses: actions/download-artifact@v4

- name: Upload artifacts to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} thunderstore-build/*.zip nupkg-build/*.nupkg

deploy-nuget:
name: Deploy to NuGet
needs: build
runs-on: ubuntu-latest
steps:
- name: Fetch Sources
uses: actions/checkout@v4

- name: Download nupkg artifact
uses: actions/download-artifact@v4
with:
name: nupkg-build
path: ./ContentSettings/bin/Release
path: "${{ github.workspace }}/**/bin/Release/*.nupkg"

- name: Setup .NET environment
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.100"
- name: Publishing to Thunderstore
env:
TCLI_AUTH_TOKEN: ${{ secrets.THUNDERSTORE_API_TOKEN }}
if: ${{ env.TCLI_AUTH_TOKEN != '' }}
run: |
dotnet tcli publish --config-path assets/thunderstore.toml --package-version ${{ env.PACKAGE_VERSION }}
- name: Publish to NuGet.org
env:
NUGET_API_TOKEN: ${{ secrets.NUGET_API_TOKEN }}
if: ${{ env.NUGET_API_TOKEN != '' }}
run: |
dotnet nuget push ./ContentSettings/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }} --source https://api.nuget.org/v3/index.json
dotnet nuget push ${{ github.workspace }}/**/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_TOKEN }} --source https://api.nuget.org/v3/index.json
deploy-thunderstore:
if: ${{ github.event.release.prerelease == false }}
upload-release-artifacts:
needs: build
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: Download Thunderstore Artifact

- name: Download all Artifacts
uses: actions/download-artifact@v4
with:
name: thunderstore-build
path: ./dist

- name: Restore Tools
run: |
dotnet tool restore

- name: Publishing to Thunderstore
- name: Upload artifacts to Release
env:
TCLI_AUTH_TOKEN: ${{ secrets.THUNDERSTORE_API_TOKEN }}
run: |
dotnet tcli publish --config-path assets/thunderstore.toml --file dist/*.zip
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} thunderstore-build/*.zip nupkg-build/*.nupkg
22 changes: 22 additions & 0 deletions .github/workflows/pull-request.yml
@@ -0,0 +1,22 @@
name: Validate PR Title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: true
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -363,3 +363,4 @@ MigrationBackup/
FodyWeavers.xsd

.idea/
dist/
7 changes: 7 additions & 0 deletions .husky/commit-msg
@@ -0,0 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

dotnet husky run --name "commit-message-linter" --args "$1"
echo
echo Great work! 🥂
echo
16 changes: 16 additions & 0 deletions .husky/csx/commit-lint.csx
@@ -0,0 +1,16 @@
using System.Text.RegularExpressions;

private var pattern = @"^(?=.{1,90}$)(?:build|feat|ci|chore|docs|fix|perf|refactor|revert|style|test|wip)(?:\(.+\))*(?::).{4,}(?:#\d+)*(?<![\.\s])$";
private var msg = File.ReadAllLines(Args[0])[0];

if (Regex.IsMatch(msg, pattern))
return 0;

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Invalid commit message");
Console.ResetColor();
Console.WriteLine("e.g: 'feat(scope): subject' or 'fix: subject'");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("more info: https://www.conventionalcommits.org/en/v1.0.0/");

return 1;
22 changes: 22 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,22 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

## husky task runner examples -------------------
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'

## run all tasks
#husky run

### run all tasks with group: 'group-name'
#husky run --group group-name

## run task with name: 'task-name'
#husky run --name task-name

## pass hook arguments to task
#husky run --args "$1" "$2"

## or put your custom commands -------------------
#echo 'Husky.Net is awesome!'

dotnet husky run --group pre-commit
22 changes: 22 additions & 0 deletions .husky/task-runner.json
@@ -0,0 +1,22 @@
{
"tasks": [
{
"name": "commit-message-linter",
"command": "dotnet",
"args": [
"husky",
"exec",
".husky/csx/commit-lint.csx",
"--args",
"${args}"
]
},
{
"name": "dotnet-format",
"group": "pre-commit",
"command": "dotnet",
"args": ["format", "--include", "${staged}"],
"include": ["**/*.cs"]
}
]
}
22 changes: 20 additions & 2 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Unreleased](https://github.com/Commander-Cat101/ContentSettings/compare/v1.0.2...HEAD)

[unreleased]: https://github.com/Commander-Cat101/ContentSettings/compare/v1.0.0...HEAD
## [v1.0.2](https://github.com/Commander-Cat101/ContentSettings/compare/v1.0.1...v1.0.2) - 2024-04-12

## [v1.0.1](https://github.com/Commander-Cat101/ContentSettings/compare/v1.0.0...v1.0.1) - 2024-04-05

### Fixed

- Fixed release on Thunderstore.

## [v1.0.0](https://github.com/Commander-Cat101/ContentSettings/compare/v0.0.1...v1.0.0) - 2024-04-04

### Fixed

- Fixed an issue with access rights due to the use of non-publicized DLLs.

## [v0.0.1](https://github.com/Commander-Cat101/ContentSettings/releases/tag/v0.0.1) - 2024-04-03

### Added

- Initial release of ContentSettings.
4 changes: 2 additions & 2 deletions ContentSettings/ContentSettings.cs
Expand Up @@ -11,9 +11,9 @@ namespace ContentSettings;
using HarmonyLib;

/// <summary>
/// The main Content Settings plugin class
/// The main Content Settings plugin class.
/// </summary>
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class ContentSettings : BaseUnityPlugin
{
private Harmony Harmony { get; } = new (MyPluginInfo.PLUGIN_GUID);
Expand Down