Skip to content

Commit

Permalink
fix(ci): fix devolutions-agent packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmancoder committed Jun 5, 2024
1 parent 38d27b4 commit 6996498
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ jobs:
- name: Install Pester module
id: prepare
shell: pwsh
run: Install-Module Pester -Force
run: Install-Module Pester -RequiredVersion 5.5.0 -Force

- name: Build module
shell: pwsh
Expand Down
47 changes: 39 additions & 8 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ jobs:
if: matrix.os == 'windows' && (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent')
uses: microsoft/setup-msbuild@v2

- name: Regenerate MSI
if: (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent') && matrix.os == 'windows'
- name: Regenerate Gateway MSI
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
Expand All @@ -257,10 +257,19 @@ jobs:
Remove-Item $_.FullName -Force
}
./ci/tlk.ps1 package -PackageOption generate
./ci/tlk.ps1 package -Product gateway -PackageOption generate
- name: Sign msi runtime
if: (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent') && matrix.os == 'windows'
- name: Regenerate Agent MSI
if: matrix.project == 'devolutions-agent' && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
$Env:DAGENT_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsAgent*.exe' | Select -First 1
./ci/tlk.ps1 package -Product agent -PackageOption generate
- name: Sign Gateway MSI runtime
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
shell: pwsh
working-directory: package/WindowsManaged/Release
run: |
Expand All @@ -276,7 +285,24 @@ jobs:
AzureSignTool @Params $_.FullName
}
- name: Repackage gateway
- name: Sign Agent MSI runtime
if: matrix.project == 'devolutions-agent' && matrix.os == 'windows'
shell: pwsh
working-directory: package/AgentWindowsManaged/Release
run: |
Get-ChildItem -Path .\* -Include "*.exe" | % {
$Params = @('sign',
'-kvt', '${{ secrets.AZURE_TENANT_ID }}',
'-kvu', '${{ secrets.CODE_SIGNING_KEYVAULT_URL }}',
'-kvi', '${{ secrets.CODE_SIGNING_CLIENT_ID }}',
'-kvs', '${{ secrets.CODE_SIGNING_CLIENT_SECRET }}',
'-kvc', '${{ secrets.CODE_SIGNING_CERTIFICATE_NAME }}',
'-tr', '${{ vars.CODE_SIGNING_TIMESTAMP_SERVER }}',
'-v')
AzureSignTool @Params $_.FullName
}
- name: Repackage Gateway
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
shell: pwsh
run: |
Expand All @@ -285,7 +311,7 @@ jobs:
./ci/tlk.ps1 package -Product gateway -PackageOption assemble
- name: Repackage agent
- name: Repackage Agent
if: matrix.project == 'devolutions-agent' && matrix.os == 'windows'
shell: pwsh
run: |
Expand All @@ -298,6 +324,11 @@ jobs:
if: (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent') && matrix.os == 'windows'
shell: pwsh
run: |
$ContentDescription = switch ('${{ matrix.project }}') {
'devolutions-gateway' { 'Devolutions Gateway' }
'devolutions-agent' { 'Devolutions Agent' }
}
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include '*.msi' | % {
$Params = @('sign',
'-kvt', '${{ secrets.AZURE_TENANT_ID }}',
Expand All @@ -306,7 +337,7 @@ jobs:
'-kvs', '${{ secrets.CODE_SIGNING_CLIENT_SECRET }}',
'-kvc', '${{ secrets.CODE_SIGNING_CERTIFICATE_NAME }}',
'-tr', '${{ vars.CODE_SIGNING_TIMESTAMP_SERVER }}',
'-d', 'Devolutions Gateway',
'-d', $ContentDescription,
'-v')
AzureSignTool @Params $_.FullName
}
Expand Down
11 changes: 9 additions & 2 deletions ci/tlk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,13 @@ class TlkRecipe

[void] Package_Windows_Managed_Assemble() {
Push-Location
Set-Location "$($this.SourcePath)/package/$($this.Target.Platform)Managed"

$InputPackagePathPrefix = switch ($this.Product) {
"gateway" { "" }
"agent" { "Agent" }
}

Set-Location "$($this.SourcePath)/package/$($InputPackagePathPrefix)$($this.Target.Platform)Managed"

$TargetConfiguration = "Release"

Expand All @@ -441,7 +447,8 @@ class TlkRecipe
foreach ($PackageLanguage in $([TlkRecipe]::PackageLanguages | Select-Object -Skip 1)) {
# Build the localized MSI
& ".\$TargetConfiguration\$($PackageLanguage.Name)\Build_$($this.PackageName()).cmd"
$LangMsi = Join-Path $TargetConfiguration $($PackageLanguage.Name) "$($this.PackageName()).msi"
$LangDir = Join-Path $TargetConfiguration $PackageLanguage.Name
$LangMsi = Join-Path $LangDir "$($this.PackageName()).msi"
$Transform = Join-Path $TargetConfiguration "$($PackageLanguage.Name).mst"
# Generate a language transform
& 'torch.exe' "$BaseMsi" "$LangMsi" "-o" "$Transform" | Out-Host
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace DevolutionsAgent.Actions;

internal static class GatewayActions
internal static class AgentActions
{
// Immediate sequence

Expand Down
12 changes: 6 additions & 6 deletions package/AgentWindowsManaged/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void Main()
{
new()
{
Cabinet = "dgateway.cab",
Cabinet = "dagent.cab",
EmbedCab = true,
CompressionLevel = CompressionLevel.mszip,
}
Expand Down Expand Up @@ -195,7 +195,7 @@ static void Main()
{
Type = SvcType.ownProcess,
// In contrast to Devolutions Gateway, Devolutions Agent uses LocalSystem
// accout to be able to perform administrative operations
// accout to be able to perform administrative operations
// such as MSI installation (Updating, restarting DevolutionsGateway).
Interactive = false,
Vital = true,
Expand All @@ -217,7 +217,7 @@ static void Main()
project.ResolveWildCards(true);

project.DefaultRefAssemblies.Add(typeof(ZipArchive).Assembly.Location);
project.Actions = GatewayActions.Actions;
project.Actions = AgentActions.Actions;
project.RegValues = new RegValue[]
{
new (RegistryHive.LocalMachine, $"Software\\{Includes.VENDOR_NAME}\\{Includes.SHORT_NAME}", "InstallDir", $"[{AgentProperties.InstallDir}]")
Expand All @@ -240,7 +240,7 @@ static void Main()

project.UnhandledException += Project_UnhandledException;
project.UIInitialized += Project_UIInitialized;

if (SourceOnlyBuild)
{
project.Language = ProjectLangId;
Expand Down Expand Up @@ -269,7 +269,7 @@ static void Main()

msi.EmbedTransform(mstFile);
}

msi.SetPackageLanguages(string.Join(",", Languages.Keys).ToLcidList());
}
}
Expand Down Expand Up @@ -351,7 +351,7 @@ string I18n(string key)
e.ManagedUI.Shell.ErrorDetected = true;
e.Result = ActionResult.UserExit;
}

if (netfx45Version < 528040)
{
if (MessageBox.Show(I18n(Strings.DotNet48IsStrongRecommendedDownloadNow), I18n(Strings.AgentDlg_Title),
Expand Down

0 comments on commit 6996498

Please sign in to comment.