Skip to content

Commit

Permalink
Merge pull request #21 from YumeChan-DT/develop
Browse files Browse the repository at this point in the history
4.0-beta : Update to .NET 8, support for docs, support for more plugin info
  • Loading branch information
SakuraIsayeki authored Sep 8, 2024
2 parents a3bb9c6 + 987193e commit 478a497
Show file tree
Hide file tree
Showing 31 changed files with 681 additions and 401 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"nbgv": {
"version": "3.5.113",
"commands": [
"nbgv"
]
}
}
}
21 changes: 21 additions & 0 deletions .github/workflows/build-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
push:
pull_request:

jobs:
build-test:
name: Build and Test
uses: ./.github/workflows/build.yml
with:
project-path: ${{ matrix.project.path }}
artifact-name: ${{ matrix.project.name }}

strategy:
fail-fast: false
matrix:
# Projects to publish
project: [
{ name: "Base", path: "YumeChan.PluginBase/YumeChan.PluginBase.csproj" },
{ name: "Database.MongoDB", path: "YumeChan.PluginBase.Database.MongoDB/YumeChan.PluginBase.Database.MongoDB.csproj" },
{ name: "Database.Postgres", path: "YumeChan.PluginBase.Database.Postgres/YumeChan.PluginBase.Database.Postgres.csproj" },
]
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: .NET Build & Test Project

on:
workflow_call:
inputs:
project-path:
description: 'Path to the project to build'
required: true
type: string

artifact-name:
description: 'Name of the artifact to upload'
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

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

- uses: dotnet/[email protected]
id: nbgv

- name: Restore dependencies
run: dotnet restore ${{ inputs.project-path }}

- name: Build Debug
run: dotnet build -c debug --no-restore ${{ inputs.project-path }}

- name: Test
run: dotnet test --no-build --verbosity normal --logger "GitHubActions;report-warnings=true" ${{ inputs.project-path }}

- name: .NET Build Release & Pack
run: dotnet build -c release -o "publish" ${{ inputs.project-path }}

- name: Upload .NET build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: "publish"

25 changes: 0 additions & 25 deletions .github/workflows/dotnet.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/publish-artifact.yml

This file was deleted.

148 changes: 70 additions & 78 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,93 @@ name: Publish NuGet packages
# Controls when the action will run.
on:
push:
branches: [ master ]
branches:
- master

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
YumeChan_PluginsLocation: build

jobs:
publish-nuget:
name: Build, pack, & publish to NuGet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

# Publish
- name: Publish to NuGet
id: publish_nuget
uses: Rebel028/[email protected]
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: YumeChan.PluginBase.csproj

# NuGet package id, used for version detection & defaults to project name
# PACKAGE_NAME: Core

# Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH
# VERSION_FILE_PATH: Directory.Build.props

# Regex pattern to extract version info in a capturing group
# VERSION_REGEX: ^\s*<Version>(.*)<\/Version>\s*$

# Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX
# VERSION_STATIC: 1.0.0
build-test:
name: Build and Test
strategy:
fail-fast: true
matrix:
# Projects to publish
project: [
{ name: "Base", path: "YumeChan.PluginBase/YumeChan.PluginBase.csproj" },
{ name: "Database.MongoDB", path: "YumeChan.PluginBase.Database.MongoDB/YumeChan.PluginBase.Database.MongoDB.csproj" },
{ name: "Database.Postgres", path: "YumeChan.PluginBase.Database.Postgres/YumeChan.PluginBase.Database.Postgres.csproj" },
]
uses: ./.github/workflows/build.yml
with:
project-path: ${{ matrix.project.path }}

# Flag to toggle git tagging, enabled by default
TAG_COMMIT: true

# Format of the git tag, [*] gets replaced with actual version
TAG_FORMAT: v*

# API key to authenticate with NuGet server
NUGET_KEY: ${{ secrets.NUGET_TOKEN }}

# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org

# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
# INCLUDE_SYMBOLS: false

publish-ghpackages:
name: Build, pack, & publish to GitHub Packages
publish-nuget:
name: Publish NuGet package
runs-on: ubuntu-latest
needs:
- build-test

