diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e154a08..58b3a31b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [vNext] +## [7.0.4] / 2023-08-31 +- Fixed check on nullable parameter type +- Fixed telemetry check on home repository +- Fixed missing environment variables for AppVeyor +- Fixed `ICreateGitHubRelease` to work with existing releases +- Fixed `ICreateGitHubRelease` to set `GitHubToken` unconditionally +- Fixed `SetBuildTarget` and `SetTestPlatform` overloads in `UnityTasks` +- Fixed `UnityRunTestsSettings` base type + ## [7.0.3] / 2023-08-21 - Fixed enumeration value sets to exclude non-public fields - Fixed check for `NUKE_ENTERPRISE_TOKEN` in `build.sh` bootstrapping script @@ -1474,3 +1483,103 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [0.3.1]: https://github.com/nuke-build/nuke/compare/0.2.10...0.3.1 [0.2.10]: https://github.com/nuke-build/nuke/compare/0.2.0...0.2.10 [0.2.0]: https://github.com/nuke-build/nuke/tree/0.2.0 + +[vNext]: https://github.com/nuke-build/nuke/compare/7.0.4...HEAD +[7.0.4]: https://github.com/nuke-build/nuke/compare/7.0.3...7.0.4 +[7.0.3]: https://github.com/nuke-build/nuke/compare/7.0.2...7.0.3 +[7.0.2]: https://github.com/nuke-build/nuke/compare/7.0.1...7.0.2 +[7.0.1]: https://github.com/nuke-build/nuke/compare/7.0.0...7.0.1 +[7.0.0]: https://github.com/nuke-build/nuke/compare/6.3.0...7.0.0 +[6.3.0]: https://github.com/nuke-build/nuke/compare/6.2.1...6.3.0 +[6.2.1]: https://github.com/nuke-build/nuke/compare/6.2.0...6.2.1 +[6.2.0]: https://github.com/nuke-build/nuke/compare/6.1.2...6.2.0 +[6.1.2]: https://github.com/nuke-build/nuke/compare/6.1.1...6.1.2 +[6.1.1]: https://github.com/nuke-build/nuke/compare/6.1.0...6.1.1 +[6.1.0]: https://github.com/nuke-build/nuke/compare/6.0.3...6.1.0 +[6.0.3]: https://github.com/nuke-build/nuke/compare/6.0.2...6.0.3 +[6.0.2]: https://github.com/nuke-build/nuke/compare/6.0.1...6.0.2 +[6.0.1]: https://github.com/nuke-build/nuke/compare/6.0.0...6.0.1 +[6.0.0]: https://github.com/nuke-build/nuke/compare/5.3.0...6.0.0 +[5.3.0]: https://github.com/nuke-build/nuke/compare/5.2.1...5.3.0 +[5.2.1]: https://github.com/nuke-build/nuke/compare/5.2.0...5.2.1 +[5.2.0]: https://github.com/nuke-build/nuke/compare/5.1.4...5.2.0 +[5.1.4]: https://github.com/nuke-build/nuke/compare/5.1.3...5.1.4 +[5.1.3]: https://github.com/nuke-build/nuke/compare/5.1.2...5.1.3 +[5.1.2]: https://github.com/nuke-build/nuke/compare/5.1.1...5.1.2 +[5.1.1]: https://github.com/nuke-build/nuke/compare/5.1.0...5.1.1 +[5.1.0]: https://github.com/nuke-build/nuke/compare/5.0.2...5.1.0 +[5.0.2]: https://github.com/nuke-build/nuke/compare/5.0.1...5.0.2 +[5.0.1]: https://github.com/nuke-build/nuke/compare/5.0.0...5.0.1 +[5.0.0]: https://github.com/nuke-build/nuke/compare/0.25.0...5.0.0 +[0.25.0]: https://github.com/nuke-build/nuke/compare/0.24.11...0.25.0 +[0.24.11]: https://github.com/nuke-build/nuke/compare/0.24.10...0.24.11 +[0.24.10]: https://github.com/nuke-build/nuke/compare/0.24.9...0.24.10 +[0.24.9]: https://github.com/nuke-build/nuke/compare/0.24.8...0.24.9 +[0.24.8]: https://github.com/nuke-build/nuke/compare/0.24.7...0.24.8 +[0.24.7]: https://github.com/nuke-build/nuke/compare/0.24.6...0.24.7 +[0.24.6]: https://github.com/nuke-build/nuke/compare/0.24.5...0.24.6 +[0.24.5]: https://github.com/nuke-build/nuke/compare/0.24.4...0.24.5 +[0.24.4]: https://github.com/nuke-build/nuke/compare/0.24.2...0.24.4 +[0.24.2]: https://github.com/nuke-build/nuke/compare/0.24.1...0.24.2 +[0.24.1]: https://github.com/nuke-build/nuke/compare/0.24.0...0.24.1 +[0.24.0]: https://github.com/nuke-build/nuke/compare/0.23.7...0.24.0 +[0.23.7]: https://github.com/nuke-build/nuke/compare/0.23.6...0.23.7 +[0.23.6]: https://github.com/nuke-build/nuke/compare/0.23.5...0.23.6 +[0.23.5]: https://github.com/nuke-build/nuke/compare/0.23.4...0.23.5 +[0.23.4]: https://github.com/nuke-build/nuke/compare/0.23.3...0.23.4 +[0.23.3]: https://github.com/nuke-build/nuke/compare/0.23.2...0.23.3 +[0.23.2]: https://github.com/nuke-build/nuke/compare/0.23.1...0.23.2 +[0.23.1]: https://github.com/nuke-build/nuke/compare/0.23.0...0.23.1 +[0.23.0]: https://github.com/nuke-build/nuke/compare/0.22.2...0.23.0 +[0.22.2]: https://github.com/nuke-build/nuke/compare/0.22.1...0.22.2 +[0.22.1]: https://github.com/nuke-build/nuke/compare/0.22.0...0.22.1 +[0.22.0]: https://github.com/nuke-build/nuke/compare/0.21.2...0.22.0 +[0.21.2]: https://github.com/nuke-build/nuke/compare/0.21.1...0.21.2 +[0.21.1]: https://github.com/nuke-build/nuke/compare/0.21.0...0.21.1 +[0.21.0]: https://github.com/nuke-build/nuke/compare/0.20.1...0.21.0 +[0.20.1]: https://github.com/nuke-build/nuke/compare/0.20.0...0.20.1 +[0.20.0]: https://github.com/nuke-build/nuke/compare/0.19.2...0.20.0 +[0.19.2]: https://github.com/nuke-build/nuke/compare/0.19.1...0.19.2 +[0.19.1]: https://github.com/nuke-build/nuke/compare/0.19.0...0.19.1 +[0.19.0]: https://github.com/nuke-build/nuke/compare/0.18.0...0.19.0 +[0.18.0]: https://github.com/nuke-build/nuke/compare/0.17.7...0.18.0 +[0.17.7]: https://github.com/nuke-build/nuke/compare/0.17.6...0.17.7 +[0.17.6]: https://github.com/nuke-build/nuke/compare/0.17.5...0.17.6 +[0.17.5]: https://github.com/nuke-build/nuke/compare/0.17.4...0.17.5 +[0.17.4]: https://github.com/nuke-build/nuke/compare/0.17.3...0.17.4 +[0.17.3]: https://github.com/nuke-build/nuke/compare/0.17.2...0.17.3 +[0.17.2]: https://github.com/nuke-build/nuke/compare/0.17.1...0.17.2 +[0.17.1]: https://github.com/nuke-build/nuke/compare/0.17.0...0.17.1 +[0.17.0]: https://github.com/nuke-build/nuke/compare/0.16.0...0.17.0 +[0.16.0]: https://github.com/nuke-build/nuke/compare/0.15.0...0.16.0 +[0.15.0]: https://github.com/nuke-build/nuke/compare/0.14.1...0.15.0 +[0.14.1]: https://github.com/nuke-build/nuke/compare/0.14.0...0.14.1 +[0.14.0]: https://github.com/nuke-build/nuke/compare/0.13.0...0.14.0 +[0.13.0]: https://github.com/nuke-build/nuke/compare/0.12.4...0.13.0 +[0.12.4]: https://github.com/nuke-build/nuke/compare/0.12.3...0.12.4 +[0.12.3]: https://github.com/nuke-build/nuke/compare/0.12.2...0.12.3 +[0.12.2]: https://github.com/nuke-build/nuke/compare/0.12.1...0.12.2 +[0.12.1]: https://github.com/nuke-build/nuke/compare/0.12.0...0.12.1 +[0.12.0]: https://github.com/nuke-build/nuke/compare/0.11.1...0.12.0 +[0.11.1]: https://github.com/nuke-build/nuke/compare/0.11.0...0.11.1 +[0.11.0]: https://github.com/nuke-build/nuke/compare/0.10.5...0.11.0 +[0.10.5]: https://github.com/nuke-build/nuke/compare/0.10.4...0.10.5 +[0.10.4]: https://github.com/nuke-build/nuke/compare/0.10.3...0.10.4 +[0.10.3]: https://github.com/nuke-build/nuke/compare/0.10.2...0.10.3 +[0.10.2]: https://github.com/nuke-build/nuke/compare/0.10.1...0.10.2 +[0.10.1]: https://github.com/nuke-build/nuke/compare/0.10.0...0.10.1 +[0.10.0]: https://github.com/nuke-build/nuke/compare/0.9.1...0.10.0 +[0.9.1]: https://github.com/nuke-build/nuke/compare/0.9.0...0.9.1 +[0.9.0]: https://github.com/nuke-build/nuke/compare/0.8.0...0.9.0 +[0.8.0]: https://github.com/nuke-build/nuke/compare/0.7.0...0.8.0 +[0.7.0]: https://github.com/nuke-build/nuke/compare/0.6.2...0.7.0 +[0.6.2]: https://github.com/nuke-build/nuke/compare/0.6.1...0.6.2 +[0.6.1]: https://github.com/nuke-build/nuke/compare/0.6.0...0.6.1 +[0.6.0]: https://github.com/nuke-build/nuke/compare/0.5.3...0.6.0 +[0.5.3]: https://github.com/nuke-build/nuke/compare/0.5.2...0.5.3 +[0.5.2]: https://github.com/nuke-build/nuke/compare/0.5.0...0.5.2 +[0.5.0]: https://github.com/nuke-build/nuke/compare/0.4.0...0.5.0 +[0.4.0]: https://github.com/nuke-build/nuke/compare/0.3.1...0.4.0 +[0.3.1]: https://github.com/nuke-build/nuke/compare/0.2.10...0.3.1 +[0.2.10]: https://github.com/nuke-build/nuke/compare/0.2.0...0.2.10 +[0.2.0]: https://github.com/nuke-build/nuke/tree/0.2.0 diff --git a/appveyor.yml b/appveyor.yml index 2c9b2f882..3c2516244 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,13 +41,13 @@ environment: SignPathApiToken: secure: uQTH2MxpqiqWTy7EJkjtNc43ipG17EUOQN99QsODRNgtNEcikDaP0t4ylekK/ibn TwitterConsumerKey: - secure: mYr1Uw8bcVUyl1P0prdaUFurdiF7V283BSRlQHxe2Zg= + secure: T61zL4r+xtyj7b0aOGYCsyixrXHooXE759T8z3M67Lw= TwitterConsumerSecret: - secure: pGt5X6KOwj/bLM4A5mnDRBqPxt7o7UreSlZSFmbfZwyfKZnhfFRnr20fXWjVqToVw7NSp30s6GxjswTrQSIogw== + secure: CZwdlO4PHT51Xr0Pe/mT6WpfBzQXsL0C3yWfHgXqdYrf22rx8ePEt5qpszWckbHE5Vh5ErtVfIAQgLeFrqe2Gg== TwitterAccessToken: - secure: nnv1h5nkNm4MS50soQHiYUZLERgkft/ooq73B02sLValeUDZFypI3tk1TzUwACzJPOdjqRSvY9efvQbt2MoNaQ== + secure: nnv1h5nkNm4MS50soQHiYZk9hnPkWEMQP/5cdf6RJfDIL1gUYxLR7uBaAi1M4sswT0TQ7oL4TBIN/yziq33N5A== TwitterAccessTokenSecret: - secure: odqmaAfKaVzNj8Ph/q2sLVmM/1COuix8NoqtDwayr8KEli3kmtGFThrN4g5k6aKT + secure: /RrBl2p46rlgpzBHweWeD0spt3JNZDsM8vABoI9Ao29+Z9D4rUYvpM5oHUWA8Lb6 SlackWebhook: secure: xENxLITTR28hBLEY51YWMeHhxkhg1h1tLY1zGre1/hmM/XDRPsJCxvZvTHFhtfLsQ3cF7GQi3xDaShkVVR7zoXHsIYT+KT0zLnq9FSEvr5c= DiscordWebhook: diff --git a/build/Build.Announce.cs b/build/Build.Announce.cs index 445b48a93..c3a09433f 100644 --- a/build/Build.Announce.cs +++ b/build/Build.Announce.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using LinqToTwitter; +using LinqToTwitter.OAuth; using Nuke.Common; using Nuke.Common.ChangeLog; using Nuke.Common.Git; @@ -16,9 +18,6 @@ using Nuke.Common.Tools.Slack; using Nuke.Common.Utilities; using Nuke.Components; -using Tweetinvi; -using Tweetinvi.Models; -using Tweetinvi.Parameters; using static Nuke.Common.Tools.Discord.DiscordTasks; using static Nuke.Common.Tools.Git.GitTasks; using static Nuke.Common.Tools.Mastodon.MastodonTasks; @@ -78,10 +77,12 @@ partial class Build ("Amazon Web Services", "https://aws.amazon.com/"), }; + // https://api.slack.com/apps/A050ZLH0V40/incoming-webhooks? [Parameter] [Secret] readonly string SlackWebhook; Target AnnounceSlack => _ => _ .TriggeredBy(Announce) + .ProceedAfterFailure() .Requires(() => SlackWebhook) .Executes(async () => { @@ -105,10 +106,12 @@ await SendSlackMessageAsync(_ => _ SlackWebhook); }); + // Server settings | Apps | Integrations | Webhooks | NUKE [Parameter] [Secret] readonly string DiscordWebhook; Target AnnounceDiscord => _ => _ .TriggeredBy(Announce) + .ProceedAfterFailure() .Requires(() => DiscordWebhook) .Executes(async () => { @@ -143,38 +146,41 @@ await SendDiscordMessageAsync(_ => _ Target AnnounceTwitter => _ => _ .TriggeredBy(Announce) + .ProceedAfterFailure() .Requires(() => TwitterCredentials.ConsumerKey) .Requires(() => TwitterCredentials.ConsumerSecret) .Requires(() => TwitterCredentials.AccessToken) .Requires(() => TwitterCredentials.AccessTokenSecret) .Executes(async () => { - var client = new TwitterClient( - new TwitterCredentials( - TwitterCredentials.ConsumerKey, - TwitterCredentials.ConsumerSecret, - TwitterCredentials.AccessToken, - TwitterCredentials.AccessTokenSecret)); - - var media = await client.Upload.UploadTweetImageAsync( - new UploadTweetImageParameters(ReleaseImageFile.ReadAllBytes()) + var context = new TwitterContext( + new SingleUserAuthorizer { - MediaCategory = MediaCategory.Image + CredentialStore = + new SingleUserInMemoryCredentialStore + { + ConsumerKey = TwitterCredentials.ConsumerKey, + ConsumerSecret = TwitterCredentials.ConsumerSecret, + AccessToken = TwitterCredentials.AccessToken, + AccessTokenSecret = TwitterCredentials.AccessTokenSecret + } }); - await client.Tweets.PublishTweetAsync( - new PublishTweetParameters - { - Text = AnnouncementTweetText, - Medias = new List { media } - }); + var media = await context.UploadMediaAsync( + media: ReleaseImageFile.ReadAllBytes(), + mediaType: "image/png", + mediaCategory: "tweet_image"); + + await context.TweetMediaAsync(AnnouncementTweetText, mediaIds: new[] { media.NotNull().MediaID.ToString() }); }); string AnnouncementTootText => AnnouncementTweetText; + // https://dotnet.social/settings/applications/496 [Parameter] [Secret] readonly string MastodonAccessToken; Target AnnounceMastodon => _ => _ .TriggeredBy(Announce) + .ProceedAfterFailure() .Requires(() => MastodonAccessToken) .Executes(async () => { diff --git a/build/Build.CI.AppVeyor.cs b/build/Build.CI.AppVeyor.cs index e91a2c584..51dd13e13 100644 --- a/build/Build.CI.AppVeyor.cs +++ b/build/Build.CI.AppVeyor.cs @@ -37,10 +37,10 @@ [AppVeyorSecret(nameof(PublicNuGetApiKey), "dSaquYHVNEAZO+hhGGoGqeHaVP99BP8koHTTqcD3WInWBTmB7yE4CzxZ1pWypnX2")] [AppVeyorSecret(ICreateGitHubRelease.GitHubRelease + nameof(ICreateGitHubRelease.GitHubToken), "a5UfxXiDEere9GkCCN9TUZMUdyzjC01cvHthbMLtSl0w+/giDwOyApiHRRRrwyKL5yd/vjD6xDBTBj+W/ZxKzMtzC+gDCSTNO8bSJG9Rh2n9eGzLtWzEFDw/zDYZXe5N")] [AppVeyorSecret(ISignPackages.SignPath + nameof(ISignPackages.ApiToken), "uQTH2MxpqiqWTy7EJkjtNc43ipG17EUOQN99QsODRNgtNEcikDaP0t4ylekK/ibn")] -[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.ConsumerKey), "mYr1Uw8bcVUyl1P0prdaUFurdiF7V283BSRlQHxe2Zg=")] -[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.ConsumerSecret), "pGt5X6KOwj/bLM4A5mnDRBqPxt7o7UreSlZSFmbfZwyfKZnhfFRnr20fXWjVqToVw7NSp30s6GxjswTrQSIogw==")] -[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.AccessToken), "nnv1h5nkNm4MS50soQHiYUZLERgkft/ooq73B02sLValeUDZFypI3tk1TzUwACzJPOdjqRSvY9efvQbt2MoNaQ==")] -[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.AccessTokenSecret), "odqmaAfKaVzNj8Ph/q2sLVmM/1COuix8NoqtDwayr8KEli3kmtGFThrN4g5k6aKT")] +[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.ConsumerKey), "T61zL4r+xtyj7b0aOGYCsyixrXHooXE759T8z3M67Lw=")] +[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.ConsumerSecret), "CZwdlO4PHT51Xr0Pe/mT6WpfBzQXsL0C3yWfHgXqdYrf22rx8ePEt5qpszWckbHE5Vh5ErtVfIAQgLeFrqe2Gg==")] +[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.AccessToken), "nnv1h5nkNm4MS50soQHiYZk9hnPkWEMQP/5cdf6RJfDIL1gUYxLR7uBaAi1M4sswT0TQ7oL4TBIN/yziq33N5A==")] +[AppVeyorSecret(IHazTwitterCredentials.Twitter + nameof(IHazTwitterCredentials.AccessTokenSecret), "/RrBl2p46rlgpzBHweWeD0spt3JNZDsM8vABoI9Ao29+Z9D4rUYvpM5oHUWA8Lb6")] [AppVeyorSecret(nameof(SlackWebhook), "xENxLITTR28hBLEY51YWMeHhxkhg1h1tLY1zGre1/hmM/XDRPsJCxvZvTHFhtfLsQ3cF7GQi3xDaShkVVR7zoXHsIYT+KT0zLnq9FSEvr5c=")] [AppVeyorSecret(nameof(DiscordWebhook), "K5WG8m71vcB56C75b0ErFPLYTsqywhPy8hSn49uqc5XBE7txUnZqWBHfbWCuU9AdFkm3TNgSYLoejjF59OgiACEn45fghVe7XCwAXo2l54ZXl08MZyBkJ8by9HsZirL9W+SeysNdw/Cfc0sxKrWcpDkn1IH2zZ+iXAgqBsW2CNY=")] [AppVeyorSecret(nameof(MastodonAccessToken), "pD/C1TvhUnFtb0oLUvlf2NtjkWeZQcrUVvYJE/LgZb8nxagK8Lwk+OR7TUqOh+Nn")] diff --git a/build/_build.csproj b/build/_build.csproj index 228f882be..a335ad710 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -52,6 +52,7 @@ + diff --git a/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs b/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs index b165d1e51..1a2b1c97d 100644 --- a/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs +++ b/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs @@ -6,10 +6,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using JetBrains.Annotations; using Newtonsoft.Json.Linq; using Nuke.Common.CI; using Nuke.Common.IO; -using Nuke.Common.ProjectModel; using Nuke.Common.Utilities; using Nuke.Common.Utilities.Collections; using Nuke.Common.ValueInjection; @@ -48,11 +48,10 @@ string DecryptValue(string profile, string name, string value) name); // TODO: Abstract AbsolutePath/Solution/Project etc. - string ConvertValue(Type scalarType, string value) - => scalarType.IsAssignableTo(typeof(IAbsolutePathHolder)) - ? PathConstruction.HasPathRoot(value) - ? value - : EnvironmentInfo.WorkingDirectory.GetUnixRelativePathTo(Build.RootDirectory / value) + string ConvertValue([CanBeNull] Type scalarType, string value) + => typeof(IAbsolutePathHolder).IsAssignableFrom(scalarType) && + !PathConstruction.HasPathRoot(value) + ? EnvironmentInfo.WorkingDirectory.GetUnixRelativePathTo(Build.RootDirectory / value) : value; var arguments = GetParameters().SelectMany(x => ConvertToArguments(x.Profile, x.Name, x.Values)).ToArray(); diff --git a/source/Nuke.Build/Telemetry/Telemetry.Properties.cs b/source/Nuke.Build/Telemetry/Telemetry.Properties.cs index f980b17a8..8904dd6ef 100644 --- a/source/Nuke.Build/Telemetry/Telemetry.Properties.cs +++ b/source/Nuke.Build/Telemetry/Telemetry.Properties.cs @@ -126,7 +126,7 @@ private static bool IsCommonType(Type type) { return type.Assembly .GetCustomAttributes() - .Any(x => x is { Key: "RepositoryUrl", Value: "https://github.com/nuke-build/nuke" }); + .Any(x => x is { Key: "RepositoryUrl", Value: "https://github.com/nuke-build/nuke.git" }); } private static bool IsCustomType(Type type) diff --git a/source/Nuke.Common/CI/AppVeyor/AppVeyor.cs b/source/Nuke.Common/CI/AppVeyor/AppVeyor.cs index e9f7e11f8..11ea4760a 100644 --- a/source/Nuke.Common/CI/AppVeyor/AppVeyor.cs +++ b/source/Nuke.Common/CI/AppVeyor/AppVeyor.cs @@ -67,6 +67,9 @@ internal AppVeyor() public string BuildWorkerImage => EnvironmentInfo.GetVariable("APPVEYOR_BUILD_WORKER_IMAGE"); [CanBeNull] public int? PullRequestNumber => EnvironmentInfo.GetVariable("APPVEYOR_PULL_REQUEST_NUMBER"); [CanBeNull] public string PullRequestTitle => EnvironmentInfo.GetVariable("APPVEYOR_PULL_REQUEST_TITLE"); + [CanBeNull] public string PullRequestHeadRepositoryName => EnvironmentInfo.GetVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME"); + [CanBeNull] public string PullRequestHeadRepositoryBranch => EnvironmentInfo.GetVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH"); + [CanBeNull] public string PullRequestHeadCommit => EnvironmentInfo.GetVariable("APPVEYOR_PULL_REQUEST_HEAD_COMMIT"); public string JobId => EnvironmentInfo.GetVariable("APPVEYOR_JOB_ID"); [CanBeNull] public string JobName => EnvironmentInfo.GetVariable("APPVEYOR_JOB_NAME"); public int JobNumber => EnvironmentInfo.GetVariable("APPVEYOR_JOB_NUMBER"); diff --git a/source/Nuke.Common/Tools/Unity/Unity.Generated.cs b/source/Nuke.Common/Tools/Unity/Unity.Generated.cs index 155f2351d..7d1d387a3 100644 --- a/source/Nuke.Common/Tools/Unity/Unity.Generated.cs +++ b/source/Nuke.Common/Tools/Unity/Unity.Generated.cs @@ -752,7 +752,7 @@ protected override Arguments ConfigureProcessArguments(Arguments arguments) [PublicAPI] [ExcludeFromCodeCoverage] [Serializable] -public partial class UnityRunTestsSettings : UnityBaseSettings +public partial class UnityRunTestsSettings : UnityProjectSettings { /// /// Path to the Unity executable. diff --git a/source/Nuke.Common/Tools/Unity/Unity.json b/source/Nuke.Common/Tools/Unity/Unity.json index deff95cd0..353fb1762 100644 --- a/source/Nuke.Common/Tools/Unity/Unity.json +++ b/source/Nuke.Common/Tools/Unity/Unity.json @@ -166,7 +166,7 @@ "customAssertion": true, "definiteArgument": "-runTests", "settingsClass": { - "baseClass": "UnityBaseSettings", + "baseClass": "UnityProjectSettings", "properties": [ { "name": "TestCategories", diff --git a/source/Nuke.Common/Tools/Unity/UnityProjectSettingsExtensions.cs b/source/Nuke.Common/Tools/Unity/UnityProjectSettingsExtensions.cs index dfa84db84..fe4533d5c 100644 --- a/source/Nuke.Common/Tools/Unity/UnityProjectSettingsExtensions.cs +++ b/source/Nuke.Common/Tools/Unity/UnityProjectSettingsExtensions.cs @@ -5,7 +5,6 @@ using System; using System.Linq; using JetBrains.Annotations; -using Nuke.Common.Tooling; namespace Nuke.Common.Tools.Unity; @@ -15,11 +14,10 @@ public static partial class UnityProjectSettingsExtensions ///

