Skip to content

Commit

Permalink
Merge pull request #84 from mateuszskoczek/features/github_actions
Browse files Browse the repository at this point in the history
Features/GitHub actions
  • Loading branch information
mateuszskoczek authored Apr 23, 2024
2 parents 8f34f7c + c4710b5 commit 774f438
Show file tree
Hide file tree
Showing 47 changed files with 724 additions and 335 deletions.
9 changes: 8 additions & 1 deletion .github/config/gitversion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
next-version: 2.0
next-version: 1.0.0
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch

Expand All @@ -9,3 +9,10 @@ branches:
increment: Patch
tag: ''
is-release-branch: true
test:
regex: ^features
mode: ContinuousDelivery
increment: Patch
tag: ''
is-release-branch: true
source-branches: []
66 changes: 66 additions & 0 deletions .github/workflows/push_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and publish application on master push


on:
push:
branches:
- "master"
- "features/github_actions"
#paths:
#- "VDownload**"


jobs:
build:
name: Build
runs-on: windows-latest
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.com
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: 5.x
- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.9.7
id: gitversion
with:
useConfigFile: true
configFilePath: .github/config/gitversion.yml
- name: Set version in VDownload.csproj file
id: package_version
uses: KageKirin/set-csproj-version@v0
with:
file: VDownload/VDownload.csproj
version: ${{steps.gitversion.outputs.SemVer}}
- name: Set version in Package.appxmanifest file
uses: Nambers/ReplaceStringInFile@v1.3
with:
path: VDownload/Package.appxmanifest
oldString: 0\.0\.0\.0
newString: ${{steps.gitversion.outputs.SemVer}}.0
showFileContent: true
escapeBackslash: true
- name: Set version in app.manifest file
uses: Nambers/ReplaceStringInFile@v1.3
with:
path: VDownload/app.manifest
oldString: 0\.0\.0\.0
newString: ${{steps.gitversion.outputs.SemVer}}.0
showFileContent: true
escapeBackslash: true
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Build application
run: dotnet build -o build
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: build
path: build
41 changes: 41 additions & 0 deletions VDownload.Core/VDownload.Core.Strings/StringResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Windows.ApplicationModel.Resources;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace VDownload.Core.Strings
{
public class StringResource
{
#region FIELDS

protected ResourceLoader _resourceLoader;

#endregion



#region CONSTRUCTORS

internal StringResource(ResourceLoader resourceLoader)
{
_resourceLoader = resourceLoader;
}

#endregion



#region PUBLIC METHODS

public string Get(string key)
{
return _resourceLoader.GetString(key);
}

#endregion
}
}
57 changes: 57 additions & 0 deletions VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.UI.Xaml;
using Windows.ApplicationModel.Resources;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace VDownload.Core.Strings
{
public static class StringResourcesManager
{
#region PROPERTIES

public static StringResource BaseView { get; } = BuildResource("BaseViewResources");
public static StringResource HomeView { get; } = BuildResource("HomeViewResources");
public static StringResource HomeVideoView { get; } = BuildResource("HomeVideoViewResources");
public static StringResource HomeVideoCollectionView { get; } = BuildResource("HomeVideoCollectionViewResources");
public static StringResource HomeDownloadsView { get; } = BuildResource("HomeDownloadsViewResources");
public static StringResource AuthenticationView { get; } = BuildResource("AuthenticationViewResources");
public static StringResource Notifications { get; } = BuildResource("NotificationsResources");
public static StringResource Search { get; } = BuildResource("SearchResources");
public static StringResource Common { get; } = BuildResource("CommonResources");
public static StringResource DialogButtons { get; } = BuildResource("DialogButtonsResources");
public static StringResource SettingsView { get; } = BuildResource("SettingsViewResources");
public static StringResource FilenameTemplate { get; } = BuildResource("FilenameTemplateResources");
public static StringResource AboutView { get; } = BuildResource("AboutViewResources");
public static StringResource SubscriptionsView { get; } = BuildResource("SubscriptionsViewResources");

#endregion



#region PRIVATE METHODS

private static StringResource BuildResource(string resourceName)
{
File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"teststring {resourceName}\n");
ResourceLoader loader;
try
{
loader = new ResourceLoader($"VDownload.Core.Strings/{resourceName}");
File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"afterteststring {resourceName}\n");
}
catch (Exception e)
{

File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"teststringerror {e.Message}\n");
throw;
}
return new StringResource(loader);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,48 @@
</ItemGroup>

<ItemGroup>
<PRIResource Update="Strings\en-US\AboutViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\AuthenticationViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\BaseViewResources.resw">
<Generator></Generator>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\CommonResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\DialogButtonsResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\FilenameTemplateResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\HomeDownloadsViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\HomeVideoCollectionViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\HomeVideoViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\HomeViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\NotificationsResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\SearchResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\SettingsViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
<PRIResource Update="Strings\en-US\SubscriptionsViewResources.resw">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</PRIResource>
</ItemGroup>
</Project>
22 changes: 10 additions & 12 deletions VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
using Windows.Storage;
using System.IO;
using VDownload.Services.UI.Notifications;
using VDownload.Services.UI.StringResources;
using System.Collections.Generic;
using System.Net.Http;
using Instances.Exceptions;
using FFMpegCore.Exceptions;
using VDownload.Core.Strings;

