Skip to content

Commit

Permalink
back
Browse files Browse the repository at this point in the history
  • Loading branch information
seayxu committed Oct 15, 2022
1 parent b10a016 commit d0f0929
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
name: windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v1
- name: Run './build.cmd Deploy'
run: ./build.cmd Deploy
env:
Expand Down
8 changes: 4 additions & 4 deletions nuke/Build.Azure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
null,
AzurePipelinesImage.WindowsLatest,
AutoGenerate = true,
TriggerBranchesInclude = new[] { "main" },
InvokedTargets = new[] { nameof(Deploy) },
NonEntryTargets = new[] { nameof(Clean), nameof(Restore), nameof(Compile), nameof(Publish), nameof(Delete), nameof(Compress), nameof(Artifacts) },
TriggerBranchesInclude = new[] {"main"},
InvokedTargets = new[] {nameof(Deploy)},
NonEntryTargets = new[] { nameof(Clean), nameof(Restore), nameof(Compile), nameof(Publish), nameof(Delete),nameof(Compress), nameof(Artifacts)},
// ImportSecrets = new[] {nameof(GitHubAccessToken)},
CacheKeyFiles = new string[0]
)]
internal partial class Build
partial class Build
{
}
35 changes: 19 additions & 16 deletions nuke/Build.Github.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.AspNetCore.StaticFiles;

using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.IO;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities.Collections;

using Octokit;

using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

[GitHubActions(
"continuous",
GitHubActionsImage.WindowsLatest,
AutoGenerate = true,
PublishArtifacts = true,
// On = new[] { GitHubActionsTrigger.Push },
OnPushBranches = new []{"main"},
InvokedTargets = new []{nameof(Deploy)},
ImportSecrets = new []{nameof(GhAccessToken)},
OnPushBranches = new[] { "main" },
InvokedTargets = new[] { nameof(Deploy) },
ImportSecrets = new[] { nameof(GhAccessToken) },
CacheKeyFiles = new string[0]
)]
partial class Build
internal partial class Build
{
Target Deploy => _ => _
private Target Deploy => _ => _
.Description("Deploy")
.DependsOn(Artifacts)
.WhenSkipped(DependencyBehavior.Execute)
.OnlyWhenStatic(() => IsServerBuild && HostType == HostType.GitHubActions)
.OnlyWhenDynamic(() => GitVersion.BranchName.Equals("main") || GitVersion.BranchName.Equals("origin/main"))
.Executes(async () =>
{
if(string.IsNullOrWhiteSpace(GhAccessToken)) ControlFlow.Fail($"{nameof(GhAccessToken)} is null");
if (string.IsNullOrWhiteSpace(GhAccessToken)) ControlFlow.Fail($"{nameof(GhAccessToken)} is null");
Logger.Info("Release to github...");
await PublishAndUploadToGitHubRelease(GitVersion);
Logger.Info("Release to github finished.");
});
async Task PublishAndUploadToGitHubRelease(GitVersion git)

private async Task PublishAndUploadToGitHubRelease(GitVersion git)
{
try
{
Expand Down Expand Up @@ -76,8 +79,8 @@ async Task PublishAndUploadToGitHubRelease(GitVersion git)
// .Repository.Release
// .Edit(repositoryOwner, repositoryName, createdRelease.Id, new ReleaseUpdate { Draft = false });
}
Task UploadReleaseAssetToGithub(Release release, AbsolutePath asset)

private Task UploadReleaseAssetToGithub(Release release, AbsolutePath asset)
{
if (!FileSystemTasks.FileExists(asset)) return Task.CompletedTask;

Expand All @@ -92,7 +95,7 @@ Task UploadReleaseAssetToGithub(Release release, AbsolutePath asset)
FileName = Path.GetFileName(asset),
RawData = File.OpenRead(asset)
};

return GitHubTasks.GitHubClient.Repository.Release.UploadAsset(release, releaseAssetUpload);
}
}
4 changes: 2 additions & 2 deletions nuke/NukeBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</ItemGroup>

<ItemGroup>
<PackageDownload Include="GitVersion.Tool" Version="[5.6.10]" />
<PackageDownload Include="GitVersion.CommandLine" Version="[5.6.10]" />
<PackageDownload Include="GitVersion.Tool" Version="[5.10.3]" />
<PackageDownload Include="GitVersion.CommandLine" Version="[5.10.3]" />
</ItemGroup>

</Project>

0 comments on commit d0f0929

Please sign in to comment.