Skip to content

Commit

Permalink
Merge pull request #163 from ionite34/combine-jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ionite34 authored Jul 26, 2023
2 parents f030ca7 + 3614248 commit 7b3222a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 69 deletions.
55 changes: 32 additions & 23 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node("Windows") {
node("Diligence") {
def repoName = "StabilityMatrix"
def author = "ionite34"
def version = ""
Expand All @@ -11,32 +11,41 @@ node("Windows") {
git branch: env.BRANCH_NAME, credentialsId: 'Ionite', url: "https://github.com/${author}/${repoName}.git"
}

stage('Test') {
bat "dotnet test StabilityMatrix.Tests"
}
try {
stage('Test') {
sh "dotnet test StabilityMatrix.Tests"
}

if (env.BRANCH_NAME == 'main') {

stage('Set Version') {
script {
if (env.TAG_NAME) {
version = env.TAG_NAME.replaceFirst(/^v/, '')
} else {
version = VersionNumber projectStartDate: '2023-06-21', versionNumberString: '${BUILDS_ALL_TIME}', worstResultForIncrement: 'SUCCESS'
if (env.BRANCH_NAME == 'main') {

stage('Set Version') {
script {
if (env.TAG_NAME) {
version = env.TAG_NAME.replaceFirst(/^v/, '')
} else {
version = VersionNumber projectStartDate: '2023-06-21', versionNumberString: '${BUILDS_ALL_TIME}', worstResultForIncrement: 'SUCCESS'
}
}
}

stage('Publish Windows') {
sh "dotnet publish ./StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj -c Release -o out -r win-x64 -p:PublishSingleFile=true -p:VersionPrefix=2.0.0 -p:VersionSuffix=${version} -p:IncludeNativeLibrariesForSelfExtract=true"
}

stage('Publish Linux') {
sh "/home/jenkins/.dotnet/tools/pupnet --runtime linux-x64 --kind appimage --app-version ${version} --clean -y"
}

stage ('Archive Artifacts') {
archiveArtifacts artifacts: 'out/*.exe', followSymlinks: false
archiveArtifacts artifacts: 'out/*.appimage', followSymlinks: false
}
}

stage('Publish') {
bat "dotnet publish .\\StabilityMatrix.Avalonia\\StabilityMatrix.Avalonia.csproj -c Release -o out -r win-x64 -p:PublishSingleFile=true -p:VersionPrefix=2.0.0 -p:VersionSuffix=${version} -p:IncludeNativeLibrariesForSelfExtract=true"
}

stage ('Archive Artifacts') {
archiveArtifacts artifacts: 'out/*.exe', followSymlinks: false
}
} else {
stage('Publish') {
bat "dotnet publish .\\StabilityMatrix.Avalonia\\StabilityMatrix.Avalonia.csproj -c Release -o out -r win-x64 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true"
} finally {
stage('Cleanup') {
cleanWs()
}
}


}
42 changes: 0 additions & 42 deletions Jenkinsfile-linux

This file was deleted.

1 change: 1 addition & 0 deletions StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ApplicationIcon>./Assets/Icon.ico</ApplicationIcon>
<Version>2.0.3-dev.1</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion StabilityMatrix.Core/Helper/SharedFolders.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NLog;
using System.Globalization;
using NLog;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
Expand Down Expand Up @@ -30,6 +31,8 @@ private static void CreateLinkOrJunction(string junctionDir, string targetDir, b
}
else
{
// Create parent directory if it doesn't exist, since CreateSymbolicLink doesn't seem to
new DirectoryPath(junctionDir).Parent?.Create();
Directory.CreateSymbolicLink(junctionDir, targetDir);
}
}
Expand Down
1 change: 1 addition & 0 deletions StabilityMatrix.Core/StabilityMatrix.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 12 additions & 1 deletion StabilityMatrix.Tests/Models/InstalledPackageTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using StabilityMatrix.Core.Models;
using System.Runtime.InteropServices;
using StabilityMatrix.Core.Models;

namespace StabilityMatrix.Tests.Models;

Expand All @@ -12,6 +13,16 @@ public class InstalledPackageTests
[DataRow("C:\\User\\AppData\\StabilityMatrix", "C:\\User\\AppData\\StabilityMatrix\\Packages\\abc", "Packages\\abc")]
public void TestGetSubPath(string relativeTo, string path, string? expected)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
relativeTo = relativeTo.Replace("C:\\", $"{Path.DirectorySeparatorChar}")
.Replace('\\', Path.DirectorySeparatorChar);
path = path.Replace("C:\\", $"{Path.DirectorySeparatorChar}")
.Replace('\\', Path.DirectorySeparatorChar);
expected = expected?.Replace("C:\\", $"{Path.DirectorySeparatorChar}")
.Replace('\\', Path.DirectorySeparatorChar);
}

var result = InstalledPackage.GetSubPath(relativeTo, path);
Assert.AreEqual(expected, result);
}
Expand Down
9 changes: 8 additions & 1 deletion StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using StabilityMatrix.Core.ReparsePoints;
using System.Runtime.InteropServices;
using StabilityMatrix.Core.ReparsePoints;

namespace StabilityMatrix.Tests.ReparsePoints;

Expand All @@ -13,6 +14,12 @@ public class JunctionTest
[TestInitialize]
public void Initialize()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Assert.Inconclusive("Test cannot be run on anything but Windows currently.");
return;
}

tempFolder = Path.GetTempFileName();
File.Delete(tempFolder);
Directory.CreateDirectory(tempFolder);
Expand Down
2 changes: 1 addition & 1 deletion StabilityMatrix.Tests/StabilityMatrix.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;osx-arm64</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<EnableWindowsTargeting>true</EnableWindowsTargeting>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand Down

0 comments on commit 7b3222a

Please sign in to comment.