Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signing #21

Merged
merged 23 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,53 +40,54 @@ jobs:
- name: Create the package
run: dotnet publish --configuration Release ${Solution_Name} --self-contained false -p:PublishSingleFile=True -p:PublishReadyToRun=False --output bin\fire\out

- name: Zip Release
uses: vimtor/[email protected]
with:
files: bin\fire\out
recursive: true
dest: dlssupdater.zip

- name: Get version of the project
id: project-version
uses: 'euberdeveloper/ga-project-version@main'
with:
path: DlssUpdater\version.json

- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build artifact
id: Artifact
uses: actions/upload-artifact@v4
with:
tag_name: v${{ steps.project-version.outputs.version }}
release_name: v${{ steps.project-version.outputs.version }}
draft: false
prerelease: false
name: release
path: bin\fire\out

- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sign the artifact
id: Signing
uses: signpath/github-action-submit-signing-request@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dlssupdater.zip
asset_name: dlssupdater.zip
asset_content_type: application/zip

- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '755fc32c-cfd8-4e3a-9ece-1a337dd6e8c3'
project-slug: 'DlssUpdater'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{steps.Artifact.outputs.artifact-id}}'
wait-for-completion: true
output-artifact-directory: './signed-artifacts'
parameters: |
Version: ${{ toJSON(steps.project-version.outputs.version) }}
Release_Tag: "v${{ steps.project-version.outputs.version }}"

- name: Zip Release
uses: vimtor/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./DlssUpdater/version.json
asset_name: version.json
asset_content_type: application/json
files: ./signed-artifacts
recursive: true
dest: dlssupdater.zip

- uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v2
with:
release_id: ${{ steps.create_release.outputs.id }}
# with permissions to create releases in the other repo
token: ${{ secrets.GITHUB_TOKEN }}
name: v${{ steps.project-version.outputs.version }}
tag_name: v${{ steps.project-version.outputs.version }}
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
./DlssUpdater/version.json
./dlssupdater.zip

- uses: sarisia/actions-status-discord@v1
if: success()
Expand All @@ -98,4 +99,3 @@ jobs:
Version `${{ steps.project-version.outputs.version }}`
Download directly inside `Dlss Updater` or [here](${{ steps.create_release.outputs.html_url }}).
color: 0xff91a4

6 changes: 6 additions & 0 deletions DlssUpdater/GameLibrary/EpicGames/EpicGamesLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace DLSSUpdater.GameLibrary.EpicGames;

public class EpicGamesLibrary : ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>>? LoadingProgress;
private readonly NLog.Logger _logger;
private readonly LibraryConfig _config;

