Skip to content

Commit

Permalink
feat(pedm): add package and CI steps for PEDM
Browse files Browse the repository at this point in the history
  • Loading branch information
kbouchard-dev committed Aug 12, 2024
1 parent 645c634 commit 965ebf0
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 51 deletions.
35 changes: 28 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ jobs:
run: |
$PackageVersion = "${{ needs.preflight.outputs.version }}"
$StagingPath = Join-Path $Env:RUNNER_TEMP "staging"
$SymbolsPath = Join-Path $Env:RUNNER_TEMP "symbols"
New-Item -ItemType Directory $SymbolsPath
$TargetOutputPath = Join-Path $StagingPath ${{ matrix.os }} ${{ matrix.arch }}
$ExecutableFileName = "DevolutionsAgent_${{ runner.os }}_${PackageVersion}_${{ matrix.arch }}"
Expand All @@ -525,10 +528,20 @@ jobs:
$DAgentPackage = Join-Path $TargetOutputPath $PackageFileName
echo "dagent-package=$DAgentPackage" >> $Env:GITHUB_OUTPUT
$DAgentPedmDesktopExecutable = Join-Path $TargetOutputPath "DevolutionsPedmDesktop.exe"
echo "dagent-pedm-desktop-executable=$DAgentPedmDesktopExecutable" >> $Env:GITHUB_OUTPUT
$DAgentPedmContextMenuMsix = Join-Path $TargetOutputPath "devolutions-pedm-contextmenu.msix"
echo "dagent-pedm-context-menu-msix=$DAgentPedmContextMenuMsix" >> $Env:GITHUB_OUTPUT
$DAgentPedmHook = Join-Path $TargetOutputPath "devolutions_pedm_hook.dll"
echo "dagent-pedm-hook=$DAgentPedmHook" >> $Env:GITHUB_OUTPUT
}
$DAgentExecutable = Join-Path $TargetOutputPath $ExecutableFileName
echo "staging-path=$StagingPath" >> $Env:GITHUB_OUTPUT
echo "symbols-path=$SymbolsPath" >> $Env:GITHUB_OUTPUT
echo "target-output-path=$TargetOutputPath" >> $Env:GITHUB_OUTPUT
echo "dagent-executable=$DAgentExecutable" >> $Env:GITHUB_OUTPUT
Expand Down Expand Up @@ -571,17 +584,24 @@ jobs:
# We need to add the NASM binary folder to the PATH manually.
Write-Output "$Env:ProgramFiles\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Add msbuild to PATH
if: matrix.os == 'windows'
uses: microsoft/setup-msbuild@v2

- name: Build
shell: pwsh
env:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DAGENT_EXECUTABLE: ${{ steps.load-variables.outputs.dagent-executable }}
CARGO_PACKAGE: devolutions-agent
run: ./ci/tlk.ps1 build -Product agent -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}

