Skip to content

Commit 386e694

Browse files
authored
Add token and login+password authentication (#8)
* Add token and login+password authentication * readme
1 parent 703dcfc commit 386e694

File tree

10 files changed

+61
-10
lines changed

10 files changed

+61
-10
lines changed

Chocolatey/GitHubReleaseNotes/GitHubReleaseNotes.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Refe
2626
<!-- version should MATCH as closely as possible with the underlying software -->
2727
<!-- Is the version a prerelease of a version? https://docs.nuget.org/create/versioning#creating-prerelease-packages -->
2828
<!-- Note that unstable versions like 0.0.1 can be considered a released version, but it's possible that one can release a 0.0.1-beta before you release a 0.0.1 version. If the version number is final, that is considered a released version and not a prerelease. -->
29-
<version>1.0.3.0</version>
29+
<version>1.0.4.0</version>
3030
<!-- <packageSourceUrl>Where is this Chocolatey package located (think GitHub)? packageSourceUrl is highly recommended for the community feed</packageSourceUrl>-->
3131
<!-- owners is a poor name for maintainers of the package. It sticks around by this name for compatibility reasons. It basically means you. -->
3232
<owners>Stef Heyenrath</owners>
Binary file not shown.

Chocolatey/GitHubReleaseNotes/generate.linq

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ To verify this package, follow these steps:
3838
3939
Note that this application is build with the .NET 4.5.2 framework and uses Fody and Fody.Costura to include all dependencies to generate a single exe file.";
4040

41-
File.WriteAllText(Path.Combine(chocolateyFolder, "tools", "VERIFICATION.txt"), text, Encoding.UTF8);
41+
File.WriteAllText(Path.Combine(chocolateyFolder, "tools", "VERIFICATION.txt"), text, Encoding.UTF8);
42+
43+
"Done".Dump();

Chocolatey/GitHubReleaseNotes/tools/VERIFICATION.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
To verify this package, follow these steps:
44

55
1] Right click the GitHubReleaseNotes.exe in Windows file explorer and go to the "Details" tab and check the following properties:
6-
- File version 1.0.3.0
6+
- File version 1.0.4.0
77
- Product name GitHubReleaseNotes
88
- Copyright Stef Heyenrath
9-
- Size 1062912 bytes
9+
- Size 1063424 bytes
1010
- Original filename GitHubReleaseNotes.exe
1111

1212
2] Verify the SHA256 from the GitHubReleaseNotes.exe file (7zip can be used for this)
13-
- SHA256 E5E5BD299169D9F99CA4023BBF7FEE99AA3F6C8F7249BE69D94569B4D43FB6DE
13+
- SHA256 193FF97037962C9C996A82DF67D3C2C3E4246B08EFAE88ED7EC79C6AE9C4A12C
1414

1515

1616
Note that this application is build with the .NET 4.5.2 framework and uses Fody and Fody.Costura to include all dependencies to generate a single exe file.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</PropertyGroup>
55

66
<PropertyGroup>
7-
<Version>1.0.3.0</Version>
7+
<Version>1.0.4.0</Version>
88
<Description>Generate Release Notes from a GitHub project.</Description>
99
<Summary>Generate Release Notes from a GitHub project.</Summary>
1010
<Authors>Stef Heyenrath</Authors>

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Arguments:
2424
- `--language`: Provide the language (two letter according to [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1)) which is used to format the dates. If not provided, "en" is used. It's also possible to use a value like "system", which takes the current system ui language.
2525
- `--skip-empty-releases`: Define this optional argument to skip writing releases which have no associated Issues or Pull Requests.
2626
- `--template`: Provide a custom Handlebars template instead of the default template to generate the Release Notes.
27+
- `--token`: Provide the GitHub API token as authentication for connecting to private repositories. **@**
28+
- `--login` and `--password`: Provide the GitHub API login and password as authentication for connecting to private repositories. **@**
29+
30+
**@** you only can use one authentication method
2731

2832
## Output
2933
The generated Release Notes ([Markdown](https://en.wikipedia.org/wiki/Markdown) formatted) will look like:
@@ -41,7 +45,7 @@ This project is based on [GitTools/GitReleaseNotes](https://github.com/GitTools/
4145

4246
### Dependencies
4347
- [Oktokit](https://github.com/octokit/octokit.net)
44-
- [LibGit2Sharp](https://github.com/libgit2/libgit2sharp)
48+
- [LibGit2Sharp.Portable](https://github.com/aarnott/libgit2sharp)
4549
- [Handlebars.Net](https://github.com/rexm/Handlebars.Net)
4650
- [Fody](https://github.com/Fody/Fody)
4751
- [Fody.Costura](https://github.com/Fody/Costura)

src/GitHubReleaseNotes.Logic/Configuration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ public class Configuration
1515
public bool SkipEmptyReleases { get; set; }
1616

1717
public string TemplatePath { get; set; }
18+
19+
public string Login { get; set; }
20+
21+
public string Password { get; set; }
22+
23+
public string Token { get; set; }
1824
}
1925
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using Octokit;
3+
4+
namespace GitHubReleaseNotes.Logic
5+
{
6+
internal static class GitHubClientFactory
7+
{
8+
private const string AppName = "GitHubReleaseNotes";
9+
10+
public static IGitHubClient CreateClient(Configuration configuration)
11+
{
12+
if (configuration == null)
13+
{
14+
throw new ArgumentNullException(nameof(configuration));
15+
}
16+
17+
var client = CreateClient();
18+
19+
if (!string.IsNullOrEmpty(configuration.Token))
20+
{
21+
client.Credentials = new Credentials(configuration.Token);
22+
}
23+
else if (!string.IsNullOrEmpty(configuration.Login) && !string.IsNullOrEmpty(configuration.Password))
24+
{
25+
client.Credentials = new Credentials(configuration.Login, configuration.Password);
26+
}
27+
28+
return client;
29+
}
30+
31+
private static GitHubClient CreateClient()
32+
{
33+
return new GitHubClient(new ProductHeaderValue(AppName));
34+
}
35+
}
36+
}

src/GitHubReleaseNotes.Logic/RepositoryHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public class RepositoryHelper
1414
private const int DeltaSeconds = 30;
1515

1616
private readonly Configuration _configuration;
17-
private readonly GitHubClient _client;
17+
private readonly IGitHubClient _client;
1818

1919
public RepositoryHelper(Configuration configuration)
2020
{
2121
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
2222

23-
_client = new GitHubClient(new ProductHeaderValue("GitHubReleaseNotes"));
23+
_client = GitHubClientFactory.CreateClient(_configuration);
2424
}
2525

2626
internal async Task<IEnumerable<ReleaseInfo>> GetReleaseInfoAsync()

src/GitHubReleaseNotes/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ private static Configuration ParseConfiguration(string[] args)
3333
Culture = parser.GetCultureInfo("language"),
3434
Version = parser.GetStringValue("version", "next"),
3535
TemplatePath = parser.GetStringValue("template"),
36-
SkipEmptyReleases = parser.GetBoolValue("skip-empty-releases") || parser.Contains("skip-empty-releases") // "--skip-empty-releases true" and "--skip-empty-releases" both qualify
36+
SkipEmptyReleases = parser.GetBoolValue("skip-empty-releases") || parser.Contains("skip-empty-releases"), // "--skip-empty-releases true" and "--skip-empty-releases" both qualify
37+
Token = parser.GetStringValue("token"),
38+
Login = parser.GetStringValue("login"),
39+
Password = parser.GetStringValue("password")
3740
};
3841
}
3942
}

0 commit comments

Comments
 (0)