Skip to content

Commit

Permalink
Merge pull request #109 from XanatosX/develop
Browse files Browse the repository at this point in the history
Prepare release 1.2.0
  • Loading branch information
XanatosX authored Sep 24, 2023
2 parents 4636303 + 4ebb2c6 commit b6411f3
Show file tree
Hide file tree
Showing 92 changed files with 1,493 additions and 543 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
39 changes: 36 additions & 3 deletions .github/workflows/create-live-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
APPLICATION_PUBLISH_FOLDER: ./publish
PLUGIN_PUBLISH_FOLDER: ./publish/plugins
WINDOWS_ARTIFACT_NAME: WindowsBuildArtifact_x64
WINDOWS_INSTALLER_ARTIFACT_NAME: WindowsBuildArtifactInstaller_x64
LINUX_ARTIFACT_NAME: LinuxBuildArtifact_x64
RELEASE_ARTIFACT_FOLDER: artifacts

Expand Down Expand Up @@ -67,7 +68,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
# Important for using outputs in other steps https://tech.europace.de/post/github-actions-output-variables-how-to/#get-output-values-between-steps
Expand All @@ -89,6 +90,32 @@ jobs:
name: ${{ env.WINDOWS_ARTIFACT_NAME }}
path: ${{ env.APPLICATION_PUBLISH_FOLDER }}
if-no-files-found: error
create-windows-installer:
name: Create Windows installer
needs: ["create-windows-build", "build-version"]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.REF_CHECKOUT_BRANCH }}
lfs: true
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ env.RELEASE_ARTIFACT_FOLDER }}
- name: Create installer
shell: pwsh
run: |
mkdir ./result
./setup/windows/windowsSetup.ps1 -version ${{ needs.build-version.outputs.build-version }} -buildfolder "../../artifacts/${{ env.WINDOWS_ARTIFACT_NAME }}" -output ../../result
mkdir ${{ env.APPLICATION_PUBLISH_FOLDER }}
mv ./result/*.exe ${{ env.APPLICATION_PUBLISH_FOLDER }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.WINDOWS_INSTALLER_ARTIFACT_NAME }}
path: ${{ env.APPLICATION_PUBLISH_FOLDER }}
if-no-files-found: error
create-linux-build:
name: Create Linux build
needs: ["check-build", "build-version"]
Expand All @@ -101,7 +128,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Publish Application
Expand All @@ -124,7 +151,7 @@ jobs:
if-no-files-found: error
upload-release:
name: Upload Artifacts to release
needs: ["create-windows-build", "create-linux-build"]
needs: ["create-windows-installer", "create-linux-build"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -141,6 +168,11 @@ jobs:
zip -r $WINDOWS_ARTIFACT_NAME.zip ./*
mv $WINDOWS_ARTIFACT_NAME.zip ../
rm -rf ./../$WINDOWS_ARTIFACT_NAME
- name: Move Windows installer
run: |
cd ./$RELEASE_ARTIFACT_FOLDER/$WINDOWS_INSTALLER_ARTIFACT_NAME
mv ./*.exe ../
rm -rf ./../$WINDOWS_INSTALLER_ARTIFACT_NAME
- name: Zip Linux build
run: |
cd ./$RELEASE_ARTIFACT_FOLDER/$LINUX_ARTIFACT_NAME
Expand All @@ -156,4 +188,5 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.zip
gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.exe
#gh release upload ${{ GITHUB.REF_NAME }} ${{ env.RELEASE_ARTIFACT_FOLDER }}/*.nupkg
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,5 @@ $RECYCLE.BIN/
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json

**/result/*.exe
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

[![Recent develop build](https://github.com/XanatosX/ModularToolManager/actions/workflows/create-latest-develop-build.yml/badge.svg)](https://github.com/XanatosX/ModularToolManager/actions/workflows/create-latest-develop-build.yml)
[![Latest release](https://badgen.net/github/release/Naereen/Strapdown.js)](https://github.com/XanatosX/ModularToolManager/releases)
[![Github all releases](https://img.shields.io/github/downloads/Naereen/StrapDown.js/total.svg)](https://GitHub.com/XanatosX/ModularToolManager/releases/)
![GitHub all releases](https://img.shields.io/github/downloads/XanatosX/ModularToolManager/total)


[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a76b14fe59a54a9ab4d3e4f6afed53dc)](https://app.codacy.com/app/simonaberle/ModularToolManager?utm_source=github.com&utm_medium=referral&utm_content=XanatosX/ModularToolManager&utm_campaign=badger)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FXanatosX%2FModularToolManager.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FXanatosX%2FModularToolManager?ref=badge_shield)

[![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg)
[![Windows](https://svgshare.com/i/ZhY.svg)](https://svgshare.com/i/ZhY.svg)
![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)
![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white)

## Requirements

* [.NET Desktop Runtime 6.x.x][dotnet6]
* [.NET Desktop Runtime 7.x.x][dotnet7]

## About the Project

Expand All @@ -38,7 +39,9 @@ If you found a bug or need any help with the application please head over to the

## Installation

Right now there is only a zip file you can extract somewhere to your disc. Just follow the instructions for the nighty build.
You got two options to install the tool, either you use the installation as descripted in the `Latest nightly build` section by unzipping the zip file or use the installer if you are on a Windows machine.

To use the installer just download the `ModularToolManager_Installer_{version}.exe` file and run it on your machine.

I will try to add a windows installer later on.

Expand Down Expand Up @@ -87,6 +90,7 @@ Technically the plugin will run with the user rights you did start the applicati

[wiki]: https://github.com/XanatosX/ModularToolManager/wiki
[dotnet6]: https://dotnet.microsoft.com/en-us/download/dotnet/6.0
[dotnet7]: https://dotnet.microsoft.com/en-us/download/dotnet/7.0
[avaloniaui]: https://avaloniaui.net/
[image-main-view]: https://imgur.com/oswayay.png
[image-main-view-light]: https://i.imgur.com/lqmlo5U.png
Expand Down
64 changes: 64 additions & 0 deletions setup/windows/ModularToolManagersSetup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Modular Tool Manager"
#ifndef MyAppVersion
#define MyAppVersion "0.0.0"
#endif
#define MyAppPublisher "Xanatos"
#define MyAppURL "https://github.com/XanatosX/ModularToolManager/"
#define MyAppSupportUrl MyAppURL + "issues"
#define MyAppUpdateUrl MyAppURL + "releases"
#define MyAppExeName "ModularToolManager.exe"

#define InstalltionDocumentFolder ".\documents"
#define ApplicationMainFolder "..\.."
#ifndef BuildFolder
#define BuildFolder ApplicationMainFolder + "\src\ModularToolManager\bin\Release\net7.0\win-x64\publish"
#endif

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{5B1778A7-E56A-4DA9-B4F0-0569EB9738E7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppSupportUrl}
AppUpdatesURL={#MyAppUpdateUrl}
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile={#ApplicationMainFolder}\LICENSE
; Enable the following lines if there is some information on the before or after install file
; InfoBeforeFile={#InstalltionDocumentFolder}\beforeInstall.txt
; InfoAfterFile={#InstalltionDocumentFolder}\afterInstall.txt
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=dialog
OutputBaseFilename=ModularToolManager_WindowsInstaller_{#MyAppVersion}_x64
SetupIconFile={#InstalltionDocumentFolder}\installer-logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#BuildFolder}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#BuildFolder}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

1 change: 1 addition & 0 deletions setup/windows/documents/afterInstall.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
after install text
1 change: 1 addition & 0 deletions setup/windows/documents/beforeInstall.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
before install text
3 changes: 3 additions & 0 deletions setup/windows/documents/installer-logo.ico
Git LFS file not shown
26 changes: 26 additions & 0 deletions setup/windows/windowsSetup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
param(
[String][Parameter(Mandatory, HelpMessage="Enter the version of the installation")]$version,
[String][Parameter(HelpMessage="The directory to put the resulting setup file in")]$output = "output",
[String][Parameter(HelpMessage="The folder containing the build")]$buildfolder = ""
)

# Switch to setup location
$dir = split-path $MyInvocation.MyCommand.Path -Parent
Push-Location $dir

# Write information and create setup
Write-Output "Output directory was set to $output"
Write-Output "Install version in $version"

if ([string]::IsNullOrEmpty($buildfolder))
{
Write-Output "Use default build folder"
iscc /DMyAppVersion=$version /O$output .\ModularToolManagersSetup.iss
} else
{
Write-Output "Use $buildfolder as build folder"
iscc /DMyAppVersion=$version /DBuildFolder=$buildfolder /O$output .\ModularToolManagersSetup.iss
}

# Switch back to original location
Pop-Location
4 changes: 2 additions & 2 deletions src/DefaultPlugins/DefaultPlugins.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -25,7 +25,7 @@


<Target Condition="'$(Configuration)' == 'Debug'" Name="CopyAfterBuild" AfterTargets="Build">
<Copy SourceFiles="$(OutDir)DefaultPlugins.dll" DestinationFolder="$(ProjectDir)../ModularToolManager/bin/$(Configuration)/net6.0/$(PlatformShortName)/plugins" SkipUnchangedFiles="false" />
<Copy SourceFiles="$(OutDir)DefaultPlugins.dll" DestinationFolder="$(ProjectDir)../ModularToolManager/bin/$(Configuration)/$(TargetFramework)/$(PlatformShortName)/plugins" SkipUnchangedFiles="false" />
</Target>
</Project>

2 changes: 1 addition & 1 deletion src/DefaultPlugins/Information/PluginInformationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public PluginInformation GetPluginInformation(string description)
Description = description,
License = "MIT",
ProjectUrl = "https://github.com/XanatosX/ModularToolManager",
Version = new Version("1.0.0.0")
Version = new Version("1.0.1.0")

};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using ModularToolManagerPlugin.Enums;

namespace DefaultPlugins.ProcessStartStrategies;

/// <summary>
/// Factory to create the correct process start strategy for the current OS
/// </summary>
internal sealed class DefaultScriptStarterFactory
{
/// <summary>
/// Strategy cache
/// </summary>
private readonly List<IProcessStartStrategy> strategies;

/// <summary>
/// The action used for logging
/// </summary>
private readonly Action<LogSeverity, string>? loggingAction;

/// <summary>
/// Create a new instance of this class
/// <paramref name="loggingAction">The action used for logging messages</paramref>>
/// </summary>
public DefaultScriptStarterFactory(Action<LogSeverity, string>? loggingAction)
{
strategies = new();
this.loggingAction = loggingAction;
}

/// <summary>
/// Create a new instance of this class
/// Logging is disabled with this constructor
/// </summary>
public DefaultScriptStarterFactory() : this(null) { }

/// <summary>
/// Create the correct start info for the current operation system
/// </summary>
/// <param name="parameters">The parameters to use</param>
/// <param name="path">The path of the file to execute</param>
/// <returns>The process start info</returns>
public IProcessStartStrategy? CreateStartInfo(string path)
{
IProcessStartStrategy? info = null;
if (OperatingSystem.IsWindows())
{
info = GetStrategy<WindowsStarterStrategy>(() => new WindowsStarterStrategy());
}
if (OperatingSystem.IsLinux())
{
string? terminalApp = null;
try
{
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
using (StreamReader reader = new StreamReader(stream))
{
string? line;
while ((line = reader.ReadLine()) is not null)
{
if (line.StartsWith("#!"))
{
terminalApp = line.Replace("#!", string.Empty);
break;
}
}
}
}
}
catch (Exception e)
{
if (loggingAction is not null)
{
loggingAction(LogSeverity.Warning, e.Message);
}
}
info = terminalApp switch
{
"/bin/bash" => GetStrategy<LinuxBashStarterStrategy>(() => new LinuxBashStarterStrategy()),
_ => null
};
}

return info;
}

/// <summary>
/// Get the given strategy from cache or create a new one and cache it
/// </summary>
/// <param name="creationMethod">The method used to create the strategy</param>
/// <typeparam name="T">The type of strategy to create</typeparam>
/// <returns>A useable strategy or null</returns>
public IProcessStartStrategy? GetStrategy<T>(Func<T> creationMethod) where T : IProcessStartStrategy
{
T? returnStrategy = strategies.OfType<T>().FirstOrDefault();
if (returnStrategy is null)
{
returnStrategy = creationMethod();
strategies.Add(returnStrategy);
}

return returnStrategy;
}
}
17 changes: 17 additions & 0 deletions src/DefaultPlugins/ProcessStartStrategies/IProcessStartStrategy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Diagnostics;

namespace DefaultPlugins.ProcessStartStrategies;

/// <summary>
/// Interface to define a single strategy for running tasks on an os
/// </summary>
internal interface IProcessStartStrategy
{
/// <summary>
/// Create the start information to run the process for a given os.
/// </summary>
/// <param name="parameters">The parameters to use</param>
/// <param name="path">The path to the file to run</param>
/// <returns>A useable start info, if possible</returns>
ProcessStartInfo? GetStartInfo(string parameters, string path);
}
Loading

0 comments on commit b6411f3

Please sign in to comment.