namespace VDownload.Core.Tasks
{
Expand All @@ -39,7 +39,6 @@ private enum TaskResult
protected readonly IConfigurationService _configurationService;
protected readonly ISettingsService _settingsService;
protected readonly IFFmpegService _ffmpegService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly INotificationsService _notificationsService;

#endregion
Expand Down Expand Up @@ -87,12 +86,11 @@ private enum TaskResult

#region CONSTRUCTORS

internal DownloadTask(Video video, VideoDownloadOptions downloadOptions, IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, IStringResourcesService stringResourcesService, INotificationsService notificationsService)
internal DownloadTask(Video video, VideoDownloadOptions downloadOptions, IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, INotificationsService notificationsService)
{
_configurationService = configurationService;
_settingsService = settingsService;
_ffmpegService = ffmpegService;
_stringResourcesService = stringResourcesService;
_notificationsService = notificationsService;

_video = video;
Expand Down Expand Up @@ -165,8 +163,8 @@ private async Task Download()

List<string> content = new List<string>()
{
$"{_stringResourcesService.NotificationsResources.Get("Title")}: {Video.Title}",
$"{_stringResourcesService.NotificationsResources.Get("Author")}: {Video.Author}"
$"{StringResourcesManager.Notifications.Get("Title")}: {Video.Title}",
$"{StringResourcesManager.Notifications.Get("Author")}: {Video.Author}"
};

string errorMessage = null;
Expand Down Expand Up @@ -222,15 +220,15 @@ private async Task Download()

if (ex is TaskCanceledException || ex is HttpRequestException)
{
message = _stringResourcesService.HomeDownloadsViewResources.Get("ErrorDownloadingTimeout");
message = StringResourcesManager.HomeDownloadsView.Get("ErrorDownloadingTimeout");
}
else if (ex is InstanceFileNotFoundException)
{
message = _stringResourcesService.HomeDownloadsViewResources.Get("ErrorFFmpegPath");
message = StringResourcesManager.HomeDownloadsView.Get("ErrorFFmpegPath");
}
else if (ex is FFMpegException)
{
message = _stringResourcesService.HomeDownloadsViewResources.Get("ErrorFFmpeg");
message = StringResourcesManager.HomeDownloadsView.Get("ErrorFFmpeg");
}
else
{
Expand All @@ -249,15 +247,15 @@ private async Task Download()
case TaskResult.Error:
if (_settingsService.Data.Common.Notifications.OnUnsuccessful)
{
string title = _stringResourcesService.NotificationsResources.Get("OnUnsuccessfulTitle");
content.Add($"{_stringResourcesService.NotificationsResources.Get("Message")}: {errorMessage}");
string title = StringResourcesManager.Notifications.Get("OnUnsuccessfulTitle");
content.Add($"{StringResourcesManager.Notifications.Get("Message")}: {errorMessage}");
_notificationsService.SendNotification(title, content);
}
break;
case TaskResult.Success:
if (_settingsService.Data.Common.Notifications.OnSuccessful)
{
string title = _stringResourcesService.NotificationsResources.Get("OnSuccessfulTitle");
string title = StringResourcesManager.Notifications.Get("OnSuccessfulTitle");
_notificationsService.SendNotification(title, content);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using VDownload.Services.Data.Configuration;
using VDownload.Services.Data.Settings;
using VDownload.Services.UI.Notifications;
using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.FFmpeg;

namespace VDownload.Core.Tasks
Expand All @@ -26,7 +25,6 @@ public class DownloadTaskFactoryService : IDownloadTaskFactoryService
protected readonly IConfigurationService _configurationService;
protected readonly ISettingsService _settingsService;
protected readonly IFFmpegService _ffmpegService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly INotificationsService _notificationsService;

#endregion
Expand All @@ -35,12 +33,11 @@ public class DownloadTaskFactoryService : IDownloadTaskFactoryService

#region CONSTRUCTORS

public DownloadTaskFactoryService(IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, IStringResourcesService stringResourcesService, INotificationsService notificationsService)
public DownloadTaskFactoryService(IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, INotificationsService notificationsService)
{
_configurationService = configurationService;
_settingsService = settingsService;
_ffmpegService = ffmpegService;
_stringResourcesService = stringResourcesService;
_notificationsService = notificationsService;
}

Expand All @@ -52,7 +49,7 @@ public DownloadTaskFactoryService(IConfigurationService configurationService, IS

public DownloadTask Create(Video video, VideoDownloadOptions downloadOptions)
{
return new DownloadTask(video, downloadOptions, _configurationService, _settingsService, _ffmpegService, _stringResourcesService, _notificationsService);
return new DownloadTask(video, downloadOptions, _configurationService, _settingsService, _ffmpegService, _notificationsService);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.Notifications\VDownload.Services.UI.Notifications.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.StringResources\VDownload.Services.UI.StringResources.csproj" />
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.FFmpeg\VDownload.Services.Utility.FFmpeg.csproj" />
<ProjectReference Include="..\VDownload.Core.Strings\VDownload.Core.Strings.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 774f438

Please sign in to comment.