strategy:
fail-fast: false
matrix:
# Projects to publish
project: [
{ name: "Base", path: "YumeChan.PluginBase/YumeChan.PluginBase.csproj" },
{ name: "Database.MongoDB", path: "YumeChan.PluginBase.Database.MongoDB/YumeChan.PluginBase.Database.MongoDB.csproj" },
{ name: "Database.Postgres", path: "YumeChan.PluginBase.Database.Postgres/YumeChan.PluginBase.Database.Postgres.csproj" },
]
# Sources to publish to
nuget: [
{ name: "NuGet", source: "https://api.nuget.org", keyname: "NUGET_TOKEN" },
{ name: "GitHub Packages", source: "https://nuget.pkg.github.com/YumeChan", keyname: "GITHUB_TOKEN" }
]

steps:
- uses: actions/checkout@v2

- name: Setup dotnet
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
with:
dotnet-version: 6.0.x
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- name: Publish to GH Packages
id: publish_ghpackages
uses: Rebel028/[email protected]
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: YumeChan.PluginBase.csproj

# NuGet package id, used for version detection & defaults to project name
# PACKAGE_NAME: Core

# Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH
# VERSION_FILE_PATH: Directory.Build.props
dotnet-version: 8.0

# Regex pattern to extract version info in a capturing group
# VERSION_REGEX: ^\s*<Version>(.*)<\/Version>\s*$

# Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX
# VERSION_STATIC: 1.0.0
- name: Setup NuGet CLI
uses: NuGet/setup-nuget@v2

# Flag to toggle git tagging, enabled by default
TAG_COMMIT: false
- uses: dotnet/[email protected]
id: nbgv

# Format of the git tag, [*] gets replaced with actual version
# TAG_FORMAT: v*
- name: Restore dependencies
run: dotnet restore ${{ matrix.project.path }}

# API key to authenticate with NuGet server
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: dotnet build -c release ${{ matrix.project.path }}

# NuGet server uri hosting the packages, defaults to https://api.nuget.org
NUGET_SOURCE: https://nuget.pkg.github.com/YumeChan-DT
- name: Package
run: dotnet pack -c Release --no-build --include-symbols ${{ matrix.project.path }}

# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
# INCLUDE_SYMBOLS: false
- name: Attest build provenance for .(s)nupkgs
uses: actions/attest-build-provenance@v1
# Only once per package: take nuget provider
if: matrix.nuget.name == 'NuGet'
with:
subject-path: "${{ env.YumeChan_PluginsLocation }}/**/*.nupkg"
#subject-path: "**/Release/*nupkg"

# GITHUB_USER: ${{ GITHUB_ACTOR }}
# Publish
- name: Publish packages to ${{ matrix.nuget.name }}
run: |
dotnet nuget push "${{ env.YumeChan_PluginsLocation }}/**/*.nupkg" \
--source "${{ matrix.nuget.source }}" \
--symbol-source "${{ matrix.nuget.source }}" \
--api-key "${{ secrets[matrix.nuget.keyname] }}" \
--symbol-api-key "${{ secrets[matrix.nuget.keyname] }}" \
--skip-duplicate
30 changes: 0 additions & 30 deletions DependencyInjectionHandler.cs

This file was deleted.

33 changes: 33 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<Company>Nodsoft Systems</Company>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/YumeChan-DT/YumeChan-PluginBase</RepositoryUrl>
<RepositoryType>git</RepositoryType>

<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>icon.png</PackageIcon>
<CommonPackageTags>yumechan, plugin, spec, discord, bot, dsharpplus</CommonPackageTags>
<PackageTags>$(CommonPackageTags)</PackageTags> <!-- Default package tags -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" Condition="!Exists('packages.config')" PrivateAssets="all">
</PackageReference>
</ItemGroup>

<ItemGroup Condition="$(PackAsTool) != 'true'">
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.4" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup Label="PackageInfoFiles">
<!-- Import the Readme at build props level if there is none in the project -->
<None Condition="!Exists('README.md')" Include="$(_DirectoryBuildPropsBasePath)\README.md" Pack="true" PackagePath="/" />
<None Include="$(MSBuildThisFileDirectory)\LICENSE" Pack="true" PackagePath="/" />
<None Include="$(MSBuildThisFileDirectory)\icon.png" Pack="true" PackagePath="/" />
</ItemGroup>
</Project>
Loading

0 comments on commit 478a497

Please sign in to comment.