Skip to content

Commit

Permalink
Merge branch 'release/0.66.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jul 29, 2023
2 parents a0e48c7 + 97a0616 commit bccc190
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"version": "3.1.0",
"commands": [
"dotnet-cake"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Logzio.DotNet.NLog" Version="1.0.16" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Source/ZoomNet.UnitTests/ZoomNet.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
56 changes: 51 additions & 5 deletions Source/ZoomNet/OAuthConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,49 @@ private OAuthConnectionInfo() { }
/// <param name="clientSecret">Your Client Secret.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo WithClientCredentials(string clientId, string clientSecret)
{
return WithClientCredentials(clientId, clientSecret, null, null);
}

/// <summary>
/// Initializes a new instance of the <see cref="OAuthConnectionInfo"/> class.
/// </summary>
/// <remarks>
/// This constructor is used to get access token for APIs that do not
/// need a user's permission, but rather a service's permission.
/// Within the realm of Zoom APIs, Client Credentials grant should be
/// used to get access token from the Chatbot Service in order to use
/// the "Send Chatbot Messages API". See the "Using OAuth 2.0 / Client
/// Credentials" section in the "Using Zoom APIs" document for more details
/// (https://marketplace.zoom.us/docs/api-reference/using-zoom-apis).
/// </remarks>
/// <param name="clientId">Your Client Id.</param>
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo WithClientCredentials(string clientId, string clientSecret, OnTokenRefreshedDelegate onTokenRefreshed)
{
return WithClientCredentials(clientId, clientSecret, null, onTokenRefreshed);
}

/// <summary>
/// Initializes a new instance of the <see cref="OAuthConnectionInfo"/> class.
/// </summary>
/// <remarks>
/// This constructor is used to get access token for APIs that do not
/// need a user's permission, but rather a service's permission.
/// Within the realm of Zoom APIs, Client Credentials grant should be
/// used to get access token from the Chatbot Service in order to use
/// the "Send Chatbot Messages API". See the "Using OAuth 2.0 / Client
/// Credentials" section in the "Using Zoom APIs" document for more details
/// (https://marketplace.zoom.us/docs/api-reference/using-zoom-apis).
/// </remarks>
/// <param name="clientId">Your Client Id.</param>
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="accessToken">The access token.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo WithClientCredentials(string clientId, string clientSecret, string accessToken, OnTokenRefreshedDelegate onTokenRefreshed)
{
if (string.IsNullOrEmpty(clientId)) throw new ArgumentNullException(nameof(clientId));
if (string.IsNullOrEmpty(clientSecret)) throw new ArgumentNullException(nameof(clientSecret));
Expand All @@ -229,7 +272,10 @@ public static OAuthConnectionInfo WithClientCredentials(string clientId, string
{
ClientId = clientId,
ClientSecret = clientSecret,
AccessToken = accessToken,
TokenExpiration = string.IsNullOrEmpty(accessToken) ? DateTime.MinValue : DateTime.MaxValue, // Set expiration to DateTime.MaxValue when an access token is provided because we don't know when it will expire
GrantType = OAuthGrantType.ClientCredentials,
OnTokenRefreshed = onTokenRefreshed,
};
}

Expand All @@ -253,7 +299,7 @@ public static OAuthConnectionInfo WithClientCredentials(string clientId, string
/// <param name="clientId">Your Client Id.</param>
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="authorizationCode">The authorization code.</param>
/// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued.</param>
/// <param name="redirectUri">The Redirect Uri.</param>
/// <param name="codeVerifier">The cryptographically random string used to correlate the authorization request to the token request.</param>
/// <returns>The connection info.</returns>
Expand Down Expand Up @@ -285,7 +331,7 @@ public static OAuthConnectionInfo WithAuthorizationCode(string clientId, string
/// <param name="clientId">Your Client Id.</param>
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="refreshToken">The refresh token.</param>
/// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued or refreshed.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo WithRefreshToken(string clientId, string clientSecret, string refreshToken, OnTokenRefreshedDelegate onTokenRefreshed)
{
Expand All @@ -311,7 +357,7 @@ public static OAuthConnectionInfo WithRefreshToken(string clientId, string clien
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="refreshToken">The refresh token.</param>
/// <param name="accessToken">(Optional) The access token. We recommend you specify a null value. See remarks for more details.</param>
/// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued or refreshed.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo WithRefreshToken(string clientId, string clientSecret, string refreshToken, string accessToken, OnTokenRefreshedDelegate onTokenRefreshed)
{
Expand Down Expand Up @@ -340,7 +386,7 @@ public static OAuthConnectionInfo WithRefreshToken(string clientId, string clien
/// <param name="clientId">Your Client Id.</param>
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="accountId">Your Account Id.</param>
/// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed. In the Server-to-Server scenario, this delegate is optional.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued. In the Server-to-Server scenario, this delegate is optional.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo ForServerToServer(string clientId, string clientSecret, string accountId, OnTokenRefreshedDelegate onTokenRefreshed = null)
{
Expand All @@ -366,7 +412,7 @@ public static OAuthConnectionInfo ForServerToServer(string clientId, string clie
/// <param name="clientSecret">Your Client Secret.</param>
/// <param name="accountId">Your Account Id.</param>
/// <param name="accessToken">(Optional) The access token. We recommend you specify a null value. See remarks for more details.</param>
/// <param name="onTokenRefreshed">The delegate invoked when the token is refreshed. In the Server-to-Server scenario, this delegate is optional.</param>
/// <param name="onTokenRefreshed">The delegate invoked when a token is issued. In the Server-to-Server scenario, this delegate is optional.</param>
/// <returns>The connection info.</returns>
public static OAuthConnectionInfo ForServerToServer(string clientId, string clientSecret, string accountId, string accessToken, OnTokenRefreshedDelegate onTokenRefreshed = null)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/ZoomNet/ZoomNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Pathoschild.Http.FluentClient" Version="4.3.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Websocket.Client" Version="4.6.1" />
Expand Down
99 changes: 76 additions & 23 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#tool dotnet:?package=GitVersion.Tool&version=5.12.0
#tool dotnet:?package=coveralls.net&version=4.0.1
#tool nuget:?package=GitReleaseManager&version=0.13.0
#tool nuget:?package=ReportGenerator&version=5.1.22
#tool nuget:?package=xunit.runner.console&version=2.4.2
#tool nuget:?package=ReportGenerator&version=5.1.23
#tool nuget:?package=xunit.runner.console&version=2.5.0
#tool nuget:?package=CodecovUploader&version=0.5.0

// Install addins.
Expand Down Expand Up @@ -51,8 +51,8 @@ var testCoverageExcludeFiles = new[]
var nuGetApiUrl = Argument<string>("NUGET_API_URL", EnvironmentVariable("NUGET_API_URL"));
var nuGetApiKey = Argument<string>("NUGET_API_KEY", EnvironmentVariable("NUGET_API_KEY"));

var myGetApiUrl = Argument<string>("MYGET_API_URL", EnvironmentVariable("MYGET_API_URL"));
var myGetApiKey = Argument<string>("MYGET_API_KEY", EnvironmentVariable("MYGET_API_KEY"));
var feedzioApiUrl = Argument<string>("FEEDZIO_API_URL", EnvironmentVariable("FEEDZIO_API_URL"));
var feedzioApiKey = Argument<string>("FEEDZIO_API_KEY", EnvironmentVariable("FEEDZIO_API_KEY"));

var gitHubToken = Argument<string>("GITHUB_TOKEN", EnvironmentVariable("GITHUB_TOKEN"));
var gitHubUserName = Argument<string>("GITHUB_USERNAME", EnvironmentVariable("GITHUB_USERNAME"));
Expand All @@ -74,12 +74,15 @@ var integrationTestsProject = $"{sourceFolder}{libraryName}.IntegrationTests/{li
var unitTestsProject = $"{sourceFolder}{libraryName}.UnitTests/{libraryName}.UnitTests.csproj";
var benchmarkProject = $"{sourceFolder}{libraryName}.Benchmark/{libraryName}.Benchmark.csproj";

var buildBranch = Context.GetBuildBranch();
var repoName = Context.GetRepoName();

var versionInfo = GitVersion(new GitVersionSettings() { OutputType = GitVersionOutput.Json });
var milestone = versionInfo.MajorMinorPatch;
var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();
var isLocalBuild = BuildSystem.IsLocalBuild;
var isMainBranch = StringComparer.OrdinalIgnoreCase.Equals("main", BuildSystem.AppVeyor.Environment.Repository.Branch);
var isMainRepo = StringComparer.OrdinalIgnoreCase.Equals($"{gitHubRepoOwner}/{gitHubRepo}", BuildSystem.AppVeyor.Environment.Repository.Name);
var isMainBranch = StringComparer.OrdinalIgnoreCase.Equals("main", buildBranch);
var isMainRepo = StringComparer.OrdinalIgnoreCase.Equals($"{gitHubRepoOwner}/{gitHubRepo}", repoName);
var isPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
var isTagged = BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag && !string.IsNullOrWhiteSpace(BuildSystem.AppVeyor.Environment.Repository.Tag.Name);
var isIntegrationTestsProjectPresent = FileExists(integrationTestsProject);
Expand Down Expand Up @@ -132,9 +135,9 @@ Setup(context =>
isTagged
);

Information("Myget Info:\r\n\tApi Url: {0}\r\n\tApi Key: {1}",
myGetApiUrl,
string.IsNullOrEmpty(myGetApiKey) ? "[NULL]" : new string('*', myGetApiKey.Length)
Information("Feedz.io Info:\r\n\tApi Url: {0}\r\n\tApi Key: {1}",
feedzioApiUrl,
string.IsNullOrEmpty(feedzioApiKey) ? "[NULL]" : new string('*', feedzioApiKey.Length)
);

Information("Nuget Info:\r\n\tApi Url: {0}\r\n\tApi Key: {1}",
Expand Down Expand Up @@ -405,33 +408,37 @@ Task("Publish-NuGet")
if(string.IsNullOrEmpty(nuGetApiKey)) throw new InvalidOperationException("Could not resolve NuGet API key.");
if(string.IsNullOrEmpty(nuGetApiUrl)) throw new InvalidOperationException("Could not resolve NuGet API url.");

var settings = new DotNetNuGetPushSettings
{
Source = nuGetApiUrl,
ApiKey = nuGetApiKey
};

foreach(var package in GetFiles(outputDir + "*.nupkg"))
{
// Push the package.
NuGetPush(package, new NuGetPushSettings {
ApiKey = nuGetApiKey,
Source = nuGetApiUrl
});
DotNetNuGetPush(package, settings);
}
});

Task("Publish-MyGet")
Task("Publish-Feedzio")
.IsDependentOn("Create-NuGet-Package")
.WithCriteria(() => !isLocalBuild)
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isMainRepo)
.Does(() =>
{
if(string.IsNullOrEmpty(myGetApiKey)) throw new InvalidOperationException("Could not resolve MyGet API key.");
if(string.IsNullOrEmpty(myGetApiUrl)) throw new InvalidOperationException("Could not resolve MyGet API url.");
if(string.IsNullOrEmpty(feedzioApiKey)) throw new InvalidOperationException("Could not resolve Feedz.io API key.");
if(string.IsNullOrEmpty(feedzioApiUrl)) throw new InvalidOperationException("Could not resolve Feedz.io API url.");

var settings = new DotNetNuGetPushSettings
{
Source = feedzioApiUrl,
ApiKey = feedzioApiKey
};

foreach(var package in GetFiles(outputDir + "*.nupkg"))
{
// Push the package.
NuGetPush(package, new NuGetPushSettings {
ApiKey = myGetApiKey,
Source = myGetApiUrl
});
DotNetNuGetPush(package, settings);
}
});

Expand Down Expand Up @@ -537,7 +544,7 @@ Task("AppVeyor")
.IsDependentOn("Upload-Coverage-Result-Codecov")
.IsDependentOn("Create-NuGet-Package")
.IsDependentOn("Upload-AppVeyor-Artifacts")
.IsDependentOn("Publish-MyGet")
.IsDependentOn("Publish-Feedzio")
.IsDependentOn("Publish-NuGet")
.IsDependentOn("Publish-GitHub-Release")
.Finally(() =>
Expand Down Expand Up @@ -580,3 +587,49 @@ private static string TrimStart(this string source, string value, StringComparis

return source.Substring(startIndex);
}

private static List<string> ExecuteCommand(this ICakeContext context, FilePath exe, string args)
{
context.StartProcess(exe, new ProcessSettings { Arguments = args, RedirectStandardOutput = true }, out var redirectedOutput);

return redirectedOutput.ToList();
}

private static List<string> ExecGitCmd(this ICakeContext context, string cmd)
{
var gitExe = context.Tools.Resolve(context.IsRunningOnWindows() ? "git.exe" : "git");
return context.ExecuteCommand(gitExe, cmd);
}

private static string GetBuildBranch(this ICakeContext context)
{
var buildSystem = context.BuildSystem();
string repositoryBranch = null;

if (buildSystem.IsRunningOnAppVeyor) repositoryBranch = buildSystem.AppVeyor.Environment.Repository.Branch;
else if (buildSystem.IsRunningOnAzurePipelines) repositoryBranch = buildSystem.AzurePipelines.Environment.Repository.SourceBranchName;
else if (buildSystem.IsRunningOnBamboo) repositoryBranch = buildSystem.Bamboo.Environment.Repository.Branch;
else if (buildSystem.IsRunningOnBitbucketPipelines) repositoryBranch = buildSystem.BitbucketPipelines.Environment.Repository.Branch;
else if (buildSystem.IsRunningOnBitrise) repositoryBranch = buildSystem.Bitrise.Environment.Repository.GitBranch;
else if (buildSystem.IsRunningOnGitHubActions) repositoryBranch = buildSystem.GitHubActions.Environment.Workflow.Ref.Replace("refs/heads/", "");
else if (buildSystem.IsRunningOnGitLabCI) repositoryBranch = buildSystem.GitLabCI.Environment.Build.RefName;
else if (buildSystem.IsRunningOnTeamCity) repositoryBranch = buildSystem.TeamCity.Environment.Build.BranchName;
else if (buildSystem.IsRunningOnTravisCI) repositoryBranch = buildSystem.TravisCI.Environment.Build.Branch;
else repositoryBranch = ExecGitCmd(context, "rev-parse --abbrev-ref HEAD").Single();

return repositoryBranch;
}

public static string GetRepoName(this ICakeContext context)
{
var buildSystem = context.BuildSystem();

if (buildSystem.IsRunningOnAppVeyor) return buildSystem.AppVeyor.Environment.Repository.Name;
else if (buildSystem.IsRunningOnAzurePipelines) return buildSystem.AzurePipelines.Environment.Repository.RepoName;
else if (buildSystem.IsRunningOnTravisCI) return buildSystem.TravisCI.Environment.Repository.Slug;
else if (buildSystem.IsRunningOnGitHubActions) return buildSystem.GitHubActions.Environment.Workflow.Repository;

var originUrl = ExecGitCmd(context, "config --get remote.origin.url").Single();
var parts = originUrl.Split('/', StringSplitOptions.RemoveEmptyEntries);
return $"{parts[parts.Length - 2]}/{parts[parts.Length - 1].Replace(".git", "")}";
}
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.305",
"version": "7.0.306",
"rollForward": "patch",
"allowPrerelease": false
}
Expand Down

0 comments on commit bccc190

Please sign in to comment.