Skip to content

Commit bea84d8

Browse files
authored
Merge pull request #1 from ricaun-io/develop
Version 1.0.1
2 parents 9a888ea + 1d11127 commit bea84d8

20 files changed

+561
-13
lines changed

.github/workflows/Build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ------------------------------------------------------------------------------
2+
# Build.yml
3+
# ------------------------------------------------------------------------------
4+
5+
name: Build
6+
7+
on:
8+
push:
9+
pull_request:
10+
branches-ignore:
11+
- master
12+
- main
13+
workflow_dispatch:
14+
15+
jobs:
16+
Build:
17+
name: Build
18+
runs-on: windows-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- uses: actions/checkout@v1
23+
24+
- name: NuGet Setup
25+
uses: actions/setup-dotnet@v4
26+
with:
27+
dotnet-version: 8.0.x
28+
- name: "NuGet Add Source Organization"
29+
run: if ("${{ secrets.ORGANIZATION_SOURCE_PACKAGE_PASSWORD }}" -ne "") { dotnet nuget add source --username ${{ secrets.ORGANIZATION_SOURCE_PACKAGE_USERNAME }} --password ${{ secrets.ORGANIZATION_SOURCE_PACKAGE_PASSWORD }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{github.repository_owner}}/index.json" }
30+
31+
- name: Run './Build/build.cmd'
32+
run: ./Build/build.cmd --root ./Build
33+
env:
34+
GitHubToken: ${{ secrets.GITHUB_TOKEN }}
35+
SignFile: ${{ secrets.SIGN_FILE }}
36+
SignPassword: ${{ secrets.SIGN_PASSWORD }}
37+
InstallationFiles: ${{ secrets.INSTALLATION_FILES }}

Build/.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[*.cs]
2+
dotnet_style_qualification_for_field = false:warning
3+
dotnet_style_qualification_for_property = false:warning
4+
dotnet_style_qualification_for_method = false:warning
5+
dotnet_style_qualification_for_event = false:warning
6+
dotnet_style_require_accessibility_modifiers = never:warning
7+
8+
csharp_style_expression_bodied_methods = true:silent
9+
csharp_style_expression_bodied_properties = true:warning
10+
csharp_style_expression_bodied_indexers = true:warning
11+
csharp_style_expression_bodied_accessors = true:warning

Build/.nuke/build.schema.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"$ref": "#/definitions/build",
4+
"title": "Build Schema",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"properties": {
9+
"Continue": {
10+
"type": "boolean",
11+
"description": "Indicates to continue a previously failed build attempt"
12+
},
13+
"Folder": {
14+
"type": "string"
15+
},
16+
"GitHubToken": {
17+
"type": "string",
18+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
19+
},
20+
"Help": {
21+
"type": "boolean",
22+
"description": "Shows the help text for this build assembly"
23+
},
24+
"Host": {
25+
"type": "string",
26+
"description": "Host for execution. Default is 'automatic'",
27+
"enum": [
28+
"AppVeyor",
29+
"AzurePipelines",
30+
"Bamboo",
31+
"Bitbucket",
32+
"Bitrise",
33+
"GitHubActions",
34+
"GitLab",
35+
"Jenkins",
36+
"Rider",
37+
"SpaceAutomation",
38+
"TeamCity",
39+
"Terminal",
40+
"TravisCI",
41+
"VisualStudio",
42+
"VSCode"
43+
]
44+
},
45+
"MainName": {
46+
"type": "string"
47+
},
48+
"NoLogo": {
49+
"type": "boolean",
50+
"description": "Disables displaying the NUKE logo"
51+
},
52+
"Partition": {
53+
"type": "string",
54+
"description": "Partition to use on CI"
55+
},
56+
"Plan": {
57+
"type": "boolean",
58+
"description": "Shows the execution plan (HTML)"
59+
},
60+
"PreReleaseFilter": {
61+
"type": "array",
62+
"items": {
63+
"type": "string"
64+
}
65+
},
66+
"Profile": {
67+
"type": "array",
68+
"description": "Defines the profiles to load",
69+
"items": {
70+
"type": "string"
71+
}
72+
},
73+
"ReleaseFolder": {
74+
"type": "string"
75+
},
76+
"ReleaseNameVersion": {
77+
"type": "boolean"
78+
},
79+
"Root": {
80+
"type": "string",
81+
"description": "Root directory during build execution"
82+
},
83+
"SignFile": {
84+
"type": "string",
85+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
86+
},
87+
"SignPassword": {
88+
"type": "string",
89+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
90+
},
91+
"Skip": {
92+
"type": "array",
93+
"description": "List of targets to be skipped. Empty list skips all dependencies",
94+
"items": {
95+
"type": "string",
96+
"enum": [
97+
"Build",
98+
"BuildInstall",
99+
"Clean",
100+
"Compile",
101+
"GitPreRelease",
102+
"GitRelease",
103+
"Release",
104+
"Sign"
105+
]
106+
}
107+
},
108+
"Solution": {
109+
"type": "string",
110+
"description": "Path to a solution file that is automatically loaded"
111+
},
112+
"Target": {
113+
"type": "array",
114+
"description": "List of targets to be invoked. Default is '{default_target}'",
115+
"items": {
116+
"type": "string",
117+
"enum": [
118+
"Build",
119+
"BuildInstall",
120+
"Clean",
121+
"Compile",
122+
"GitPreRelease",
123+
"GitRelease",
124+
"Release",
125+
"Sign"
126+
]
127+
}
128+
},
129+
"Verbosity": {
130+
"type": "string",
131+
"description": "Logging verbosity during build execution. Default is 'Normal'",
132+
"enum": [
133+
"Minimal",
134+
"Normal",
135+
"Quiet",
136+
"Verbose"
137+
]
138+
}
139+
}
140+
}
141+
}
142+
}

