Skip to content
Snippets Groups Projects
Commit dc736cba authored by L. Ellenbeck's avatar L. Ellenbeck
Browse files

Merge branch 'Topic/570-gitVersion' into 'master'

Fix: hopefully

See merge request coscine/cs/exampleproject!13
parents 44bbb1bf c727d837
Branches
No related tags found
1 merge request!13Fix: hopefully
......@@ -5,6 +5,9 @@
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.FileHelpers&version=3.2.1
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Http&version=0.7.0
using System.Net;
using System.Net.Http;
// Commandline arguments
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
......@@ -89,12 +92,12 @@ Task("Test")
});
Task("GitVersion")
.WithCriteria(string.IsNullOrWhiteSpace(version))
.Does(() => {
if(string.IsNullOrWhiteSpace(version)) {
version = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = false
}).NuGetVersionV2;
}
var index = version.IndexOf("-");
semanticVersion = index > 0 ? version.Substring(0, index) : version;
Information($"Version: {version}, SemanticVersion: {semanticVersion}");
......@@ -220,7 +223,7 @@ IEnumerable<string> redirectedStandardOutput;
description += "\n";
}
}
// create tag
var settings = new HttpSettings
{
Headers = new Dictionary<string, string>
......@@ -230,24 +233,17 @@ IEnumerable<string> redirectedStandardOutput;
EnsureSuccessStatusCode = true,
};
settings.SetJsonRequestBody("{}");
var responseBody = HttpPost($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/repository/tags?tag_name=v{semanticVersion}&ref=master&release_description={description}", settings);
Information("Create tag: {0}", responseBody);
// create tag
var client = new HttpClient();
client.DefaultRequestHeaders.Add("PRIVATE-TOKEN", gitlabToken);
var result = client.PostAsync($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/repository/tags?tag_name=v{semanticVersion}&ref=master", null).Result;
Information("Create tag: {0}", result.Content.ReadAsStringAsync().Result);
// create release
settings = new HttpSettings
{
Headers = new Dictionary<string, string>
{
{"PRIVATE-TOKEN", gitlabToken},
},
EnsureSuccessStatusCode = true,
};
var json = $"{{\"name\": \"v{semanticVersion}\", \"tag_name\": \"v{semanticVersion}\" \"description\": \"{description}\"}}";
settings.SetJsonRequestBody(json);
responseBody = HttpPost($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/releases", settings);
Information("Create release: {0}", responseBody);
var json = $"{{\"name\": \"v{semanticVersion}\", \"tag_name\": \"v{semanticVersion}\", \"description\": \"{description}\"}}";
var content = new StringContent(json, Encoding.ASCII, "application/json");
result = client.PostAsync($"https://git.rwth-aachen.de/api/v4/projects/{gitlabProjectId}/releases", content).Result;
Information("Create release: {0}", result.Content.ReadAsStringAsync().Result);
});
Task("Build")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment