-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
1,855 additions
and
527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Dev Build | ||
|
||
on: | ||
push: | ||
branches: [ dev ] | ||
pull_request: | ||
branches: [ dev ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
- name: Install dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build -c Release --no-restore | ||
- name: Test | ||
run: dotnet test -c Release --no-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Release Build | ||
|
||
on: | ||
push: | ||
branches: [ release ] | ||
pull_request: | ||
branches: [ release ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
- name: Install dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build -c Release --no-restore | ||
- name: Test | ||
run: dotnet test -c Release --no-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
release: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v1 | ||
- name: Install dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build -c Release --no-restore /p:Version=${{ github.event.release.tag_name }} -p:PackageReleaseNotes="See https://github.com/Noggog/Synthesis/releases/tag/${{ github.event.release.tag_name }}" | ||
- name: Test | ||
run: dotnet test --no-build -c Release | ||
- name: Publish Synthesis GUI to Github | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
file: Synthesis.Bethesda.GUI/bin/Release/Synthesis.exe | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.event.release.tag_name }} | ||
- name: Publish Mutagen Synthesis to Github | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
file: Mutagen.Bethesda.Synthesis/bin/Release/Mutagen.Bethesda.Synthesis.${{ github.event.release.tag_name }}.nupkg | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.event.release.tag_name }} | ||
- name: Publish Synthesis Bethesda to Github | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
file: Synthesis.Bethesda/bin/Release/Synthesis.Bethesda.${{ github.event.release.tag_name }}.nupkg | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.event.release.tag_name }} | ||
- name: Publish Synthesis Execution to Github | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
file: Synthesis.Bethesda.Execution/bin/Release/Synthesis.Bethesda.Execution.${{ github.event.release.tag_name }}.nupkg | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.event.release.tag_name }} | ||
- name: Publish to Nuget.org | ||
run: dotnet nuget push **/*${{ github.event.release.tag_name }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --no-symbols true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
Synthesis.Bethesda.Execution/Patcher Runs/GithubPatcherRun.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using LibGit2Sharp; | ||
using Mutagen.Bethesda; | ||
using Noggog; | ||
using Synthesis.Bethesda.Execution.Patchers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reactive.Subjects; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Synthesis.Bethesda.Execution | ||
{ | ||
public class GithubPatcherRun : IPatcherRun | ||
{ | ||
public string Name { get; } | ||
private readonly string _nickname; | ||
private readonly string _remote; | ||
private readonly string _localDir; | ||
private readonly string _pathToSln; | ||
private readonly string _pathToProj; | ||
private readonly string _pathToExe; | ||
public SolutionPatcherRun? SolutionRun { get; private set; } | ||
|
||
private Subject<string> _output = new Subject<string>(); | ||
public IObservable<string> Output => _output; | ||
|
||
private Subject<string> _error = new Subject<string>(); | ||
public IObservable<string> Error => _error; | ||
|
||
public GithubPatcherRun(string nickname, string remote, string localDir, string pathToSln, string pathToProj, string pathToExe) | ||
{ | ||
_nickname = nickname; | ||
_remote = remote; | ||
_localDir = localDir; | ||
_pathToProj = pathToProj; | ||
_pathToSln = pathToSln; | ||
_pathToExe = pathToExe; | ||
Name = $"{nickname} => {remote} => {Path.GetFileNameWithoutExtension(pathToProj)}"; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
|
||
public async Task Prep(GameRelease release, CancellationToken? cancel = null) | ||
{ | ||
var prepResult = await PrepRepo(GetResponse<string>.Succeed(_remote), _localDir, cancel ?? CancellationToken.None); | ||
if (prepResult.Failed) | ||
{ | ||
throw new SynthesisBuildFailure(prepResult.Reason); | ||
} | ||
SolutionRun = new SolutionPatcherRun(_nickname, Path.Combine(_localDir, _pathToSln), Path.Combine(_localDir, _pathToProj), Path.Combine(_localDir, _pathToExe)); | ||
await SolutionRun.Prep(release, cancel).ConfigureAwait(false); | ||
} | ||
|
||
public async Task Run(RunSynthesisPatcher settings, CancellationToken? cancel = null) | ||
{ | ||
if (SolutionRun == null) | ||
{ | ||
throw new SynthesisBuildFailure("Expected Solution Run object did not exist."); | ||
} | ||
await SolutionRun.Run(settings, cancel).ConfigureAwait(false); | ||
} | ||
|
||
private static bool DeleteOldRepo(string localDir, GetResponse<string> remoteUrl) | ||
{ | ||
if (!Directory.Exists(localDir)) return false; | ||
var dirInfo = new DirectoryPath(localDir); | ||
if (remoteUrl.Failed) | ||
{ | ||
dirInfo.DeleteEntireFolder(); | ||
return false; | ||
} | ||
using var repo = new Repository(localDir); | ||
// If it's the same remote repo, don't delete | ||
if (repo.Network.Remotes.FirstOrDefault()?.Url.Equals(remoteUrl.Value) ?? false) return true; | ||
dirInfo.DeleteEntireFolder(); | ||
return false; | ||
} | ||
|
||
public static async Task<GetResponse<(string Remote, string Local)>> PrepRepo(GetResponse<string> remote, string localDir, CancellationToken cancel) | ||
{ | ||
try | ||
{ | ||
cancel.ThrowIfCancellationRequested(); | ||
if (DeleteOldRepo(localDir: localDir, remoteUrl: remote)) | ||
{ | ||
// Short circuiting deletion | ||
return GetResponse<(string Remote, string Local)>.Succeed((remote.Value, localDir), remote.Reason); | ||
} | ||
cancel.ThrowIfCancellationRequested(); | ||
if (remote.Failed) return GetResponse<(string Remote, string Local)>.Fail((remote.Value, string.Empty), remote.Reason); | ||
var clonePath = Repository.Clone(remote.Value, localDir); | ||
return GetResponse<(string Remote, string Local)>.Succeed((remote.Value, clonePath), remote.Reason); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return GetResponse<(string Remote, string Local)>.Fail((remote.Value, string.Empty), ex); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.