Sets .

Allows the selection of an active build target before a project is loaded.

[Pure] - public static UnityProjectSettings SetBuildTarget(this UnityProjectSettings toolSettings, UnityBuildTarget buildTarget) + public static T SetBuildTarget(this T toolSettings, UnityBuildTarget buildTarget) + where T : UnityProjectSettings { - toolSettings = toolSettings.NewInstance(); - toolSettings.BuildTarget = buildTarget.ToString(); - return toolSettings; + return toolSettings.SetBuildTarget(buildTarget.ToString()); } #endregion diff --git a/source/Nuke.Common/Tools/Unity/UnityRunTestsSettingsExtensions.cs b/source/Nuke.Common/Tools/Unity/UnityRunTestsSettingsExtensions.cs index e603ea4b7..ce2957c09 100644 --- a/source/Nuke.Common/Tools/Unity/UnityRunTestsSettingsExtensions.cs +++ b/source/Nuke.Common/Tools/Unity/UnityRunTestsSettingsExtensions.cs @@ -5,7 +5,6 @@ using System; using System.Linq; using JetBrains.Annotations; -using Nuke.Common.Tooling; namespace Nuke.Common.Tools.Unity; @@ -18,11 +17,10 @@ public static partial class UnityRunTestsSettingsExtensions ///

