Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c7fc7b9
Update the Git settings
cedx Dec 2, 2025
6d72db3
Update the editor settings
cedx Dec 2, 2025
613a1f7
Update the "Invoke" script
cedx Dec 2, 2025
8f06128
Updated the PowerShell module manifest
cedx Dec 2, 2025
0ca1146
Add the C# projects
cedx Dec 2, 2025
d25c748
Update the build system [skip ci]
cedx Dec 2, 2025
f1407c3
Update the build system [skip ci]
cedx Dec 2, 2025
31a905b
Update the dependencies [skip ci]
cedx Dec 2, 2025
595a055
Update the dependencies [skip ci]
cedx Dec 2, 2025
f11480d
Add the C# class skeletons [skip ci]
cedx Dec 2, 2025
8542621
Update the test settings [skip ci]
cedx Dec 2, 2025
0337f23
Update the Git attributes [skip ci]
cedx Dec 2, 2025
a660e1a
Update the "Publish" script
cedx Dec 3, 2025
acc8d4d
Update the "Start" script
cedx Dec 3, 2025
e65b10b
Bump the version number
cedx Dec 3, 2025
1cf1f5a
Update the example workflow
cedx Dec 3, 2025
8d95955
Port the `Platform` enum and the `Get-Platform` cmdlet
cedx Dec 3, 2025
f8b507d
Port the `ReleaseAsset` class
cedx Dec 3, 2025
ddbaacd
Port the `New-ReleaseAsset` cmdlet
cedx Dec 3, 2025
4ccd864
Port the release data
cedx Dec 3, 2025
c0f33dd
Port the `Release` class [skip ci]
cedx Dec 3, 2025
f439976
Port the `Find-Release` cmdlet
cedx Dec 3, 2025
38c0c71
Port the `Get-Release` cmdlet
cedx Dec 3, 2025
85d6ec8
Port the `Test-Release` cmdlet
cedx Dec 3, 2025
a1e665d
Port the `New-Release` cmdlet [skip ci]
cedx Dec 3, 2025
467b0f6
Add the cmdlet tests
cedx Dec 3, 2025
f85a605
Add the tests of the `Release` class
cedx Dec 3, 2025
cb3f364
Port the `Install-Release` cmdlet
cedx Dec 3, 2025
9884b4a
Add a VSCode launch configuration [skip ci]
cedx Dec 4, 2025
7f813b0
Port the `Setup` class
cedx Dec 4, 2025
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
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ insert_final_newline = true
tab_width = 2
trim_trailing_whitespace = true

[*.cs]
csharp_indent_case_contents_when_block = false
csharp_indent_labels = no_change
csharp_new_line_before_open_brace = none
csharp_prefer_braces = false
csharp_space_after_cast = true
csharp_space_before_colon_in_inheritance_clause = false
csharp_style_expression_bodied_constructors = true
csharp_style_expression_bodied_local_functions = true
csharp_style_expression_bodied_methods = true
csharp_style_expression_bodied_operators = true
csharp_style_namespace_declarations = file_scoped
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
csharp_using_directive_placement = inside_namespace
dotnet_diagnostic.CS8524.severity = silent
dotnet_sort_system_directives_first = false
dotnet_style_namespace_match_folder = false

[*.md]
trim_trailing_whitespace = false

Expand Down
11 changes: 10 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
* text=auto
.* text

