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