forked from microsoft/appcenter-sdk-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-release.cake
58 lines (52 loc) · 2.29 KB
/
git-release.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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#addin nuget:?package=Cake.FileHelpers&version=3.0.0
#addin nuget:?package=Cake.Git&version=0.18.0
#addin nuget:?package=Cake.Incubator&version=2.0.2
#tool "nuget:?package=gitreleasemanager"
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using System.Xml.XPath;
// Task TARGET for build
var TARGET = Argument("target", Argument("t", "Default"));
Task("Default").IsDependentOn("GitRelease");
// Create a tag and release on GitHub
Task("GitRelease")
.Does(() =>
{
// Use the package version for AppCenter package as the release version.
var nuspecPathPrefix = EnvironmentVariable("NUSPEC_PATH", "nuget");
var nuspecPath = System.IO.Path.Combine(nuspecPathPrefix, "AppCenter.nuspec");
var nuspecXml = XDocument.Load(nuspecPath);
var publishVersion = nuspecXml.XPathSelectElement("/package/metadata/version").Value;
// Create temporary release notes.
var releaseNotesFileName = "tempRelease.md";
System.IO.File.Create(releaseNotesFileName).Dispose();
var releaseFile = File(releaseNotesFileName);
FileWriteText(releaseFile,"Please update description. It will be pulled out automatically from release.md next time.");
// Build a string containing paths to NuGet packages.
var files = GetFiles("../../**/Microsoft.AppCenter*.nupkg");
var assets = string.Empty;
foreach (var file in files)
{
assets += file.FullPath + ",";
}
assets = assets.Substring(0,assets.Length-1);
var username = "user";
var password = Argument<string>("GithubToken");
var owner = "Microsoft";
var repo = "appcenter-sdk-dotnet";
GitReleaseManagerCreate(username, password,owner, repo,
new GitReleaseManagerCreateSettings {
Prerelease = true,
Assets = assets,
TargetCommitish = "master",
InputFilePath = releaseFile.Path.FullPath,
Name = publishVersion
});
GitReleaseManagerPublish(username, password, owner, repo, publishVersion);
DeleteFile(releaseFile);
});
RunTarget(TARGET);