- name: Add msbuild to PATH
if: matrix.os == 'windows'
uses: microsoft/setup-msbuild@v2
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_PEDM_DESKTOP_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-pedm-desktop-executable }}"
$Env:DAGENT_PEDM_HOOK = "${{ steps.load-variables.outputs.dagent-pedm-hook }}"
$Env:DAGENT_PEDM_CONTEXT_MENU_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-context-menu-msix }}"
}
./ci/tlk.ps1 build -Product agent -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Package
shell: pwsh
Expand All @@ -592,8 +612,9 @@ jobs:
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_PACKAGE = "${{ steps.load-variables.outputs.dagent-package }}"
$Env:DAGENT_PEDM_DESKTOP_BUILD_DIR = Get-ChildItem -Recurse -Include DevolutionsPedmDesktop.exe | Select -First 1 -ExpandProperty Directory
$Env:DAGENT_BUILD_DIR = Get-Item "./target/${{ matrix.arch }}-*${{ matrix.os }}*/release" | Select -First 1
$Env:DAGENT_PEDM_DESKTOP_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-pedm-desktop-executable }}"
$Env:DAGENT_PEDM_HOOK = "${{ steps.load-variables.outputs.dagent-pedm-hook }}"
$Env:DAGENT_PEDM_CONTEXT_MENU_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-context-menu-msix }}"
}
./ci/tlk.ps1 package -Product agent -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
Expand Down
45 changes: 42 additions & 3 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,33 @@ jobs:
run: |
$IncludePattern = switch ('${{ matrix.project }}') {
'devolutions-gateway' { 'DevolutionsGateway_*.exe' }
'devolutions-agent' { 'DevolutionsAgent_*.exe' }
'devolutions-agent' { 'DevolutionsAgent_*.exe', 'devolutions-pedm-contextmenu.msix', 'DevolutionsPedmDesktop.exe', 'devolutions_pedm_hook.dll' }
'jetsocat' { 'jetsocat_*' }
}
$ExcludePattern = "*.pdb"
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include "$IncludePattern" -Exclude $ExcludePattern | % {
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include $IncludePattern -Exclude $ExcludePattern | % {
if ('${{ matrix.os }}' -Eq 'windows') {
if ($_.Name -Eq 'devolutions-pedm-contextmenu.msix') {
$PackagePublisher = '${{ secrets.CODE_SIGNING_APPX_PUBLISHER }}'
$UnpackedMsix = Join-Path ${{ runner.temp }} "unpacked-context-menu-msix"
$AppxManifest = Join-Path $UnpackedMsix "AppxManifest.xml"
$PackedMsix = $_.FullName
& 'MakeAppx.exe' unpack /p $PackedMsix /d $UnpackedMsix /nv
Remove-Item $PackedMsix -Force | Out-Null
$appx = [xml](Get-Content -Path $AppxManifest)
$appx.Package.Identity.Publisher = $PackagePublisher
$xmlWriterSettings = New-Object System.Xml.XmlWriterSettings
$xmlWriterSettings.Indent = $true
$xmlWriterSettings.Encoding = [System.Text.Encoding]::UTF8
$xmlTextWriter = [System.Xml.XmlTextWriter]::Create($AppxManifest, $xmlWriterSettings)
$appx.Save($xmlTextWriter)
$xmlTextWriter.Close()
& 'MakeAppx.exe' pack /d $UnpackedMsix /p $PackedMsix /nv
Remove-Item $UnpackedMsix -Recurse -Force | Out-Null
}
$Params = @('sign',
'-kvt', '${{ secrets.AZURE_TENANT_ID }}',
'-kvu', '${{ secrets.CODE_SIGNING_KEYVAULT_URL }}',
Expand Down Expand Up @@ -300,6 +321,9 @@ jobs:
run: |
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
$Env:DAGENT_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsAgent*.exe' | Select -First 1
$Env:DAGENT_PEDM_DESKTOP_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsPedmDesktop.exe' | Select -First 1
$Env:DAGENT_PEDM_CONTEXT_MENU_MSIX = Get-ChildItem -Path $PackageRoot -Recurse -Include 'devolutions-pedm-contextmenu.msix' | Select -First 1
$Env:DAGENT_PEDM_HOOK = Get-ChildItem -Path $PackageRoot -Recurse -Include 'devolutions_pedm_hook.dll' | Select -First 1
./ci/tlk.ps1 package -Product agent -PackageOption generate
Expand Down Expand Up @@ -378,7 +402,7 @@ jobs:
}
- name: Verification
if: matrix.os == 'windows' || matrix.os == 'macos'
if: (matrix.os == 'windows' || matrix.os == 'macos') && env.package-env == 'publish-prod'
shell: pwsh
run: |
$RootPath = Join-Path ${{ runner.temp }} ${{ matrix.project }} ${{ matrix.os }}
Expand Down Expand Up @@ -438,13 +462,28 @@ jobs:
with:
pattern: devolutions-agent-*
merge-multiple: true

- name: Split symbols
shell: pwsh
run: |
$SymbolsPath = New-Item -ItemType Directory $(Join-Path "${{ runner.temp }}" 'symbols')
Get-ChildItem -Path "${{ github.workspace }}" -Recurse -Include '*.pdb' | % {
Move-Item $_ $SymbolsPath
}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/**/*
name: devolutions-agent
overwrite: true

- name: Upload Symbol Artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ runner.temp }}/symbols
name: devolutions-agent-symbols
overwrite: true

jetsocat-merge:
name: Merge jetsocat artifacts
Expand Down
41 changes: 37 additions & 4 deletions ci/tlk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ function New-ModulePackage
$OutputFile
}

