From e6e24635e83d818dfcfd9012ceb429eaa07a8b6b Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Wed, 12 May 2021 04:59:18 -0700 Subject: [PATCH] Add name to Server artifact. Update installer. Update packages. --- .github/workflows/build.yml | 1 + .github/workflows/deploy-to-iis.yml | 201 ----------------------- .github/workflows/deploy-via-ssh.yml | 199 ---------------------- Agent/Agent.csproj | 4 +- Desktop.Core/Desktop.Core.csproj | 4 +- Desktop.XPlat/Desktop.XPlat.csproj | 6 +- README.md | 4 +- Server.Installer/Services/GitHubApi.cs | 4 +- Server/Server.csproj | 18 +- Shared/Shared.csproj | 2 +- Tests.LoadTester/Tests.LoadTester.csproj | 2 +- Tests/Tests.csproj | 4 +- 12 files changed, 26 insertions(+), 423 deletions(-) delete mode 100644 .github/workflows/deploy-to-iis.yml delete mode 100644 .github/workflows/deploy-via-ssh.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c471c500..534d7a0ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -186,6 +186,7 @@ jobs: uses: actions/upload-artifact@v2 with: path: ./publish/ + name: Server # Remove the pfx diff --git a/.github/workflows/deploy-to-iis.yml b/.github/workflows/deploy-to-iis.yml deleted file mode 100644 index 172ef36f0..000000000 --- a/.github/workflows/deploy-to-iis.yml +++ /dev/null @@ -1,201 +0,0 @@ -# To use this workflow to deploy Remotely: -# -# 1. Create the site in IIS, if you haven't already. -# -# 2. Set up MSDeploy on the site. -# - Right-click the site. -# - Go to Deploy - Configure Web Deploy Publishing. -# - Select the user account to use for publishing. -# - Click OK. -# -# 2. Create the below Secrets in GitHub. -# - BASE64_ENCODED_PFX -# - See below section to get this string. -# - PFX_KEY -# - The password for the certificate. -# - MSDEPLOY_USERNAME -# - The username selected when configuring MSDeploy. -# - MSDEPLOY_PASSWORD -# - The password for the above user. -# - IIS_APP_PATH -# - The IIS site name. -# - SITE_URL -# - The public URL of the website (e.g. https://app.remotely.one). -# -# Secrets are created in GitHub under the repository (your forked repository, -# not the lucent-sea/Remotely repository). They are only usable by you and -# collaborators that you've allowed on your repo. After being set, they are -# not visible or displayed anywhere, even to yourself. -# -# If you don't want to sign your EXEs, skip creating the BASE64_ENCODED_PFX -# and PFX_KEY secrets. They won't be used. -# -# -# 3. Getting the Base64-Encoded PFX -# To get the base64-encoded certificate, use the below PowerShell snippet, -# using your PFX file name. -# -# $Pfx_Cert = Get-Content '.\Remotely_Cert.pfx' -Encoding Byte -# [System.Convert]::ToBase64String($Pfx_Cert) | clip -# -# The base64-encoded string is now in your clipboard. You can paste -# it into GitHub when creating the Secret. -# -# 4. Deploying to IIS -# On GitHub, go to your forked repo, then to Actions. On the left, select -# "Deploy to IIS" action underneath "All Workflows". There should be a -# banner saying "This workflow has a workflow_dispatch event trigger." -# -# Click "Run workflow" and select the branch you want to deploy. -# -# 5. Keeping Your Fork Updated -# You'll want to keep your fork updated so you can deploy the latest -# changes. There are a few ways to do it, and they're easy to find -# with a little Googling. -# -# Once your branch has been updated, you can run the -# workflow again manually in GitHub to re-deploy. - -name: Deploy To IIS - -on: - # Uncomment these for automatic deployment. - # push: - # branches: [ master ] - # pull_request: - # branches: [ master ] - workflow_dispatch: - -jobs: - - build: - - strategy: - matrix: - configuration: [Release] - - runs-on: windows-latest # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - - env: - Solution_Name: Remotely.sln # Replace with your solution name, i.e. MyWpfApp.sln. - Configuration: ${{ matrix.configuration }} - Test_Project_Path: Tests\Tests.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. - PfxBase64: ${{ secrets.BASE64_ENCODED_PFX }} - PfxKey: ${{ secrets.PFX_KEY }} - MsDeployUsername: ${{ secrets.MSDEPLOY_USERNAME }} - MsDeployPassword: ${{ secrets.MSDEPLOY_PASSWORD }} - IisAppPath: ${{ secrets.IIS_APP_PATH }} - SiteUrl: ${{ secrets.SITE_URL }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # Install the .NET Core workload - - name: Install .NET Core - uses: actions/setup-dotnet@v1.7.2 - - # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1 - - # Execute all unit tests in the solution - - name: Execute unit tests - run: dotnet test - - # Restore the application to populate the obj folder with RuntimeIdentifiers - - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration - - # Decode the base 64 encoded pfx and save the Signing_Certificate - - name: Decode the pfx - run: | - if (!($env:PfxBase64)) { - echo "Skipping cert signing because Base64_Encoded_Pfx secret is missing." - return - } - - echo "Creating Pfx for signing assemblies." - - $pfx_cert_byte = [System.Convert]::FromBase64String($env:PfxBase64) - $certificatePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath GitHubActionsWorkflow.pfx - echo "Writing file to $certificatePath." - [IO.File]::WriteAllBytes($certificatePath, $pfx_cert_byte) - - # Store the assembly version in an environment variable - - name: Set current version - shell: powershell - run: | - $VersionString = git show -s --format=%ci - $VersionDate = [DateTimeOffset]::Parse($VersionString) - - $Year = $VersionDate.Year.ToString() - $Month = $VersionDate.Month.ToString().PadLeft(2, "0") - $Day = $VersionDate.Day.ToString().PadLeft(2, "0") - $Hour = $VersionDate.Hour.ToString().PadLeft(2, "0") - $Minute = $VersionDate.Minute.ToString().PadLeft(2, "0") - $CurrentVersion = "$Year.$Month.$Day.$Hour$Minute" - - echo "::set-env name=CurrentVersion::$CurrentVersion" - # This was needed in Azure Pipelines. - #[System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion") - - Write-Host "Setting current version to $CurrentVersion." - - # Create MSDeploy Publishing Profile - - name: Create MSDeploy Profile - shell: powershell - run: | - $PublishProfile = @" - - - - MSDeploy - Release - x64 - $($env:SiteUrl):80/ - False - False - 3e835099-c417-4d82-8d5c-13dc09af48ac - $($env:SiteUrl):8172/msdeploy.axd - $env:IisAppPath - - True - WMSVC - True - $env:MsDeployUsername - net5.0 - true - true - win-x64 - - - "@ - - New-Item -Path "$env:GITHUB_WORKSPACE\Server\Properties\PublishProfiles\" -ItemType Directory -Force - Set-Content -Path "$env:GITHUB_WORKSPACE\Server\Properties\PublishProfiles\DeployIIS.pubxml" -Value $PublishProfile -Force - - # Run the Publish script to build clients and server. - - name: Run Publish script - shell: powershell - run: | - .\Utilities\Publish.ps1 -CertificatePath "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx" -CertificatePassword $env:PfxKey -Hostname $env:SiteUrl -CurrentVersion $env:CurrentVersion -RID win-x64 -OutDir "$env:GITHUB_WORKSPACE\publish" - - # Upload build artifact to be deployed from Ubuntu runner - - name: Upload build artifact - uses: actions/upload-artifact@v2 - with: - path: ./publish/ - - # Publish server to IIS - - name: Publish - run: | - echo "Publishing with configuration $env:Configuration." - dotnet publish /p:Platform="x64" /p:Configuration="$env:Configuration" /p:PublishProfile="DeployIIS" /p:Password=$env:MsDeployPassword /p:Version=$env:CurrentVersion /p:FileVersion=$env:CurrentVersion ".\Server" - - # Remove the pfx - - name: Remove the pfx - run: Remove-Item -path $env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx diff --git a/.github/workflows/deploy-via-ssh.yml b/.github/workflows/deploy-via-ssh.yml deleted file mode 100644 index df4f0358b..000000000 --- a/.github/workflows/deploy-via-ssh.yml +++ /dev/null @@ -1,199 +0,0 @@ -# To use this workflow to deploy Remotely: -# -# IMPORTANT: You must run the install script as sudo first before using this -# GitHub workflow. This will only deploy the updated files. -# The script will install dependencies, create the systemd -# ervice, create the Nginx site, etc. -# -# 1. Set up SSH on your Ubuntu server. There are plenty of articles on -# the internet that describe the process. Here's a good one: -# https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-1604 -# -# It's a good idea to turn off password-based authentication. -# -# -# 2. Create the below Secrets in GitHub. -# - BASE64_ENCODED_PFX -# - See below section to get this string. -# - PFX_KEY -# - The password for the certificate. -# - SSH_USERNAME -# - Username to use for SSH connection. -# - SSH_PRIVATE_KEY -# - The private key to use for SSH. -# - SSH_HOSTNAME -# - The hostname or IP to use for the SSH connection. -# - SSH_KNOWN_HOSTS -# - The content to go into your known_hosts file. This should -# contain the fingerprint for the SSH host (e.g. "{hostname} {public key}") -# - SITE_URL -# - The public hostname for the site (e.g. https://app.remotely.one). -# This can be an IP if it's only going to be used on the local network -# with HTTP. -# -# Secrets are created in GitHub under the repository (your forked repository, -# not the lucent-sea/Remotely repository). They are only usable by you and -# collaborators that you've allowed on your repo. After being set, they are -# not visible or displayed anywhere, even to yourself. -# -# If you don't want to sign your EXEs, skip creating the BASE64_ENCODED_PFX -# and PFX_KEY secrets. They won't be used. -# -# -# 3. Getting the Base64-Encoded PFX -# To get the base64-encoded certificate, use the below PowerShell snippet, -# using your PFX file name. -# -# $Pfx_Cert = Get-Content '.\Remotely_Cert.pfx' -Encoding Byte -# [System.Convert]::ToBase64String($Pfx_Cert) | clip -# -# The base64-encoded string is now in your clipboard. You can paste -# it into GitHub when creating the Secret. -# -# -# 3. Deploying via SSH -# -# On GitHub, go to your forked repo, then to Actions. On the left, select -# "Deploy via SSH" action underneath "All Workflows". There should be a -# banner saying "This workflow has a workflow_dispatch event trigger." -# -# Click "Run workflow" and select the branch you want to deploy. -# -# 5. Keeping Your Fork Updated -# You'll want to keep your fork updated so you can deploy the latest -# changes. There are a few ways to do it, and they're easy to find -# with a little Googling. -# -# Once your branch has been updated, you can run the -# workflow again manually in GitHub to re-deploy. - -name: Deploy via SSH - -on: - # Uncomment these for automatic deployment. - # push: - # branches: [ master ] - # pull_request: - # branches: [ master ] - workflow_dispatch: - -jobs: - - build: - - strategy: - matrix: - configuration: [Release] - - runs-on: windows-latest # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on - - env: - Solution_Name: Remotely.sln # Replace with your solution name, i.e. MyWpfApp.sln. - Configuration: ${{ matrix.configuration }} - Test_Project_Path: Tests\Tests.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj. - PfxBase64: ${{ secrets.BASE64_ENCODED_PFX }} - PfxKey: ${{ secrets.PFX_KEY }} - SiteUrl: ${{ secrets.SITE_URL }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # Install the .NET Core workload - - name: Install .NET Core - uses: actions/setup-dotnet@v1.7.2 - - # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1 - - # Execute all unit tests in the solution - - name: Execute unit tests - run: dotnet test - - # Restore the application to populate the obj folder with RuntimeIdentifiers - - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration - - # Decode the base 64 encoded pfx and save the Signing_Certificate - - name: Decode the pfx - run: | - if (!($env:PfxBase64)) { - echo "Skipping cert signing because Base64_Encoded_Pfx secret is missing." - return - } - - echo "Creating Pfx for signing assemblies." - - $pfx_cert_byte = [System.Convert]::FromBase64String($env:PfxBase64) - $certificatePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath GitHubActionsWorkflow.pfx - echo "Writing file to $certificatePath." - [IO.File]::WriteAllBytes($certificatePath, $pfx_cert_byte) - - # Store the assembly version in an environment variable - - name: Set current version - shell: powershell - run: | - $VersionString = git show -s --format=%ci - $VersionDate = [DateTimeOffset]::Parse($VersionString) - - $Year = $VersionDate.Year.ToString() - $Month = $VersionDate.Month.ToString().PadLeft(2, "0") - $Day = $VersionDate.Day.ToString().PadLeft(2, "0") - $Hour = $VersionDate.Hour.ToString().PadLeft(2, "0") - $Minute = $VersionDate.Minute.ToString().PadLeft(2, "0") - $CurrentVersion = "$Year.$Month.$Day.$Hour$Minute" - - echo "::set-env name=CurrentVersion::$CurrentVersion" - # This was needed in Azure Pipelines. - #[System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion") - - Write-Host "Setting current version to $CurrentVersion." - - # Run the Publish script to build clients and server. - - name: Run Publish script - shell: powershell - run: | - .\Utilities\Publish.ps1 -CertificatePath "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx" -CertificatePassword $env:PfxKey -Hostname $env:SiteUrl -CurrentVersion $env:CurrentVersion -RID linux-x64 -OutDir "$env:GITHUB_WORKSPACE\publish" - - # Upload build artifact to be deployed from Ubuntu runner - - name: Upload build artifact - uses: actions/upload-artifact@v2 - with: - path: ./publish/ - - - # Remove the pfx - - name: Remove the pfx - run: Remove-Item -path "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx" - - deploy: - runs-on: ubuntu-latest - needs: build - env: - SshUsername: ${{ secrets.SSH_USERNAME }} - SshPrivateKey: ${{ secrets.SSH_PRIVATE_KEY }} - SshHostname: ${{ secrets.SSH_HOSTNAME }} - - steps: - - # Install SSH Key - - name: Install SSH Key - uses: shimataro/ssh-key-action@v2.1.0 - with: - # SSH private key - key: ${{ secrets.SSH_PRIVATE_KEY }} - # public keys of SSH servers - known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} - - # Download Build Artifact - - name: Download build artifact - uses: actions/download-artifact@v2 - - - name: Publish - shell: bash - run: | - rsync -r -v ./artifact/ $SshUsername@$SshHostname:/var/www/remotely/ diff --git a/Agent/Agent.csproj b/Agent/Agent.csproj index c9964b9c0..bf7c12d7a 100644 --- a/Agent/Agent.csproj +++ b/Agent/Agent.csproj @@ -23,11 +23,11 @@ - + - + diff --git a/Desktop.Core/Desktop.Core.csproj b/Desktop.Core/Desktop.Core.csproj index 66f9c71f4..877855859 100644 --- a/Desktop.Core/Desktop.Core.csproj +++ b/Desktop.Core/Desktop.Core.csproj @@ -40,8 +40,8 @@ - - + + diff --git a/Desktop.XPlat/Desktop.XPlat.csproj b/Desktop.XPlat/Desktop.XPlat.csproj index 4b7763f8b..0725752e0 100644 --- a/Desktop.XPlat/Desktop.XPlat.csproj +++ b/Desktop.XPlat/Desktop.XPlat.csproj @@ -52,9 +52,9 @@ - - - + + + diff --git a/README.md b/README.md index c9a74417d..44d23d207 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ However, you can also choose to install the pre-built packages that do not have - If you want to use the pre-built package, run the installer now, and you're done! - Otherwise, follow the below steps for setting up the GitHub Actions integration, then run the installer afterward. - Fork the repo if you haven't already. - - If you've already forked the repo and haven't updated your fork since the new installer was created, you'll need to do so first. - - You can use the following commands to pull the latest changes, merge them, and push them back up to your repo ([git](https://git-scm.com/downloads) required). Make sure to replace `{your-username}` with your GitHub username. + - If you've already forked the repo and haven't updated your fork recently, you'll need to do so first. + - You can use the following commands to pull the latest changes, merge them, and push them back up to your repo ([git](https://git-scm.com/downloads) required). Make sure to replace `{your-username}` with your GitHub username. This example assumes you've added your SSH key to your GitHub account. ``` git clone git@github.com:{your-username}/remotely cd ./remotely diff --git a/Server.Installer/Services/GitHubApi.cs b/Server.Installer/Services/GitHubApi.cs index 3d98cdfa7..abc7471b7 100644 --- a/Server.Installer/Services/GitHubApi.cs +++ b/Server.Installer/Services/GitHubApi.cs @@ -95,7 +95,9 @@ public async Task GetLatestBuildArtifact(CliParams cliParams) return null; } - return payload.artifacts.OrderByDescending(x => x.created_at).First(); + return payload.artifacts + .OrderByDescending(x => x.created_at) + .FirstOrDefault(x=>x.name.Equals("Server", StringComparison.OrdinalIgnoreCase)); } catch (Exception ex) { diff --git a/Server/Server.csproj b/Server/Server.csproj index b42b2607d..c76d24dd2 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -24,13 +24,13 @@ - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -42,8 +42,8 @@ - - + + diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 05a4dbbe8..614471527 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -10,7 +10,7 @@ - + diff --git a/Tests.LoadTester/Tests.LoadTester.csproj b/Tests.LoadTester/Tests.LoadTester.csproj index 8987b5a85..a368ae5b4 100644 --- a/Tests.LoadTester/Tests.LoadTester.csproj +++ b/Tests.LoadTester/Tests.LoadTester.csproj @@ -8,7 +8,7 @@ - + diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index c7959f149..bb8c375bb 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -23,8 +23,8 @@ - - + +