示例#1
0
		public bool Release(string repository, string oauthToken, string tagName, UploadFile[] files, string releaseNotesFile = null)
		{
			_repository = repository;
			_oauthToken = oauthToken;
			_tagName = tagName;
			_releaseNotesFile = releaseNotesFile;

			var client = new GitHubClient(new Octokit.ProductHeaderValue("GitTfsTasks"), CredentialStore).Release;
			var release = client.CreateRelease(Owner, RepositoryName, BuildReleaseData()).Result;
			IdRelease = release.Id;
			//BuildHelper.DisplayAndLog(string.Format("Created Release {0} at {1}", release.TagName, release.HtmlUrl));
			if (files != null && files.Length != 0)
			{
				UploadedAssets = UploadAll(client, release, files);
				//foreach (var item in UploadedAssets) BuildHelper.DisplayAndLog(string.Format("Uploaded {0}", item));
			}

			return true;
		}
示例#2
0
		private ReleaseAssetUpload BuildAssetUpload(UploadFile item)
		{
			return new ReleaseAssetUpload
				{
					ContentType = item.ContentType ?? "application/octet-stream",
					FileName = Path.GetFileName(item.Path),
					RawData = File.OpenRead(item.Path)
				};
		}
示例#3
0
		private string Upload(IReleasesClient client, Release release, UploadFile sourceItem)
		{
			var uploadedAsset = client.UploadAsset(release, BuildAssetUpload(sourceItem));
			return TaskItemFor(release, uploadedAsset);
		}