function Get-DestinationSymbolFile {
param(
[Parameter(Mandatory=$true,Position=0)]
[string] $DestinationExecutable,
[Parameter(Mandatory=$true,Position=1)]
[TlkTarget] $Target
)

$DestinationSymbolsName = $(Split-Path $DestinationExecutable -LeafBase) + ".$($Target.SymbolsExtension)"
$DestinationDirectory = Split-Path $DestinationExecutable -Parent

Join-Path $DestinationDirectory $DestinationSymbolsName
}

function Get-TlkPlatform {
param(
[Parameter(Position=0)]
Expand Down Expand Up @@ -413,6 +427,8 @@ class TlkRecipe
"agent" {
if ($CargoPackage.Name -Eq "devolutions-agent" -And (Test-Path Env:DAGENT_EXECUTABLE)) {
$Env:DAGENT_EXECUTABLE
} elseif ($CargoPackage.Name -Eq "devolutions-pedm-hook" -And (Test-Path Env:DAGENT_PEDM_HOOK)) {
$Env:DAGENT_PEDM_HOOK
} else {
$null
}
Expand All @@ -431,9 +447,7 @@ class TlkRecipe

if ($this.Target.IsWindows() -And $DestinationExecutable) {
$SrcSymbolsPath = "${CargoOutputPath}/$($CargoPackage.SymbolsFileName($this.Target))"
$DestinationSymbolsName = $(Split-Path $DestinationExecutable -Leaf).Replace(".$($this.Target.ExecutableExtension)", ".$($this.Target.SymbolsExtension)")
$DestinationDirectory = Split-Path $DestinationExecutable -Parent
Copy-Item $SrcSymbolsPath -Destination $(Join-Path $DestinationDirectory $DestinationSymbolsName)
Copy-Item $SrcSymbolsPath -Destination $(Get-DestinationSymbolFile $DestinationExecutable $this.Target)
} elseif (!$this.Target.IsWindows()) {
$StripExecutable = 'strip'
if (Test-Path Env:STRIP_EXECUTABLE) {
Expand Down Expand Up @@ -470,13 +484,32 @@ class TlkRecipe
}

Pop-Location

if (Test-Path Env:DAGENT_PEDM_CONTEXT_MENU_MSIX) {
Copy-Item -Path $(Join-Path $CargoOutputPath "devolutions-pedm-contextmenu.msix") -Destination $Env:DAGENT_PEDM_CONTEXT_MENU_MSIX

$DestinationSymbolsFolder = Split-Path $Env:DAGENT_PEDM_CONTEXT_MENU_MSIX -Parent
Copy-Item "${CargoOutputPath}/devolutions_pedm_contextmenu.pdb" -Destination $DestinationSymbolsFolder
Copy-Item "${CargoOutputPath}/deps/devolutions_pedm_contextmenu_shell.pdb" -Destination $DestinationSymbolsFolder

}
}

Pop-Location
}

if ($this.Product -Eq "agent") {
if ($this.Product -Eq "agent" -And $this.Target.IsWindows()) {
& './crates/devolutions-pedm/DevolutionsPedmDesktop/build.ps1' | Out-Host

if (Test-Path Env:DAGENT_PEDM_DESKTOP_EXECUTABLE) {
$builtDesktopExe = Get-ChildItem -Recurse -Include 'DevolutionsPedmDesktop.exe' | Select-Object -First 1
$builtDesktopPdb = Get-ChildItem -Recurse -Include 'DevolutionsPedmDesktop.pdb' | Select-Object -First 1

Copy-Item -Path $builtDesktopExe -Destination $Env:DAGENT_PEDM_DESKTOP_EXECUTABLE

Copy-Item -Path $builtDesktopPdb -Destination $(Get-DestinationSymbolFile $Env:DAGENT_PEDM_DESKTOP_EXECUTABLE $this.Target)

}
}

Pop-Location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ilmerge" Version="3.0.41" />
<PackageReference Include="MSBuild.ILMerge.Task" Version="2.0.0-pre501" />
<PackageReference Include="StandardSocketsHttpHandler" Version="2.2.0.8" />
</ItemGroup>

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/devolutions-pedm/DevolutionsPedmDesktop/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ $ErrorActionPreference = "Stop"

Push-Location -Path $PSScriptRoot

dotnet build --configuration Release
& 'MSBuild.exe' "/t:restore,build" "/p:Configuration=Release" | Out-Host

Pop-Location
Loading

0 comments on commit 965ebf0

Please sign in to comment.