Skip to content

Commit

Permalink
Optimize build and release process
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-martin committed Sep 12, 2024
1 parent b681d70 commit 6b7e342
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 42 deletions.
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
<Version>3.6.143</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory>
</PropertyGroup>
</Project>
4 changes: 4 additions & 0 deletions StreamDeckSimHub.Installer/StreamDeckSimHub.Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<PackageReference Include="NLog" Version="5.3.3" />
</ItemGroup>

<Target Name="RenameInstaller" AfterTargets="Publish">
<Copy SourceFiles="$(PublishDir)\StreamDeckSimHub.Installer.exe" DestinationFiles="$(PublishDir)\StreamDeckSimHub.Installer-v$(BuildVersion3Components).exe" />
</Target>

<ItemGroup>
<EmbeddedResource Include="NLog.config" />
<EmbeddedResource Include="..\build\net.planetrenner.simhub.streamDeckPlugin" />
Expand Down
19 changes: 19 additions & 0 deletions StreamDeckSimHub.Plugin/Bundle.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2024 Martin Renner
# LGPL-3.0-or-later (see file COPYING and COPYING.LESSER)


if ($Args.Count -lt 1) {
throw 'Arguments are missing'
}

$PublishDir = $Args[0]

Remove-Item "..\build\*" -Recurse

Copy-Item "$PublishDir" -Destination "..\build" -Recurse
Pushd ..\build
Rename-Item -Path "publish" -NewName "net.planetrenner.simhub.sdPlugin"

..\..\DistributionTool.exe -b -i net.planetrenner.simhub.sdPlugin -o .

Popd
18 changes: 15 additions & 3 deletions StreamDeckSimHub.Plugin/ReplaceVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ if ($Args.Count -lt 2) {
$ManifestFile = $Args[0]
$Version = $Args[1]

$manifest = (Get-Content($ManifestFile) | ConvertFrom-Json)
$manifest.Version = $Version
$manifest | ConvertTo-Json -depth 100 | Out-File -Encoding utf8 $ManifestFile
Write-Host "Setting version $Version in file $ManifestFile"

try {
$manifest = (Get-Content($ManifestFile) | ConvertFrom-Json)
$manifest.Version = $Version
$manifest | ConvertTo-Json -depth 100 | Out-File -Encoding utf8 ($ManifestFile + ".new")

Move-Item ($ManifestFile + ".new") -Destination $ManifestFile -Force
Write-Host "Done"
}
catch {
Write-Host "An error occured:"
Write-Host $_
Exit 1
}
5 changes: 3 additions & 2 deletions StreamDeckSimHub.Plugin/StreamDeckSimHub.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TargetFramework>net8.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>false</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>StreamDeckSimHub</AssemblyName>
Expand Down Expand Up @@ -33,13 +32,15 @@
</Reference>
</ItemGroup>

<Target Name="CustomAfterPublish" AfterTargets="Publish" DependsOnTargets="GetBuildVersion">
<Target Name="SetManifestVersionAndBundle" AfterTargets="Publish">
<PropertyGroup>
<PowerShell Condition="!$([MSBuild]::IsOSUnixLike())">powershell.exe</PowerShell>
<PowerShell Condition="$([MSBuild]::IsOSUnixLike())">pwsh</PowerShell>
</PropertyGroup>
<!-- Replace version in manifest.json with the version from nbgv -->
<Exec Command="$(PowerShell) -NonInteractive -ExecutionPolicy Bypass -Command &quot;&amp; '.\ReplaceVersion.ps1' '$(PublishDir)manifest.json' '$(AssemblyFileVersion)' &quot;" />
<!-- Bundle as Stream Deck plugin if running on Windows -->
<Exec Command="$(PowerShell) -NonInteractive -ExecutionPolicy Bypass -Command &quot;&amp; '.\Bundle.ps1' '$(PublishDir)' &quot;" Condition="$([MSBuild]::IsOSPlatform('Windows'))"/>
</Target>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion StreamDeckSimHub.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFiles", "SolutionFiles", "{E3F720A4-BDC4-4B7D-B604-BF323E7AB170}"
ProjectSection(SolutionItems) = preProject
README.adoc = README.adoc
release.bat = release.bat
deploy.bat = deploy.bat
EndProjectSection
EndProject
Expand Down
3 changes: 0 additions & 3 deletions build/net.planetrenner.simhub.streamDeckPlugin

This file was deleted.

13 changes: 8 additions & 5 deletions doc/Release.adoc
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
= Release Process

. If there is no release branch yet for the current version: +
. If there is no release branch yet for the current version: +
`nbgv prepare-release`
. Switch to the release branch: +
. Switch to the release branch: +
`git switch release/v1.2`
. Push the release branch
. Create a tag and push it afterwards:
. Create a tag and push it afterward:
- `nbgv tag`
- `git push origin v1.2`
. Build the plugin:
- `release.bat`
. Create a release in GitHub from the tag and attach the file `net.planetrenner.simhub.streamDeckPlugin`
- `dotnet build StreamDeckSimHub.Plugin\StreamDeckSimHub.Plugin.csproj -c Release`
- `dotnet publish StreamDeckSimHub.Plugin\StreamDeckSimHub.Plugin.csproj -c Release`
. Build the installer:
- `dotnet publish StreamDeckSimHub.Installer\StreamDeckSimHub.Installer.csproj -c Release`
. Create a release in GitHub from the tag and attach the file `StreamDeckSimHub.Installer-vX.Y.z.exe`
. Push the main branch.
28 changes: 0 additions & 28 deletions release.bat

This file was deleted.

0 comments on commit 6b7e342

Please sign in to comment.