From 9a7bd05c286b9c3cf75e17d12621413904befdd3 Mon Sep 17 00:00:00 2001
From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>
Date: Fri, 23 Feb 2024 23:31:04 +0300
Subject: [PATCH] [CI] New build action + Build framework on linux (#2848)
* Create dotnet.yml
* Update dotnet.yml
* Update dotnet.yml
* Update dotnet.yml
* pragma disable some obsolete warnings
* Update dotnet.yml
* Update dotnet.yml
* Update dotnet.yml
* update vars for windows
* cache? dotnet
* oops forgot to save
* add concurrency
* test deploy
* fix?
* disable caching
* Update dotnet.yml
* Update dotnet.yml
* Update dotnet.yml
* ...
* Update dotnet.yml
* it should build now. maybe. probably
* huh?
* huh x2
* disable deploy on PRs / enable cache
* publish test results
* Update dotnet.yml
* remove cache cuz it's useless
* Update dotnet.yml
* push to github packages cuz why not
* add toggle vars for pushes
* Update dotnet.yml
* uncomment release since there's a toggle now
---
.github/workflows/dotnet.yml | 125 ++++++++++++++++++
.../Discord.Net.Commands.csproj | 6 +-
src/Discord.Net.Core/Discord.Net.Core.csproj | 6 +-
.../Discord.Net.DebugTools.csproj | 6 +-
.../Builders/ModuleClassBuilder.cs | 6 +
.../Discord.Net.Interactions.csproj | 6 +-
.../ContextCommands/ContextCommandInfo.cs | 2 +
.../Info/Commands/SlashCommandInfo.cs | 2 +
.../Info/ModuleInfo.cs | 2 +
.../Utilities/ApplicationCommandRestUtil.cs | 2 +
src/Discord.Net.Rest/Discord.Net.Rest.csproj | 6 +-
.../Discord.Net.WebSocket.csproj | 6 +-
12 files changed, 163 insertions(+), 12 deletions(-)
create mode 100644 .github/workflows/dotnet.yml
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
new file mode 100644
index 00000000..ff72ce73
--- /dev/null
+++ b/.github/workflows/dotnet.yml
@@ -0,0 +1,125 @@
+name: Dotnet Build
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+
+on:
+ push:
+ branches: ["dev"]
+ tags: ["*"]
+ paths-ignore:
+ - 'docs/**'
+ pull_request:
+
+jobs:
+ build:
+ name: Build and Test
+ runs-on: ubuntu-latest
+ env:
+ ArtifactStagingDirectory: "artifacts"
+ IsTagBuild: false
+ DOTNET_INSTALL_DIR: "/usr/share/dotnet"
+ Suffix: ${{ github.run_number }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 8.0.x
+
+ - name: Is Tag Build
+ if: startsWith(github.ref, 'refs/tags/')
+ run: echo "IsTagBuild=true" >> $GITHUB_ENV
+
+ - name: Generate Suffix
+ if: env.IsTagBuild != 'true'
+ run: echo "Suffix=$(date +'%Y%m%d')-${{ github.run_number }}" >> $GITHUB_ENV
+
+ - name: Restore
+ run: dotnet restore ./Discord.Net.sln -v minimal
+
+ - name: Build
+ run: dotnet build "Discord.Net.sln" -v minimal -c Release --no-restore /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=$(IsTagBuild)
+
+ - name: Unit Test
+ run: dotnet test "test/Discord.Net.Tests.Unit/Discord.Net.Tests.Unit.csproj" --no-restore --no-build -v minimal -c Release --logger trx
+
+ - name: Analyzer Test
+ run: dotnet test "test/Discord.Net.Analyzers.Tests/Discord.Net.Analyzers.Tests.csproj" --no-restore --no-build -v minimal -c Release --logger trx
+
+ - name: Publish Test Results
+ uses: EnricoMi/publish-unit-test-result-action@v2
+ if: failure() || success()
+ with:
+ files: ./**/*.trx
+
+ - name: Pack
+ env:
+ buildNumber: $Suffix
+ run: |
+ dotnet pack "src\Discord.Net.Core\Discord.Net.Core.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "src\Discord.Net.Rest\Discord.Net.Rest.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "src\Discord.Net.WebSocket\Discord.Net.WebSocket.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "src\Discord.Net.Commands\Discord.Net.Commands.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "src\Discord.Net.Webhook\Discord.Net.Webhook.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "src\Discord.Net.Analyzers\Discord.Net.Analyzers.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "src\Discord.Net.Interactions\Discord.Net.Interactions.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+ dotnet pack "experiment\Discord.Net.BuildOverrides\Discord.Net.BuildOverrides.csproj" --no-restore --no-build -v minimal -c Release -o ${{ env.ArtifactStagingDirectory }} /p:BuildNumber=${{ env.Suffix }} /p:IsTagBuild=${{ env.IsTagBuild }}
+
+ - name: Publish Artifacts
+ uses: actions/upload-artifact@v4
+ with:
+ name: discord-net
+ path: ${{ env.ArtifactStagingDirectory }}/*
+
+ deploy:
+ name: Deploy
+ runs-on: ubuntu-latest
+ needs: [build]
+ if: github.event_name != 'pull_request'
+ env:
+ IsTagBuild: false
+ ArtifactStagingDirectory: "artifacts"
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Is Tag Build
+ if: startsWith(github.ref, 'refs/tags/')
+ run: echo "IsTagBuild=true" >> $GITHUB_ENV
+
+ - name: Generate Suffix
+ run: echo "Suffix=$(date +'%Y%m%d')-${{ github.run_number }}" >> $GITHUB_ENV
+
+ - name: setup NuGet
+ uses: nuget/setup-nuget@v2
+ with:
+ nuget-version: '6.x'
+
+ - name: Download artifacts
+ uses: actions/download-artifact@v4
+ with:
+ name: discord-net
+ path: ${{ env.ArtifactStagingDirectory }}
+
+ - name: Pack Metapackage
+ if: env.IsTagBuild != 'true'
+ run: nuget pack "src/Discord.Net/Discord.Net.nuspec" -OutputDirectory ${{ env.ArtifactStagingDirectory }} -Suffix $Suffix
+
+ - name: Pack Metapackage
+ if: env.IsTagBuild == 'true'
+ run: nuget pack "src/Discord.Net/Discord.Net.nuspec" -OutputDirectory ${{ env.ArtifactStagingDirectory }}
+
+ - name: Push Nightly
+ if: vars.PUSH_NIGHTLY == 'true'
+ run: nuget push ${{ env.ArtifactStagingDirectory }}/*.nupkg -Source ${{ vars.NIGHTLY_FEED }} -ApiKey ${{ secrets.NIGHTLY_FEED_API_KEY }}
+
+ - name: Push Nightly to GitHub Pacakges
+ if: vars.PUSH_NIGHTLY == 'true'
+ env:
+ REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
+ run: nuget push ${{ env.ArtifactStagingDirectory }}/*.nupkg -Source ${{ env.REPOSITORY_URL }} -ApiKey ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Push Release
+ if: env.IsTagBuild == 'true' && vars.PUSH_NUGET == 'true'
+ run: nuget push ${{ env.ArtifactStagingDirectory }}/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
diff --git a/src/Discord.Net.Commands/Discord.Net.Commands.csproj b/src/Discord.Net.Commands/Discord.Net.Commands.csproj
index 4fdecd25..8a888180 100644
--- a/src/Discord.Net.Commands/Discord.Net.Commands.csproj
+++ b/src/Discord.Net.Commands/Discord.Net.Commands.csproj
@@ -5,12 +5,14 @@
Discord.Net.Commands
Discord.Commands
A Discord.Net extension adding support for bot commands.
- net6.0;net5.0;net461;netstandard2.0;netstandard2.1
- net6.0;net5.0;netstandard2.0;netstandard2.1
+ net6.0;net5.0;net461;netstandard2.0;netstandard2.1
5
True
+
+
+
diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj
index 9e9887a2..0ed4a28a 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.csproj
+++ b/src/Discord.Net.Core/Discord.Net.Core.csproj
@@ -5,8 +5,7 @@
Discord.Net.Core
Discord
The core components for the Discord.Net library.
- net6.0;net5.0;net461;netstandard2.0;netstandard2.1
- net6.0;net5.0;netstandard2.0;netstandard2.1
+ net6.0;net5.0;net461;netstandard2.0;netstandard2.1
5
True
@@ -29,4 +28,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj b/src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj
index 8c56a5fb..c2bdaa60 100644
--- a/src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj
+++ b/src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj
@@ -4,10 +4,12 @@
Discord.Net.DebugTools
Discord
A Discord.Net extension adding some helper classes for diagnosing issues.
- net45;netstandard1.3
- netstandard1.3
+ net45;netstandard1.3
+
+
+
diff --git a/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs
index 8d251941..4043e363 100644
--- a/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs
+++ b/src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs
@@ -80,11 +80,13 @@ namespace Discord.Interactions.Builders
builder.Description = group.Description;
}
break;
+#pragma warning disable CS0618 // Type or member is obsolete
case DefaultPermissionAttribute defPermission:
{
builder.DefaultPermission = defPermission.IsDefaultPermission;
}
break;
+#pragma warning restore CS0618 // Type or member is obsolete
case EnabledInDmAttribute enabledInDm:
{
builder.IsEnabledInDm = enabledInDm.IsEnabled;
@@ -177,11 +179,13 @@ namespace Discord.Interactions.Builders
builder.RunMode = command.RunMode;
}
break;
+#pragma warning disable CS0618 // Type or member is obsolete
case DefaultPermissionAttribute defaultPermission:
{
builder.DefaultPermission = defaultPermission.IsDefaultPermission;
}
break;
+#pragma warning restore CS0618 // Type or member is obsolete
case EnabledInDmAttribute enabledInDm:
{
builder.IsEnabledInDm = enabledInDm.IsEnabled;
@@ -232,11 +236,13 @@ namespace Discord.Interactions.Builders
command.CheckMethodDefinition(methodInfo);
}
break;
+#pragma warning disable CS0618 // Type or member is obsolete
case DefaultPermissionAttribute defaultPermission:
{
builder.DefaultPermission = defaultPermission.IsDefaultPermission;
}
break;
+#pragma warning restore CS0618 // Type or member is obsolete
case EnabledInDmAttribute enabledInDm:
{
builder.IsEnabledInDm = enabledInDm.IsEnabled;
diff --git a/src/Discord.Net.Interactions/Discord.Net.Interactions.csproj b/src/Discord.Net.Interactions/Discord.Net.Interactions.csproj
index a3ac3d50..dbb8613b 100644
--- a/src/Discord.Net.Interactions/Discord.Net.Interactions.csproj
+++ b/src/Discord.Net.Interactions/Discord.Net.Interactions.csproj
@@ -2,8 +2,7 @@
- net6.0;net5.0;net461;netstandard2.0;netstandard2.1
- net6.0;net5.0;netstandard2.0;netstandard2.1
+ net6.0;net5.0;net461;netstandard2.0;netstandard2.1
Discord.Interactions
Discord.Net.Interactions
A Discord.Net extension adding support for Application Commands.
@@ -22,5 +21,8 @@
+
+
+
diff --git a/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs
index 2635fe7c..3fd6a08e 100644
--- a/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs
+++ b/src/Discord.Net.Interactions/Info/Commands/ContextCommands/ContextCommandInfo.cs
@@ -39,7 +39,9 @@ namespace Discord.Interactions
: base(builder, module, commandService)
{
CommandType = builder.CommandType;
+#pragma warning disable CS0618 // Type or member is obsolete
DefaultPermission = builder.DefaultPermission;
+#pragma warning restore CS0618 // Type or member is obsolete
IsNsfw = builder.IsNsfw;
IsEnabledInDm = builder.IsEnabledInDm;
DefaultMemberPermissions = builder.DefaultMemberPermissions;
diff --git a/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs
index 02df9883..ad04649e 100644
--- a/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs
+++ b/src/Discord.Net.Interactions/Info/Commands/SlashCommandInfo.cs
@@ -49,7 +49,9 @@ namespace Discord.Interactions
internal SlashCommandInfo(Builders.SlashCommandBuilder builder, ModuleInfo module, InteractionService commandService) : base(builder, module, commandService)
{
Description = builder.Description;
+#pragma warning disable CS0618 // Type or member is obsolete
DefaultPermission = builder.DefaultPermission;
+#pragma warning restore CS0618 // Type or member is obsolete
IsEnabledInDm = builder.IsEnabledInDm;
IsNsfw = builder.IsNsfw;
DefaultMemberPermissions = builder.DefaultMemberPermissions;
diff --git a/src/Discord.Net.Interactions/Info/ModuleInfo.cs b/src/Discord.Net.Interactions/Info/ModuleInfo.cs
index 991da135..f42cdaef 100644
--- a/src/Discord.Net.Interactions/Info/ModuleInfo.cs
+++ b/src/Discord.Net.Interactions/Info/ModuleInfo.cs
@@ -125,7 +125,9 @@ namespace Discord.Interactions
SlashGroupName = builder.SlashGroupName;
Description = builder.Description;
Parent = parent;
+#pragma warning disable CS0618 // Type or member is obsolete
DefaultPermission = builder.DefaultPermission;
+#pragma warning restore CS0618 // Type or member is obsolete
IsNsfw = builder.IsNsfw;
IsEnabledInDm = builder.IsEnabledInDm;
DefaultMemberPermissions = BuildDefaultMemberPermissions(builder);
diff --git a/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs b/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs
index acd67a2a..32784fad 100644
--- a/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs
+++ b/src/Discord.Net.Interactions/Utilities/ApplicationCommandRestUtil.cs
@@ -163,7 +163,9 @@ namespace Discord.Interactions
{
Name = moduleInfo.SlashGroupName,
Description = moduleInfo.Description,
+#pragma warning disable CS0618 // Type or member is obsolete
IsDefaultPermission = moduleInfo.DefaultPermission,
+#pragma warning restore CS0618 // Type or member is obsolete
IsDMEnabled = moduleInfo.IsEnabledInDm,
IsNsfw = moduleInfo.IsNsfw,
DefaultMemberPermissions = moduleInfo.DefaultMemberPermissions
diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.csproj b/src/Discord.Net.Rest/Discord.Net.Rest.csproj
index bec2396e..66643ffa 100644
--- a/src/Discord.Net.Rest/Discord.Net.Rest.csproj
+++ b/src/Discord.Net.Rest/Discord.Net.Rest.csproj
@@ -5,8 +5,7 @@
Discord.Net.Rest
Discord.Rest
A core Discord.Net library containing the REST client and models.
- net6.0;net5.0;net461;netstandard2.0;netstandard2.1
- net6.0;net5.0;netstandard2.0;netstandard2.1
+ net6.0;net5.0;net461;netstandard2.0;netstandard2.1
5
True
@@ -16,4 +15,7 @@
+
+
+
diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
index a4355bc0..18e2e8c2 100644
--- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
+++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
@@ -5,8 +5,7 @@
Discord.Net.WebSocket
Discord.WebSocket
A core Discord.Net library containing the WebSocket client and models.
- net6.0;net5.0;net461;netstandard2.0;netstandard2.1
- net6.0;net5.0;netstandard2.0;netstandard2.1
+ net6.0;net5.0;net461;netstandard2.0;netstandard2.1
true
5
True
@@ -15,4 +14,7 @@
+
+
+