Expand Down Expand Up @@ -94,13 +95,18 @@ private async Task<List<GameInfo>> getGames()
List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
var files = Directory.GetFiles(path);
var amount = files.Length;
var current = 0;
foreach (var file in files)
{
var task = Task.Run(async () =>
{
// do an async wait until we can schedule again
await throttler.WaitAsync();

current += 1;
LoadingProgress?.Invoke(this, new(current, amount, GetLibraryType()));

var data = await File.ReadAllBytesAsync(file);
var yourObject = JsonDocument.Parse(data);

Expand Down
6 changes: 6 additions & 0 deletions DlssUpdater/GameLibrary/GOGLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace DLSSUpdater.GameLibrary;

public class GOGLibrary : ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>>? LoadingProgress;
private readonly NLog.Logger _logger;
private readonly LibraryConfig _config;

Expand Down Expand Up @@ -54,6 +55,8 @@ private async Task<List<GameInfo>> getGames()

List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
var amount = subKeys.Length;
var current = 0;
foreach (var subKey in subKeys)
{
var task = Task.Run(async () =>
Expand All @@ -63,6 +66,9 @@ private async Task<List<GameInfo>> getGames()
// do an async wait until we can schedule again
await throttler.WaitAsync();

current += 1;
LoadingProgress?.Invoke(this, new(current, amount, GetLibraryType()));

var gameKey = hklm.OpenSubKey(Path.Combine(@"SOFTWARE\GOG.com\Games", subKey));
if (gameKey == null)
{
Expand Down
1 change: 1 addition & 0 deletions DlssUpdater/GameLibrary/ILibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum LibraryType

public interface ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>>? LoadingProgress;
public LibraryType GetLibraryType();
public void GetInstallationDirectory();
public Task<List<GameInfo>> GatherGamesAsync();
Expand Down
1 change: 1 addition & 0 deletions DlssUpdater/GameLibrary/ManualLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace DlssUpdater.GameLibrary;

public class ManualLibrary : ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>> LoadingProgress;
public ManualLibrary(LibraryConfig config, NLog.Logger logger)
{

Expand Down
15 changes: 13 additions & 2 deletions DlssUpdater/GameLibrary/Steam/SteamLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using DlssUpdater.Helpers;
using DLSSUpdater.Defines;
using DLSSUpdater.Helpers;
Expand All @@ -9,6 +10,8 @@ namespace DlssUpdater.GameLibrary.Steam;

public class SteamLibrary : ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>>? LoadingProgress;

private readonly NLog.Logger _logger;
private readonly LibraryConfig _config;

Expand Down Expand Up @@ -103,6 +106,9 @@ private async Task<List<GameInfo>> getGames(List<LibraryFolder> folder)

var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);

int amount = folder.Sum(folderItem => folderItem.Apps.Count);
int current = 0;

foreach (var folderItem in folder)
{
foreach (var app in folderItem.Apps)
Expand All @@ -112,6 +118,9 @@ private async Task<List<GameInfo>> getGames(List<LibraryFolder> folder)
// do an async wait until we can schedule again
await throttler.WaitAsync();

current += 1;
LoadingProgress?.Invoke(this, new (current, amount, GetLibraryType()));

var appPath = Path.Combine(folderItem.Path, $"appmanifest_{app}.acf");
if (!File.Exists(appPath))
{
Expand All @@ -134,7 +143,9 @@ private async Task<List<GameInfo>> getGames(List<LibraryFolder> folder)
}

await Task.WhenAll(tasks);

ret = ret.GroupBy(g => g.GamePath)
.Select(g => g.First())
.ToList();
return ret;
}

Expand Down
6 changes: 6 additions & 0 deletions DlssUpdater/GameLibrary/UbisoftConnectLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace DlssUpdater.GameLibrary;

public class UbisoftConnectLibrary : ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>>? LoadingProgress;
private readonly LibraryConfig _config;
private readonly NLog.Logger _logger;

Expand Down Expand Up @@ -65,6 +66,8 @@ private async Task<List<GameInfo>> getGames()
var entries = data.Split("root:", StringSplitOptions.TrimEntries);
List<Task> tasks = [];
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
var amount = entries.Length;
var current = 0;
foreach (var entry in entries)
{
var task = Task.Run(async () =>
Expand All @@ -74,6 +77,9 @@ private async Task<List<GameInfo>> getGames()
// do an async wait until we can schedule again
await throttler.WaitAsync();

current += 1;
LoadingProgress?.Invoke(this, new(current, amount, GetLibraryType()));

var result = entry
.Split("\n")
.Select(x => x.Split(':'))
Expand Down
8 changes: 8 additions & 0 deletions DlssUpdater/GameLibrary/XboxLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace DlssUpdater.GameLibrary;

public class XboxLibrary : ILibrary
{
public event EventHandler<Tuple<int, int, LibraryType>> LoadingProgress;
private readonly LibraryConfig _config;
private readonly NLog.Logger _logger;

Expand Down Expand Up @@ -45,6 +46,9 @@ private async Task<List<GameInfo>> getGames()
var throttler = new SemaphoreSlim(initialCount: Settings.Constants.CoreCount);
List<GameInfo> ret = [];

var amount = 0;
var current = 0;

var drive = DriveInfo.GetDrives();
foreach (var driveItem in drive)
{
Expand Down Expand Up @@ -83,8 +87,12 @@ private async Task<List<GameInfo>> getGames()
}

var gameDirs = Directory.GetDirectories(gamePath);
amount += gameDirs.Length;
foreach (var gameDir in gameDirs)
{
current += 1;
LoadingProgress?.Invoke(this, new(current, amount, GetLibraryType()));

var manifestPath = Path.Combine(gameDir, "Content", "appxmanifest.xml");
if (!File.Exists(manifestPath))
{
Expand Down
Loading
Loading