forked from immense/Remotely
-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (155 loc) · 7.1 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# 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-mac:
runs-on: macos-10.15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install .NET Core
uses: actions/[email protected]
- name: Setup NuGet.exe for use with actions
uses: NuGet/[email protected]
- name: Set current version
shell: pwsh
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 "CurrentVersion=$CurrentVersion" >> $env:GITHUB_ENV
Write-Host "Setting current version to $CurrentVersion."
- name: Publish macOS x64 Agent
shell: pwsh
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"
Write-Host "Publishing agent with version $CurrentVersion"
dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion --runtime osx-x64 --configuration Release --output "./Agent/bin/publish/" "./Agent/"
Compress-Archive -Path "./Agent/bin/publish/*" -DestinationPath "./Agent/bin/Remotely-MacOS-x64.zip" -Force
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
path: ./Agent/bin/Remotely-MacOS-x64.zip
name: Mac-Agent-x64
build-windows:
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
needs: build-mac
env:
Solution_Name: Remotely.sln
Configuration: Release
PfxBase64: ${{ secrets.BASE64_ENCODED_PFX }}
PfxKey: ${{ secrets.PFX_KEY }}
ServerUrl: ${{ github.event.inputs.serverUrl }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Comment out the below 'repository' line if you want to build from
# your fork instead of the author's.
repository: lucent-sea/Remotely
fetch-depth: 0
# Test the Server URL to make sure it's valid
- name: Check Server URL Format
run: |
$Result = ""
if (![System.Uri]::TryCreate($env:ServerUrl, [System.UriKind]::Absolute, [ref] $Result)) {
throw "Server URL is not in the correct format. It should be fully qualified with scheme and host (e.g. https://app.remotely.one)."
}
# 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 "CurrentVersion=$CurrentVersion" >> $env:GITHUB_ENV
Write-Host "Setting current version to $CurrentVersion."
- name: Download macOS x64 Agent
uses: actions/download-artifact@v2
with:
name: Mac-Agent-x64
path: ./Server/wwwroot/Content/
# 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:ServerUrl -CurrentVersion $env:CurrentVersion -RID ${{ github.event.inputs.rid }} -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/
name: Server
# Remove the pfx
- name: Remove the pfx
run: |
if (Test-Path "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx") {
Remove-Item -path "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx"
}