Skip to content

Commit

Permalink
Add Build workflow with input parameters. Update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Mar 26, 2021
1 parent 43eaac3 commit 4946384
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 13 deletions.
148 changes: 148 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# IMPORTANT:
# 1. The Server URL must include the scheme (e.g. https://app.remotely.one).

# 2. The Server Runtime Identifier determines the target operating system
# for which to build the server. The default "linux-x64" will usually work
# for most Linux-based operating systems. You can see a full list at
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog.

# 2. You'll want to keep your fork updated so you can build the latest
# changes. On the GitHub page for your repo, you'll see a message that says,
# "This branch is ## commits behind lucent-sea:master."
#
# Click the "Pull request link next to it."
#
# On the next page click the "switching the base" link. Now it's pulling from
# my repo into yours. Create and complete the pull request to update your repo.
#
# Once your branch has been updated, you can run this workflow again
# to build the latest version.

name: Build

on:
workflow_dispatch:
inputs:
serverUrl:
description: 'Server URL'
required: true
rid:
description: 'Server Runtime Identifier'
required: false
default: "linux-x64"

jobs:

build:

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
Configuration: Release
PfxBase64: ${{ secrets.BASE64_ENCODED_PFX }}
PfxKey: ${{ secrets.PFX_KEY }}
SiteUrl: ${{ github.event.inputs.serverUrl }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

# Install the .NET Core workload
- name: Install .NET Core
uses: actions/[email protected]

# 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/[email protected]
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/
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ A remote control and remote scripting solution, built with .NET Core, SignalR Co
![GitHub Build](https://github.com/lucent-sea/Remotely/workflows/GitHub%20Build/badge.svg)


> NOTE: Active development has been suspended.
>
> I will be (mostly) taking a break from Remotely during 2021 to make more time for family, self-care, and other interests.
>
> Take care and stay safe.
>
> \- Jared
## Donations
If this project has benefited you in some way, or if you just want to show appreciation, please consider donating to a charity.

Expand All @@ -35,6 +27,10 @@ Hosting a Remotely server requires building and running an ASP.NET Core web app

It's *highly* encouraged that you get comfortable building and deploying from source. This allows you to hard-code your server's hostname into the desktop client and the installer, which makes for a better experience for the end user. If you don't want to use any of the methods below, you can look at the GitHub Actions workflows to see how the process can be automated, using the `Publish.ps1` script. You can use those as reference for creating an automation process that works for you. You can also use Azure Pipelines for free (which I personally use).

## Build Instructions (GitHub)
GitHub Actions allows you to build and deploy Remotely for free from their cloud servers. The definitions for the build processes are located in `/.github/workflows/` folder.

After forking the repo, follow the instructions in the workflow YML file. The easiest workflow to use is the Build.yml worfklow. It doesn't require setting any GitHub secrets and is the easiest to use. I'd recommend starting with that one. It will produce a build artifact (ZIP package) identical to what is on the Releases page, only the clients will have your server URL hard-coded.

## Hosting a Server (Windows)
* Create a site in IIS that will run Remotely.
Expand Down Expand Up @@ -74,11 +70,6 @@ There are countless ways to host an ASP.NET Core app, and I can't document or au
- https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/


## Build Instructions (GitHub)
GitHub Actions allows you to build and deploy Remotely for free from their cloud servers. The definitions for the build processes are located in `/.github/workflows/` folder.

After forking the repo, follow the instructions in the workflow YML file for configuring GitHub Secrets, then run the workflow.

## Build Instructions (Windows 10)
The following steps will configure your Windows 10 machine for building the Remotely server and clients.
* Install Visual Studio 2019.
Expand Down

0 comments on commit 4946384

Please sign in to comment.