Skip to content

Commit

Permalink
Merge branch 'Suplanus:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPa authored Sep 5, 2023
2 parents 3ce5ddd + f93f702 commit a1e33ad
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.0.1](https://github.com/Suplanus/GitHubReleaser/releases/tag/1.0.1.103)

`Build: 103 | Date (UTC): 2020-11-17 10:29`

#### Bugs:
- [Timeout on large assets](https://github.com/Suplanus/GitHubReleaser/issues/12)

## [1.0.0](https://github.com/Suplanus/GitHubReleaser/releases/tag/1.0.0.0)

`Build: 0 | Date (UTC): 2020-11-06 11:24`
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Combining config file with commandline arguments is not supported yet.
| `delete-files-after-upload` | _false_ | |


## Json Example
## Config file example

```json
{
Expand Down Expand Up @@ -77,4 +77,6 @@ With a test milestone and some test issues you can simple run throw the steps:

## Contributing
Feel free to make a pull-request 🦄
Or simple make an issue for a bug report or feature request 💖
Or simple make an issue for a bug report or feature request 💖

Thanks to [Daniel Papp](https://github.com/DanielPa) for being a first class contributer.
20 changes: 18 additions & 2 deletions src/GitHubReleaser/GitHubReleaser.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;netcoreapp3.1</TargetFrameworks>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<Version>1.0.0.0</Version>
<Version>1.0.1.101</Version>
<LangVersion>latest</LangVersion>
<AssemblyVersion>1.0.1.103</AssemblyVersion>
<FileVersion>1.0.1.103</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net48|AnyCPU'">
<ShouldCreateLogs>True</ShouldCreateLogs>
<AdvancedSettingsExpanded>True</AdvancedSettingsExpanded>
<UpdateAssemblyVersion>True</UpdateAssemblyVersion>
<UpdateAssemblyFileVersion>True</UpdateAssemblyFileVersion>
<UpdateAssemblyInfoVersion>True</UpdateAssemblyInfoVersion>
<AssemblyVersionSettings>None.None.None.Increment</AssemblyVersionSettings>
<UpdatePackageVersion>False</UpdatePackageVersion>
<AssemblyInfoVersionType>SettingsVersion</AssemblyInfoVersionType>
<InheritWinAppVersionFrom>None</InheritWinAppVersionFrom>
<AssemblyFileVersionSettings>None.None.None.Increment</AssemblyFileVersionSettings>
<AssemblyInfoVersionSettings>None.None.None.Increment</AssemblyInfoVersionSettings>
<PrimaryVersionType>AssemblyVersionAttribute</PrimaryVersionType>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 1 addition & 7 deletions src/GitHubReleaser/Model/ChangelogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ internal async Task Set()
var releases = await _releaser.Client.Repository.Release.GetAll(_releaser.Account, _releaser.Repo);
foreach (var release in releases.OrderByDescending(obj => obj.CreatedAt.Date))
{
if (release.Draft)
{
continue;
}

var version = new Version(release.Name);
var versionToDisplay = $"{version.Major}.{version.Minor}.{version.Build}";
var dateTime = release.CreatedAt.DateTime.ToUniversalTime();
Expand Down Expand Up @@ -182,8 +177,7 @@ internal async Task Set()
RepositoryContent content = contents.FirstOrDefault(obj => obj.Path.Equals(path));
if (content == null)
{
Log.Error("Changelog.md not found");
Environment.Exit(160);
ErrorHandler.Log("Changelog.md not found");
}

await _releaser.Client.Repository.Content.CreateFile(
Expand Down
13 changes: 13 additions & 0 deletions src/GitHubReleaser/Model/ErrorHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace GitHubReleaser.Model
{
internal class ErrorHandler
{
public static void Log(string errorMessage)
{
Serilog.Log.Error(errorMessage);
throw new Exception(errorMessage);
}
}
}
9 changes: 4 additions & 5 deletions src/GitHubReleaser/Model/ReleaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public async Task<Release> UpdateRelease()
Release release = releases.FirstOrDefault(obj => obj.Name.Equals(_releaser.VersionFull));
if (release == null)
{
Log.Error("Release to update not found");
Environment.Exit(160);
ErrorHandler.Log("Release to update not found");
}

ReleaseUpdate updateRelease = release.ToUpdate();
Expand All @@ -50,8 +49,7 @@ public async Task<Release> CreateRelease()
var release = releases.FirstOrDefault(obj => obj.Name.Equals(_releaser.VersionFull));
if (release != null)
{
Log.Error("Release already extists. Please use update.");
Environment.Exit(160);
ErrorHandler.Log("Release already extists. Please use update.");
}

// Create
Expand Down Expand Up @@ -91,7 +89,8 @@ private async Task UploadAttachments(Release release)
{
FileName = assetFilename,
ContentType = "application/x-msdownload",
RawData = archiveContents
RawData = archiveContents,
Timeout = TimeSpan.FromHours(1) // Needed because there is a global timeout
};
await _releaser.Client.Repository.Release.UploadAsset(release, assetUpload);
}
Expand Down
29 changes: 15 additions & 14 deletions src/GitHubReleaser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ static async Task<int> Main(string[] args)
var commandLine = GetCommandline(args);

// Execute
Releaser releaser = new Releaser(commandLine);
await releaser.ExecuteAsync();

Log.Information("All looks good, have fun with your release!");

return 0;
try
{
Releaser releaser = new Releaser(commandLine);
await releaser.ExecuteAsync();
Log.Information("All looks good, have fun with your release!");
return 0;
}
catch
{
return 100;
}
}

private static CommandLineParameters GetCommandline(string[] args)
Expand All @@ -45,23 +50,20 @@ private static CommandLineParameters GetCommandline(string[] args)
// Checks
if (commandLineParameters.Result.HasErrors)
{
Log.Error($"Error in parameters: {commandLineParameters.Result.ErrorText}");
Environment.Exit(160);
ErrorHandler.Log($"Error in parameters: {commandLineParameters.Result.ErrorText}");
}

commandLineParameters.FileForVersion = Path.GetFullPath(commandLineParameters.FileForVersion);
if (!File.Exists(commandLineParameters.FileForVersion))
{
Log.Error($"File not exists: {commandLineParameters.FileForVersion}");
Environment.Exit(160);
ErrorHandler.Log($"File not exists: {commandLineParameters.FileForVersion}");
}

var extension = Path.GetExtension(commandLineParameters.FileForVersion)?.ToLower();
if (extension != ".dll" &&
extension != ".exe")
{
Log.Error($"File type not supported: {extension}");
Environment.Exit(160);
ErrorHandler.Log($"File type not supported: {extension}");
}

if (commandLineParameters.ReleaseAttachments != null)
Expand All @@ -73,8 +75,7 @@ private static CommandLineParameters GetCommandline(string[] args)
var attachment = commandLineParameters.ReleaseAttachments[index];
if (!File.Exists(attachment))
{
Log.Error($"Attachment file not found: {attachment}");
Environment.Exit(160);
ErrorHandler.Log($"Attachment file not found: {attachment}");
}
}
}
Expand Down

0 comments on commit a1e33ad

Please sign in to comment.