Build/.nuke/parameters.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./build.schema.json",
3+
"Solution": "../RevitShell.sln"
4+
}

Build/Build.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Nuke.Common;
2+
using Nuke.Common.Execution;
3+
using ricaun.Nuke;
4+
using ricaun.Nuke.Components;
5+
6+
class Build : NukeBuild, IPublish, IGitPreRelease, IBuildInstall
7+
{
8+
public static int Main() => Execute<Build>(x => x.From<IPublish>().Build);
9+
}

Build/Build.csproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<RootNamespace></RootNamespace>
6+
<NoWarn>CS0649;CS0169</NoWarn>
7+
<NukeRootDirectory>.</NukeRootDirectory>
8+
<NukeScriptDirectory>.</NukeScriptDirectory>
9+
<NukeTelemetryVersion>1</NukeTelemetryVersion>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="ricaun.Nuke" Version="*-*" />
14+
<PackageReference Include="Tools.InnoSetup" Version="6.2.0" IncludeAssets="All" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<None Include="..\.github\workflows\*.yml" LinkBase="ci" />
19+
<None Include=".github\**\*"/>
20+
<None Include=".nuke\*"/>
21+
</ItemGroup>
22+
</Project>

Build/IBuildInstall.cs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using Nuke.Common;
2+
using Nuke.Common.IO;
3+
using Nuke.Common.Tooling;
4+
using Nuke.Common.Tools.InnoSetup;
5+
using Nuke.Common.Utilities.Collections;
6+
using ricaun.Nuke.Components;
7+
using ricaun.Nuke.Extensions;
8+
using System;
9+
using System.IO;
10+
using System.Linq;
11+
12+
interface IBuildInstall : IRelease, ISign, IHazMainProject
13+
{
14+
Target BuildInstall => _ => _
15+
.TriggeredBy(Sign)
16+
.Before(Release)
17+
.Executes(() =>
18+
{
19+
var project = MainProject;
20+
var projectName = project.Name;
21+
var projectVersion = project.GetInformationalVersion();
22+
var solutionDirectory = Solution.Directory;
23+
var folderOutput = "Install";
24+
25+
Serilog.Log.Information($"{projectName} {projectVersion}");
26+
27+
// Deploy File
28+
var outputInno = project.Directory / "bin" / folderOutput;
29+
var issFiles = Globbing.GlobFiles(solutionDirectory, $"**/*{projectName}.iss");
30+
31+
if (issFiles.IsEmpty())
32+
Serilog.Log.Error($"Not found any .iss file in {solutionDirectory}");
33+
34+
issFiles.ForEach(file =>
35+
{
36+
var tempFile = CreateTemporaryFile(file, projectVersion);
37+
try
38+
{
39+
InnoSetupTasks.InnoSetup(config => config
40+
.SetProcessToolPath(NuGetToolPathResolver.GetPackageExecutable("Tools.InnoSetup", "ISCC.exe"))
41+
.SetScriptFile(tempFile)
42+
.SetOutputDir(outputInno));
43+
}
44+
finally
45+
{
46+
tempFile.DeleteFile();
47+
}
48+
});
49+
50+
// Sign outputInno
51+
SignFolder(outputInno);
52+
53+
// Zip exe Files
54+
var exeFiles = Globbing.GlobFiles(outputInno, "**/*.exe");
55+
exeFiles.ForEach(file => ZipExtension.ZipFileCompact(file, projectName));
56+
57+
if (exeFiles.IsEmpty())
58+
Serilog.Log.Error($"Not found any .exe file in {outputInno}");
59+
60+
var message = string.Join(" | ", exeFiles.Select(e => e.Name));
61+
ReportSummary(_ => _.AddPair("File", message));
62+
63+
if (outputInno != ReleaseDirectory)
64+
{
65+
Globbing.GlobFiles(outputInno, "**/*.zip")
66+
.ForEach(file => FileSystemTasks.CopyFileToDirectory(file, ReleaseDirectory));
67+
}
68+
69+
});
70+
71+
AbsolutePath CreateTemporaryFile(AbsolutePath file, string projectVersion)
72+
{
73+
var folder = file.Parent;
74+
var tempFileName = $"{Path.GetFileNameWithoutExtension(file)}_{DateTime.Now.Ticks}{Path.GetExtension(file)}";
75+
76+
var tempFile = Path.Combine(folder, tempFileName);
77+
78+
FileSystemTasks.CopyFile(file, tempFile, FileExistsPolicy.Overwrite);
79+
80+
var content = File.ReadAllText(tempFile);
81+
82+
content = content.Replace("1.0.0", projectVersion);
83+
84+
File.WriteAllText(tempFile, content);
85+
86+
return tempFile;
87+
}
88+
}

