From 269a4af51db5577cd12953a5afb02e48ae4e7da2 Mon Sep 17 00:00:00 2001 From: Vladyslav Nikonov Date: Sat, 1 Jun 2024 15:05:06 +0300 Subject: [PATCH] Added Devolutions Agent to CI --- .github/workflows/ci.yml | 123 ++++++++++++++++++++++++++++++++-- .github/workflows/package.yml | 51 +++++++++++--- 2 files changed, 160 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a06f40b97..6a8e6e298 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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' @@ -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 @@ -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' @@ -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 @@ -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 @@ -480,6 +588,8 @@ jobs: - preflight - devolutions-gateway - devolutions-gateway-merge + - devolutions-agent + - devolutions-agent-merge - jetsocat - jetsocat-lipo - upload-git-log @@ -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 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 971b0df10..740f5cc29 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -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 @@ -134,6 +134,8 @@ jobs: exclude: - project: devolutions-gateway os: macos + - project: devolutions-agent + os: macos steps: - name: Checkout ${{ github.repository }} @@ -198,6 +200,7 @@ jobs: run: | $IncludePattern = switch ('${{ matrix.project }}') { 'devolutions-gateway' { 'DevolutionsGateway_*.exe' } + 'devolutions-agent' { 'DevolutionsAgent_*.exe' } 'jetsocat' { 'jetsocat_*' } } $ExcludePattern = "*.pdb" @@ -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 @@ -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: | @@ -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' | % { @@ -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] @@ -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]