-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathissuetrackers-github.cake
88 lines (67 loc) · 3.36 KB
/
issuetrackers-github.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#tool "nuget:?package=gitreleasemanager&version=0.18.0"
//-------------------------------------------------------------
public class GitHubIssueTracker : IIssueTracker
{
public GitHubIssueTracker(BuildContext buildContext)
{
BuildContext = buildContext;
ApiKey = buildContext.BuildServer.GetVariable("GitHubApiKey", showValue: false);
OwnerName = buildContext.BuildServer.GetVariable("GitHubOwnerName", buildContext.General.Copyright.Company, showValue: true);
ProjectName = buildContext.BuildServer.GetVariable("GitHubProjectName", buildContext.General.Solution.Name, showValue: true);
if (!string.IsNullOrWhiteSpace(ApiKey) &&
!string.IsNullOrWhiteSpace(OwnerName) &&
!string.IsNullOrWhiteSpace(ProjectName))
{
IsAvailable = true;
}
}
public BuildContext BuildContext { get; private set; }
public string ApiKey { get; set; }
public string OwnerName { get; set; }
public string ProjectName { get; set; }
public string OwnerAndProjectName
{
get { return $"{OwnerName}/{ProjectName}"; }
}
public bool IsAvailable { get; private set; }
public async Task CreateAndReleaseVersionAsync()
{
if (!IsAvailable)
{
BuildContext.CakeContext.Information("GitHub is not available, skipping GitHub integration");
return;
}
var version = BuildContext.General.Version.FullSemVer;
BuildContext.CakeContext.Information("Releasing version '{0}' in GitHub", version);
// For docs, see https://cakebuild.net/dsl/gitreleasemanager/
BuildContext.CakeContext.Information("Step 1 / 4: Creating release");
BuildContext.CakeContext.GitReleaseManagerCreate(ApiKey, OwnerName, ProjectName, new GitReleaseManagerCreateSettings
{
TargetDirectory = BuildContext.General.RootDirectory,
Milestone = BuildContext.General.Version.MajorMinorPatch,
Name = version,
Prerelease = !BuildContext.General.IsOfficialBuild,
TargetCommitish = BuildContext.General.Repository.CommitId
});
BuildContext.CakeContext.Information("Step 2 / 4: Adding assets to the release (not supported yet)");
// Not yet supported
if (!BuildContext.General.IsOfficialBuild)
{
BuildContext.CakeContext.Information("GitHub release publishing only runs against non-prerelease builds");
}
else
{
BuildContext.CakeContext.Information("Step 3 / 4: Publishing release");
BuildContext.CakeContext.GitReleaseManagerPublish(ApiKey, OwnerName, ProjectName, BuildContext.General.Version.MajorMinorPatch, new GitReleaseManagerPublishSettings
{
TargetDirectory = BuildContext.General.RootDirectory
});
BuildContext.CakeContext.Information("Step 4 / 4: Closing the milestone");
BuildContext.CakeContext.GitReleaseManagerClose(ApiKey, OwnerName, ProjectName, BuildContext.General.Version.MajorMinorPatch, new GitReleaseManagerCloseMilestoneSettings
{
TargetDirectory = BuildContext.General.RootDirectory
});
}
BuildContext.CakeContext.Information("Released version in GitHub");
}
}