Skip to content

Commit

Permalink
feat(agent): Devolutions Agent bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmancoder committed Jun 1, 2024
1 parent f3c2ed8 commit 35a87bd
Show file tree
Hide file tree
Showing 83 changed files with 8,442 additions and 362 deletions.
123 changes: 119 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
rust-profile: ${{ steps.rust-profile.outputs.rust-profile }}
jetsocat-build-matrix: ${{ steps.setup-matrix.outputs.jetsocat-build-matrix }}
gateway-build-matrix: ${{ steps.setup-matrix.outputs.gateway-build-matrix }}
agent-build-matrix: ${{ steps.setup-matrix.outputs.agent-build-matrix }}

steps:
- name: Setup matrix
Expand Down Expand Up @@ -51,6 +52,9 @@ jobs:
$GatewayMatrix = ConvertTo-JSON $Jobs -Compress
echo "gateway-build-matrix=$GatewayMatrix" >> $Env:GITHUB_OUTPUT
$AgentMatrix = ConvertTo-JSON $Jobs -Compress
echo "agent-build-matrix=$AgentMatrix" >> $Env:GITHUB_OUTPUT
$Jobs = @()
$Platforms += 'macos'
Expand Down Expand Up @@ -211,7 +215,7 @@ jobs:
$Env:JETSOCAT_EXECUTABLE = Join-Path $TargetOutputPath $ExecutableFileName
$Env:CARGO_PACKAGE = "jetsocat"
./ci/tlk.ps1 build -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
./ci/tlk.ps1 build -Product jetsocat -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
echo "staging-path=$StagingPath" >> $Env:GITHUB_OUTPUT
Expand Down Expand Up @@ -402,7 +406,7 @@ jobs:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DGATEWAY_EXECUTABLE: ${{ steps.load-variables.outputs.dgateway-executable }}
CARGO_PACKAGE: devolutions-gateway
run: ./ci/tlk.ps1 build -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
run: ./ci/tlk.ps1 build -Product gateway -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}

- name: Build PowerShell module
if: matrix.os == 'windows'
Expand All @@ -426,8 +430,8 @@ jobs:
$Env:DGATEWAY_PSMODULE_PATH = "${{ steps.load-variables.outputs.dgateway-psmodule-output-path }}"
}
$Env:DGATEWAY_WEBCLIENT_PATH = Join-Path "webapp" "client" | Resolve-Path
./ci/tlk.ps1 package -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
./ci/tlk.ps1 package -Product gateway -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand All @@ -448,6 +452,110 @@ jobs:
pattern: devolutions-gateway-*
delete-merged: true

devolutions-agent:
name: devolutions-agent [${{ matrix.os }} ${{ matrix.arch }}]
runs-on: ${{ matrix.runner }}
needs: [preflight]
if: always()
strategy:
matrix:
include: ${{ fromJson(needs.preflight.outputs.agent-build-matrix) }}

steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
ref: ${{ needs.preflight.outputs.ref }}

- name: Load dynamic variables
id: load-variables
shell: pwsh
run: |
$PackageVersion = "${{ needs.preflight.outputs.version }}"
$StagingPath = Join-Path $Env:RUNNER_TEMP "staging"
$TargetOutputPath = Join-Path $StagingPath ${{ matrix.os }} ${{ matrix.arch }}
$ExecutableFileName = "DevolutionsAgent_${{ runner.os }}_${PackageVersion}_${{ matrix.arch }}"
if ($Env:RUNNER_OS -eq "Windows") {
$ExecutableFileName = "$($ExecutableFileName).exe"
$PackageFileName = "DevolutionsAgent-${{ matrix.arch }}-${PackageVersion}.msi"
$DAgentPackage = Join-Path $TargetOutputPath $PackageFileName
echo "dagent-package=$DAgentPackage" >> $Env:GITHUB_OUTPUT
}
$DAgentExecutable = Join-Path $TargetOutputPath $ExecutableFileName
echo "staging-path=$StagingPath" >> $Env:GITHUB_OUTPUT
echo "target-output-path=$TargetOutputPath" >> $Env:GITHUB_OUTPUT
echo "dagent-executable=$DAgentExecutable" >> $Env:GITHUB_OUTPUT
- name: Configure Linux runner
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install python3-wget python3-setuptools libsystemd-dev dh-make
- name: Configure Linux (arm) runner
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: |
sudo dpkg --add-architecture arm64
sudo apt-get -o Acquire::Retries=3 install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user
rustup target add aarch64-unknown-linux-gnu
echo "STRIP_EXECUTABLE=aarch64-linux-gnu-strip" >> $GITHUB_ENV
# WiX is installed on Windows runners but not in the PATH
- name: Configure Windows runner
if: matrix.os == 'windows'
run: |
# https://github.com/actions/runner-images/issues/9667
choco uninstall wixtoolset
choco install wixtoolset --version 3.14.0 --allow-downgrade --force
echo "C:\Program Files (x86)\WiX Toolset v3.14\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- 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