*.cjs text
*.config text
*.cs text diff=csharp
*.csproj text
*.css text diff=css
*.esproj text
*.html text diff=html
*.http text
*.ini text
*.iss text
*.js text
*.json text
*.md text diff=markdown
*.mjs text
*.php text diff=php
*.ps1 text
*.psd1 text
*.razor text
*.scss text diff=css
*.slnx text
*.sql text
*.svg text
*.ts text
*.txt text
*.webmanifest text
*.xml text
*.yaml text
*.yml text
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
/.idea/
/.vs/
/bin/
/src/obj/
/*/obj/
/var/
5 changes: 5 additions & 0 deletions .runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RunSettings>
<RunConfiguration>
<ResultsDirectory>var/TestResults</ResultsDirectory>
</RunConfiguration>
</RunSettings>
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"ms-dotnettools.csdevkit",
"ms-vscode.powershell"
]
}
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"configurations": [
{
"name": "Script",
"preLaunchTask": "Build",
"request": "launch",
"type": "PowerShell",
"script": "${workspaceFolder}/Debug.ps1"
Expand Down
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "./Invoke.ps1",
"args": ["Build"]
}
]
}
5 changes: 4 additions & 1 deletion Invoke.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ param (
param ($commandName, $parameterName, $wordToComplete)
(Get-Item "$PSScriptRoot/tool/$wordToComplete*.ps1").BaseName
})]
[string] $Command = "Default"
[string] $Command = "Default",

[Parameter()]
[switch] $Release
)

$ErrorActionPreference = "Stop"
Expand Down
14 changes: 4 additions & 10 deletions SetupHashLink.psd1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@{
DefaultCommandPrefix = "HashLink"
ModuleVersion = "7.1.0"
ModuleVersion = "8.0.0"
PowerShellVersion = "7.4"
RootModule = "src/Main.psm1"
RootModule = "bin/Belin.SetupHashLink.dll"

Author = "Cédric Belin <cedx@outlook.com>"
CompanyName = "Cedric-Belin.fr"
Expand All @@ -11,10 +11,10 @@
GUID = "6bb1e481-9f7c-4dd0-922c-fdf44f2c0e78"

AliasesToExport = @()
CmdletsToExport = @()
FunctionsToExport = @()
VariablesToExport = @()

FunctionsToExport = @(
CmdletsToExport = @(
"Find-Release"
"Get-Release"
"Install-Release"
Expand All @@ -23,12 +23,6 @@
"Test-Release"
)

NestedModules = @(
"src/Platform.psm1"
"src/Release.psm1"
"src/Setup.psm1"
)

PrivateData = @{
PSData = @{
LicenseUri = "https://github.com/cedx/setup-hashlink/blob/main/License.md"
Expand Down
16 changes: 9 additions & 7 deletions SetupHashLink.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<File Path=".editorconfig" />
<File Path=".gitattributes" />
<File Path=".gitignore" />
<File Path=".runsettings" />
<File Path="PSModules.psd1" />
<File Path="SetupHashLink.psd1" />
</Folder>
Expand All @@ -21,24 +22,25 @@
<File Path="Start.ps1" />
</Folder>
<Folder Name="/Scripts/Tools/">
<File Path="tool/Build.ps1" />
<File Path="tool/Clean.ps1" />
<File Path="tool/Default.ps1" />
<File Path="tool/Format.ps1" />
<File Path="tool/Install.ps1" />
<File Path="tool/Lint.ps1" />
<File Path="tool/Outdated.ps1" />
<File Path="tool/Publish.ps1" />
<File Path="tool/Test.ps1" />
<File Path="tool/Update.ps1" />
<File Path="tool/Version.ps1" />
<File Path="tool/Watch.ps1" />
</Folder>
<Folder Name="/Workflows/">
<File Path="action.yaml" />
<File Path=".github/workflows/ContinuousIntegration.yaml" />
</Folder>
<Project Path="src/SetupHashLink.esproj">
<Build />
<Deploy />
</Project>
<Project Path="test/SetupHashLink.Tests.esproj">
<Build />
<Deploy />
<Project Path="src/SetupHashLink.csproj" />
<Project Path="test/SetupHashLink.Tests.csproj">
<Build Solution="Release|*" Project="false" />
</Project>
</Solution>
10 changes: 5 additions & 5 deletions Start.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env pwsh
using module ./src/Release.psm1
using module ./src/Setup.psm1
using namespace Belin.SetupHashLink
Add-Type -Path "$PSScriptRoot/bin/Belin.SetupHashLink.dll"

$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
Set-StrictMode -Version Latest
if (-not (Test-Path Env:SETUP_HASHLINK_VERSION)) { $Env:SETUP_HASHLINK_VERSION = "latest" }
if (-not (Test-Path Env:SETUP_HASHLINK_VERSION)) { $Env:SETUP_HASHLINK_VERSION = "Latest" }

$release = [Release]::Find($Env:SETUP_HASHLINK_VERSION)
if (-not $release) { throw "No release matching the version constraint." }
if (-not $release) { throw "No release matches the specified version constraint." }

$path = [Setup]::new($release).Install()
$path = [Setup]::new($release).Install().GetAwaiter().GetResult()
"HashLink $($release.Version) successfully installed in ""$path""."
2 changes: 1 addition & 1 deletion example/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Lix
uses: lix-pm/setup-lix@master
- name: Set up HashLink
uses: cedx/setup-hashlink@v7
uses: cedx/setup-hashlink@v8
with:
version: latest
- name: Install dependencies
Expand Down
20 changes: 20 additions & 0 deletions src/Cmdlets/Find-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Finds a release that matches the specified version constraint.
/// </summary>
[Cmdlet(VerbsCommon.Find, "Release")]
[OutputType(typeof(Release))]
public class FindReleaseCommand: Cmdlet {

/// <summary>
/// The version constraint.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public required string Constraint { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() => WriteObject(Release.Find(Constraint));
}
14 changes: 14 additions & 0 deletions src/Cmdlets/Get-Platform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Gets the current platform.
/// </summary>
[Cmdlet(VerbsCommon.Get, "Platform")]
[OutputType(typeof(Platform))]
public class GetPlatformCommand: Cmdlet {

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() => WriteObject(PlatformExtensions.GetCurrent());
}
21 changes: 21 additions & 0 deletions src/Cmdlets/Get-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Gets the release corresponding to the specified version.
/// </summary>
[Cmdlet(VerbsCommon.Get, "Release")]
[OutputType(typeof(Release))]
public class GetReleaseCommand: Cmdlet {

/// <summary>
/// The version number. Use `*` or `Latest` to get the latest release.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public required string Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() =>
WriteObject(Release.LatestReleasePattern().IsMatch(Version) ? Release.Latest : Release.Get(Version));
}
33 changes: 33 additions & 0 deletions src/Cmdlets/Install-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Installs the HashLink VM, after downloading it.
/// </summary>
[Cmdlet(VerbsLifecycle.Install, "Release", DefaultParameterSetName = "Constraint")]
[OutputType(typeof(string))]
public class InstallReleaseCommand: PSCmdlet {

/// <summary>
/// The version constraint of the release to be installed.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "Constraint", Position = 0, ValueFromPipeline = true)]
public required string Constraint { get; set; }

/// <summary>
/// The release to be installed.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "InputObject", ValueFromPipeline = true)]
public required Release InputObject { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() {
var release = ParameterSetName == "InputObject" ? InputObject : Release.Find(Constraint);
if (release?.Exists ?? false) WriteObject(new Setup(release).Install().GetAwaiter().GetResult());
else {
var exception = new InvalidOperationException("No release matches the specified version constraint.");
WriteError(new ErrorRecord(exception, "ReleaseNotFound", ErrorCategory.ObjectNotFound, null));
}
}
}
26 changes: 26 additions & 0 deletions src/Cmdlets/New-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Creates a new release.
/// </summary>
[Cmdlet(VerbsCommon.New, "Release")]
[OutputType(typeof(Release))]
public class NewReleaseCommand: Cmdlet {

/// <summary>
/// The associated assets.
/// </summary>
[Parameter(Position = 1)]
public Release.Asset[] Assets { get; set; } = [];

/// <summary>
/// The version number.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
public required Version Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() => WriteObject(new Release(Version, Assets));
}
26 changes: 26 additions & 0 deletions src/Cmdlets/New-ReleaseAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Creates a new release asset.
/// </summary>
[Cmdlet(VerbsCommon.New, "ReleaseAsset")]
[OutputType(typeof(Release.Asset))]
public class NewReleaseAssetCommand: Cmdlet {

/// <summary>
/// The target file.
/// </summary>
[Parameter(Mandatory = true, Position = 1)]
public required string File { get; set; }

/// <summary>
/// The target platform.
/// </summary>
[Parameter(Mandatory = true, Position = 0)]
public required Platform Platform { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() => WriteObject(new Release.Asset(Platform, File));
}
29 changes: 29 additions & 0 deletions src/Cmdlets/Test-Release.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Belin.SetupHashLink.Cmdlets;

/// <summary>
/// Gets a value indicating whether a release with the specified version exists.
/// </summary>
[Cmdlet(VerbsDiagnostic.Test, "Release", DefaultParameterSetName = "Version")]
[OutputType(typeof(bool))]
public class TestReleaseCommand: PSCmdlet {

/// <summary>
/// The release to be tested.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "InputObject", ValueFromPipeline = true)]
public required Release InputObject { get; set; }

/// <summary>
/// The version number of the release to be tested.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "Version", Position = 0, ValueFromPipeline = true)]
public required Version Version { get; set; }

/// <summary>
/// Performs execution of this command.
/// </summary>
protected override void ProcessRecord() {
var release = ParameterSetName == "InputObject" ? InputObject : new Release(Version);
WriteObject(release.Exists);
}
}
Loading