Build/build.cmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:; set -eo pipefail
2+
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
3+
:; ${SCRIPT_DIR}/build.sh "$@"
4+
:; exit $?
5+
6+
@ECHO OFF
7+
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*

Build/build.ps1

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[CmdletBinding()]
2+
Param(
3+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4+
[string[]]$BuildArguments
5+
)
6+
7+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8+
9+
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
10+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11+
12+
###########################################################################
13+
# CONFIGURATION
14+
###########################################################################
15+
16+
$BuildProjectFile = "$PSScriptRoot\Build.csproj"
17+
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
18+
19+
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
20+
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21+
$DotNetChannel = "Current"
22+
23+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25+
$env:DOTNET_MULTILEVEL_LOOKUP = 0
26+
27+
###########################################################################
28+
# EXECUTION
29+
###########################################################################
30+
31+
function ExecSafe([scriptblock] $cmd) {
32+
& $cmd
33+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
34+
}
35+
36+
# If dotnet CLI is installed globally and it matches requested version, use for execution
37+
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
38+
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
39+
$env:DOTNET_EXE = (Get-Command "dotnet").Path
40+
}
41+
else {
42+
# Download install script
43+
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
44+
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
45+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
46+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
47+
48+
# If global.json exists, load expected version
49+
if (Test-Path $DotNetGlobalFile) {
50+
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
51+
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
52+
$DotNetVersion = $DotNetGlobal.sdk.version
53+
}
54+
}
55+
56+
# Install by channel or version
57+
$DotNetDirectory = "$TempDirectory\dotnet-win"
58+
if (!(Test-Path variable:DotNetVersion)) {
59+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
60+
} else {
61+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
62+
}
63+
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
64+
}
65+
66+
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
67+
68+
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
69+
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

0 commit comments

Comments
 (0)