- name: Package
shell: pwsh
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
TARGET_OUTPUT_PATH: ${{ steps.load-variables.outputs.target-output-path }}
DAGENT_EXECUTABLE: ${{ steps.load-variables.outputs.dagent-executable }}
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_PACKAGE = "${{ steps.load-variables.outputs.dagent-package }}"
}
./ci/tlk.ps1 package -Product agent -Platform ${{ matrix.os }} -Architecture ${{ matrix.arch }} -CargoProfile ${{ needs.preflight.outputs.rust-profile }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: devolutions-agent-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ steps.load-variables.outputs.staging-path }}

devolutions-agent-merge:
name: devolutions agent merge artifacts
runs-on: ubuntu-latest
needs: [preflight, devolutions-agent]

steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: devolutions-agent
pattern: devolutions-agent-*
delete-merged: true

upload-git-log:
name: Upload git-log output
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -480,6 +588,8 @@ jobs:
- preflight
- devolutions-gateway
- devolutions-gateway-merge
- devolutions-agent
- devolutions-agent-merge
- jetsocat
- jetsocat-lipo
- upload-git-log
Expand Down Expand Up @@ -518,6 +628,11 @@ jobs:
name: devolutions-gateway
path: ${{ runner.temp }}/artifacts_raw

- uses: actions/download-artifact@v4
with:
name: devolutions-agent
path: ${{ runner.temp }}/artifacts_raw

- uses: actions/download-artifact@v4
with:
name: git-log
Expand Down
51 changes: 41 additions & 10 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
needs: preflight
strategy:
matrix:
project: [ jetsocat, devolutions-gateway ]
project: [ jetsocat, devolutions-gateway, devolutions-agent ]
os: [ windows, macos, linux ]
include:
- os: windows
Expand All @@ -134,6 +134,8 @@ jobs:
exclude:
- project: devolutions-gateway
os: macos
- project: devolutions-agent
os: macos

steps:
- name: Checkout ${{ github.repository }}
Expand Down Expand Up @@ -198,6 +200,7 @@ jobs:
run: |
$IncludePattern = switch ('${{ matrix.project }}') {
'devolutions-gateway' { 'DevolutionsGateway_*.exe' }
'devolutions-agent' { 'DevolutionsAgent_*.exe' }
'jetsocat' { 'jetsocat_*' }
}
$ExcludePattern = "*.pdb"
Expand Down Expand Up @@ -238,14 +241,14 @@ jobs:
gh run download ${{ needs.preflight.outputs.run }} -n webapp-client -D "$Destination"
- name: Add msbuild to PATH
if: matrix.os == 'windows' && matrix.project == 'devolutions-gateway'
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.os == 'windows'
if: (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent') && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} devolutions-gateway
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
$Env:DGATEWAY_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsGateway*.exe' | Select -First 1
$Env:DGATEWAY_PSMODULE_PATH = Join-Path $PackageRoot PowerShell DevolutionsGateway
$Env:DGATEWAY_WEBCLIENT_PATH = Join-Path "webapp" "client" | Resolve-Path
Expand All @@ -257,7 +260,7 @@ jobs:
./ci/tlk.ps1 package -PackageOption generate
- name: Sign msi runtime
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
if: (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent') && matrix.os == 'windows'
shell: pwsh
working-directory: package/WindowsManaged/Release
run: |
Expand All @@ -273,17 +276,26 @@ jobs:
AzureSignTool @Params $_.FullName
}
- name: Repackage
- name: Repackage gateway
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} devolutions-gateway
$Env:DGATEWAY_PACKAGE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsGateway*.msi' | Where-Object { $_.Name -NotLike "*legacy*"} | Select -First 1
./ci/tlk.ps1 package -PackageOption assemble
./ci/tlk.ps1 package -Product gateway -PackageOption assemble
- name: Repackage agent
if: matrix.project == 'devolutions-agent' && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} devolutions-agent
$Env:DAGENT_PACKAGE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsAgent*.msi' | Where-Object { $_.Name -NotLike "*legacy*"} | Select -First 1
./ci/tlk.ps1 package -Product agent -PackageOption assemble
- name: Sign packages
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
if: (matrix.project == 'devolutions-gateway' || matrix.project == 'devolutions-agent') && matrix.os == 'windows'
shell: pwsh
run: |
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include '*.msi' | % {
Expand Down Expand Up @@ -331,7 +343,7 @@ jobs:
retention-days: 1

devolutions-gateway-merge:
name: Merge Artifacts
name: Merge gateway artifacts
runs-on: ubuntu-latest
needs: [preflight, codesign]

Expand All @@ -349,8 +361,27 @@ jobs:
name: devolutions-gateway
overwrite: true

devolutions-agent-merge:
name: Merge agent artifacts
runs-on: ubuntu-latest
needs: [preflight, codesign]

steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: devolutions-agent-*
merge-multiple: true

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/**/*
name: devolutions-agent
overwrite: true

jetsocat-merge:
name: Merge Artifacts
name: Merge jetsocat artifacts
runs-on: ubuntu-latest
needs: [preflight, codesign]

Expand Down
Loading

0 comments on commit 35a87bd

Please sign in to comment.