Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] New build action #2848

Merged
merged 33 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a75ae1a
Create dotnet.yml
Misha-133 Feb 12, 2024
a341e0b
Update dotnet.yml
Misha-133 Feb 12, 2024
058bc3d
Update dotnet.yml
Misha-133 Feb 13, 2024
d293122
Update dotnet.yml
Misha-133 Feb 13, 2024
302bd14
pragma disable some obsolete warnings
Misha-133 Feb 13, 2024
b20de3b
Update dotnet.yml
Misha-133 Feb 13, 2024
48b9e6b
Merge branch 'ci/dotnet-build-deploy' of https://github.com/Misha-133…
Misha-133 Feb 13, 2024
ce98c12
Update dotnet.yml
Misha-133 Feb 13, 2024
0cc982b
Update dotnet.yml
Misha-133 Feb 13, 2024
0290050
update vars for windows
Misha-133 Feb 13, 2024
9d61aa4
cache? dotnet
Misha-133 Feb 13, 2024
1e71d48
oops forgot to save
Misha-133 Feb 13, 2024
351ddd9
add concurrency
Misha-133 Feb 13, 2024
b58d3a1
test deploy
Misha-133 Feb 13, 2024
3ad92e4
fix?
Misha-133 Feb 13, 2024
7ef030c
disable caching
Misha-133 Feb 13, 2024
7803711
Update dotnet.yml
Misha-133 Feb 13, 2024
95f5c73
Update dotnet.yml
Misha-133 Feb 13, 2024
260776e
Update dotnet.yml
Misha-133 Feb 13, 2024
3b1178d
...
Misha-133 Feb 13, 2024
1710c92
Update dotnet.yml
Misha-133 Feb 13, 2024
f92277a
it should build now. maybe. probably
Misha-133 Feb 14, 2024
67de517
huh?
Misha-133 Feb 14, 2024
e1367e9
huh x2
Misha-133 Feb 14, 2024
86243f0
disable deploy on PRs / enable cache
Misha-133 Feb 14, 2024
8a377f2
publish test results
Misha-133 Feb 14, 2024
452c218
Update dotnet.yml
Misha-133 Feb 14, 2024
14b7895
remove cache cuz it's useless
Misha-133 Feb 14, 2024
4c2254f
Update dotnet.yml
Misha-133 Feb 14, 2024
9ee547d
push to github packages cuz why not
Misha-133 Feb 16, 2024
51d9c24
add toggle vars for pushes
Misha-133 Feb 16, 2024
aa02c19
Update dotnet.yml
Misha-133 Feb 16, 2024
6203255
uncomment release since there's a toggle now
Misha-133 Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -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 }}
6 changes: 4 additions & 2 deletions src/Discord.Net.Commands/Discord.Net.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
<AssemblyName>Discord.Net.Commands</AssemblyName>
<RootNamespace>Discord.Commands</RootNamespace>
<Description>A Discord.Net extension adding support for bot commands.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>
</Project>
6 changes: 4 additions & 2 deletions src/Discord.Net.Core/Discord.Net.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<AssemblyName>Discord.Net.Core</AssemblyName>
<RootNamespace>Discord</RootNamespace>
<Description>The core components for the Discord.Net library.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
Expand All @@ -29,4 +28,7 @@
<ItemGroup Condition=" '$(TargetFramework)' != 'net461'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>
</Project>
6 changes: 4 additions & 2 deletions src/Discord.Net.DebugTools/Discord.Net.DebugTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<AssemblyName>Discord.Net.DebugTools</AssemblyName>
<RootNamespace>Discord</RootNamespace>
<Description>A Discord.Net extension adding some helper classes for diagnosing issues.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.3</TargetFrameworks>
<TargetFramework Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3</TargetFramework>
<TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions src/Discord.Net.Interactions/Builders/ModuleClassBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ private static void BuildModule(ModuleBuilder builder, TypeInfo typeInfo, Intera
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;
Expand Down Expand Up @@ -177,11 +179,13 @@ private static void BuildSlashCommand(SlashCommandBuilder builder, Func<IService
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;
Expand Down Expand Up @@ -232,11 +236,13 @@ private static void BuildContextCommand(ContextCommandBuilder builder, Func<ISer
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;
Expand Down
6 changes: 4 additions & 2 deletions src/Discord.Net.Interactions/Discord.Net.Interactions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<Import Project="../../Discord.Net.targets" />
<Import Project="../../StyleAnalyzer.targets" />
<PropertyGroup>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<RootNamespace>Discord.Interactions</RootNamespace>
<AssemblyName>Discord.Net.Interactions</AssemblyName>
<Description>A Discord.Net extension adding support for Application Commands.</Description>
Expand All @@ -22,5 +21,8 @@
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ internal ContextCommandInfo(Builders.ContextCommandBuilder builder, ModuleInfo m
: 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public class SlashCommandInfo : CommandInfo<SlashCommandParameterInfo>, IApplica
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;
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.Interactions/Info/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ internal ModuleInfo(ModuleBuilder builder, InteractionService commandService, IS
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ private static void ParseModuleModel(this ModuleInfo moduleInfo, List<Applicatio
{
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
Expand Down
6 changes: 4 additions & 2 deletions src/Discord.Net.Rest/Discord.Net.Rest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<AssemblyName>Discord.Net.Rest</AssemblyName>
<RootNamespace>Discord.Rest</RootNamespace>
<Description>A core Discord.Net library containing the REST client and models.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
Expand All @@ -16,4 +15,7 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>
</Project>
6 changes: 4 additions & 2 deletions src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<AssemblyName>Discord.Net.WebSocket</AssemblyName>
<RootNamespace>Discord.WebSocket</RootNamespace>
<Description>A core Discord.Net library containing the WebSocket client and models.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net5.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>5</WarningLevel>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
Expand All @@ -15,4 +14,7 @@
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />
<ProjectReference Include="..\Discord.Net.Rest\Discord.Net.Rest.csproj" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4')) AND '$(MSBuildRuntimeType)' == 'Core' AND '$(OS)' != 'Windows_NT'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>
</Project>
Loading