The platform to run tests on.

///
[Pure] - public static UnityRunTestsSettings SetTestPlatform(this UnityRunTestsSettings toolSettings, UnityTestPlatform testPlatform) + public static T SetTestPlatform(this T toolSettings, UnityTestPlatform testPlatform) + where T : UnityRunTestsSettings { - toolSettings = toolSettings.NewInstance(); - toolSettings.TestPlatform = testPlatform.ToString(); - return toolSettings; + return toolSettings.SetTestPlatform(testPlatform.ToString()); } /// @@ -30,11 +28,10 @@ public static UnityRunTestsSettings SetTestPlatform(this UnityRunTestsSettings t ///

The platform to run tests on.

///
[Pure] - public static UnityRunTestsSettings SetTestPlatform(this UnityRunTestsSettings toolSettings, UnityBuildTarget buildTarget) + public static T SetTestPlatform(this T toolSettings, UnityBuildTarget buildTarget) + where T : UnityRunTestsSettings { - toolSettings = toolSettings.NewInstance(); - toolSettings.TestPlatform = buildTarget.ToString(); - return toolSettings; + return toolSettings.SetTestPlatform(buildTarget.ToString()); } #endregion diff --git a/source/Nuke.Components/ICreateGitHubRelease.cs b/source/Nuke.Components/ICreateGitHubRelease.cs index d9ceb75ae..5057b045f 100644 --- a/source/Nuke.Components/ICreateGitHubRelease.cs +++ b/source/Nuke.Components/ICreateGitHubRelease.cs @@ -36,18 +36,34 @@ public interface ICreateGitHubRelease : IHazGitRepository, IHazChangelog .Requires(() => GitHubToken) .Executes(async () => { - GitHubTasks.GitHubClient.Credentials ??= new Credentials(GitHubToken.NotNull()); + async Task GetOrCreateRelease() + { + try + { + return await GitHubTasks.GitHubClient.Repository.Release.Create( + GitRepository.GetGitHubOwner(), + GitRepository.GetGitHubName(), + new NewRelease(Name) + { + Name = Name, + Prerelease = Prerelease, + Draft = Draft, + Body = ChangelogTasks.ExtractChangelogSectionNotes(ChangelogFile).JoinNewLine() + }); - var release = await GitHubTasks.GitHubClient.Repository.Release.Create( - GitRepository.GetGitHubOwner(), - GitRepository.GetGitHubName(), - new NewRelease(Name) + } + catch { - Name = Name, - Prerelease = Prerelease, - Draft = Draft, - Body = ChangelogTasks.ExtractChangelogSectionNotes(ChangelogFile).JoinNewLine() - }); + return await GitHubTasks.GitHubClient.Repository.Release.Get( + GitRepository.GetGitHubOwner(), + GitRepository.GetGitHubName(), + Name); + } + } + + GitHubTasks.GitHubClient.Credentials = new Credentials(GitHubToken.NotNull()); + + var release = await GetOrCreateRelease(); var uploadTasks = AssetFiles.Select(async x => { diff --git a/source/Nuke.Components/ITweetTips.cs b/source/Nuke.Components/ITweetTips.cs deleted file mode 100644 index ad52cd646..000000000 --- a/source/Nuke.Components/ITweetTips.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2023 Maintainers of NUKE. -// Distributed under the MIT License. -// https://github.com/nuke-build/nuke/blob/master/LICENSE - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using JetBrains.Annotations; -using Nuke.Common; -using Nuke.Common.IO; -using Nuke.Common.Utilities; -using Serilog; -using Tweetinvi; -using Tweetinvi.Models; -using Tweetinvi.Parameters; - -namespace Nuke.Components; - -[PublicAPI] -public interface ITweetTips : IHazTwitterCredentials -{ - AbsolutePath TweetDirectory { get; } - - Target Tweet => _ => _ - .Requires(() => ConsumerKey) - .Requires(() => ConsumerSecret) - .Requires(() => AccessToken) - .Requires(() => AccessTokenSecret) - .Executes(async () => - { - var client = new TwitterClient( - new TwitterCredentials( - ConsumerKey, - ConsumerSecret, - AccessToken, - AccessTokenSecret)); - - var tweetDirectories = TweetDirectory.GlobDirectories("*").OrderBy(x => (string) x).ToList(); - var index = (int) (DateTime.Now.Ticks / TimeSpan.FromDays(7).Ticks) % tweetDirectories.Count; - var tweetDirectory = tweetDirectories.Last(); - - var sentTweets = new List(); - var sortedTweets = tweetDirectory.GlobFiles("*.md").OrderBy(x => (string) x); - foreach (var tweetFile in sortedTweets) - { - var part = Path.GetFileNameWithoutExtension(tweetFile); - var text = tweetFile.ReadAllText(); - var media = tweetDirectory.GlobFiles($"{part}*.png", $"{part}*.jpeg", $"{part}*.jpg", $"{part}*.gif") - .Select(async x => await client.Upload.UploadTweetImageAsync( - new UploadTweetImageParameters(x.ReadAllBytes()) - { - MediaCategory = x.ToString().EndsWithOrdinalIgnoreCase("gif") - ? MediaCategory.Gif - : MediaCategory.Image - })) - .Select(x => x.Result).ToList(); - - var tweetParameters = new PublishTweetParameters - { - InReplyToTweetId = sentTweets.LastOrDefault()?.Id, - Text = text, - Medias = media - }; - - var tweet = await client.Tweets.PublishTweetAsync(tweetParameters); - sentTweets.Add(tweet); - } - - Log.Information("Sent tweet {Url}", sentTweets.First().Url); - }); -} diff --git a/source/Nuke.Components/Nuke.Components.csproj b/source/Nuke.Components/Nuke.Components.csproj index e6f801f96..890d2cbdc 100644 --- a/source/Nuke.Components/Nuke.Components.csproj +++ b/source/Nuke.Components/Nuke.Components.csproj @@ -8,8 +8,4 @@
- - - -