-
Notifications
You must be signed in to change notification settings - Fork 202
217 lines (197 loc) · 8.12 KB
/
server-edge.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Server (.NET) - Edge
on:
push:
paths:
- '.github/workflows/server-edge.yml'
- 'source/**'
- '!source/WebApp/**'
- '!source/Container/**'
- '!source/Container.Manager/**'
- '!source/#external/Fragile/**'
- '!source/#external/mirrorsharp/WebAssets/**'
- '!source/#external/mirrorsharp-codemirror-6-preview/WebAssets/**'
pull_request:
workflow_dispatch:
jobs:
build-core:
name: 'Build (.NET 8)'
# https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: windows-latest
env:
NUGET_PACKAGES: ${{github.workspace}}/.nuget/packages
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- uses: microsoft/setup-msbuild@v1.1
# https://github.com/actions/setup-dotnet/issues/155
- run: dotnet nuget locals all --clear
- uses: actions/cache@v3
with:
path: ${{github.workspace}}/.nuget/packages
key: nuget-server-${{hashFiles('**/*.csproj')}}
# can restore caches from container-host as well, but should not overwrite them
restore-keys: |
nuget-
# https://github.com/dotnet/sdk/issues/13281
- run: dotnet nuget add source https://ci.appveyor.com/nuget/vanara-prerelease
- run: msbuild source/Native.Profiler/Native.Profiler.vcxproj /p:SolutionName=SharpLab /p:Configuration=Release /p:Platform=x64
- run: dotnet build source/Tests --configuration Release
# Tests do not reference that one yet
- run: dotnet build source/WebApp.Server --configuration Release
- run: dotnet test source/Tests --no-build --configuration Release
- run: dotnet publish source/Server --no-build --configuration Release
- run: dotnet publish source/WebApp.Server --no-build --configuration Release /p:ErrorOnDuplicatePublishOutputFiles=false
- run: Compress-Archive -Path 'source/Server/bin/Release/net8.0/publish/*' -DestinationPath 'Server.zip'
shell: pwsh
- run: Compress-Archive -Path 'source/WebApp.Server/bin/Release/net8.0/publish/*' -DestinationPath 'WebApp.Server.zip'
shell: pwsh
- uses: actions/upload-artifact@v3
with:
name: Server
path: Server.zip
- uses: actions/upload-artifact@v3
with:
name: WebApp.Server
path: WebApp.Server.zip
deploy-core:
strategy:
matrix:
include:
- name: 'WebApp Server / Default'
artifact: WebApp.Server
app: sharplab-edge
url: https://edge.sharplab.io
environment: edge-server
- name: x64
artifact: Server
app: sl-a-edge-core-x64
url: https://sl-a-edge-core-x64.azurewebsites.net/status
environment: edge-server-x64
name: 'Deploy to Edge (${{ matrix.name }})'
runs-on: ubuntu-latest
needs: build-core
if: github.ref == 'refs/heads/main'
environment: ${{ matrix.environment }}
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.artifact }}
- uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/webapps-deploy@v2
with:
app-name: ${{ matrix.app }}
package: ${{ matrix.artifact }}.zip
- run: Invoke-RestMethod "${{ matrix.url }}" -MaximumRetryCount 10 -RetryIntervalSec 2
shell: pwsh
build-netfx:
name: 'Build (.NET Framework)'
# https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
# https://github.com/actions/setup-dotnet/issues/155
- run: dotnet nuget locals all --clear
- run: dotnet build source/NetFramework/Tests --configuration Release
- run: dotnet test source/NetFramework/Tests --no-build --configuration Release
- run: dotnet publish source/NetFramework/Server --no-build --configuration Release
- run: Compress-Archive -Path 'source/NetFramework/Server/bin/publish/*' -DestinationPath 'Server.NetFramework.zip'
shell: pwsh
- uses: actions/upload-artifact@v3
with:
name: Server.NetFramework
path: Server.NetFramework.zip
deploy-netfx:
strategy:
matrix:
include:
- name: '.NET Framework, x86'
app: sl-a-edge-netfx
url: https://sl-a-edge-netfx.azurewebsites.net/status
environment: edge-server-netfx
- name: '.NET Framework, x64'
app: sl-a-edge-netfx-x64
url: https://sl-a-edge-netfx-x64.azurewebsites.net/status
environment: edge-server-netfx-x64
name: 'Deploy to Edge (${{ matrix.name }})'
runs-on: ubuntu-latest
needs: build-netfx
if: github.ref == 'refs/heads/main'
environment: ${{ matrix.environment }}
steps:
- uses: actions/download-artifact@v3
with:
name: Server.NetFramework
- uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: azure/webapps-deploy@v2
with:
app-name: ${{ matrix.app }}
package: Server.NetFramework.zip
- run: Invoke-RestMethod "${{ matrix.url }}" -MaximumRetryCount 10 -RetryIntervalSec 2
shell: pwsh
# Since we are deploying to the edge, we can actually create
# a proper release _after_ deployment -- only main needs to
# have the release, and this avoids too many failed releases.
create-release:
name: 'Create Release'
runs-on: ubuntu-latest
needs:
- deploy-core
- deploy-netfx
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- run: 'git show ${{ github.sha }} --format="version_number=%cd" --date=format:%Y-%m-%d-%H%M --no-patch >> $GITHUB_OUTPUT'
id: version
- uses: actions/download-artifact@v3
- uses: actions/create-release@v1
id: create_release
with:
tag_name: server-release-${{ steps.version.outputs.version_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Run actions/upload-release-asset@v1: WebApp.Server.zip'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./WebApp.Server/WebApp.Server.zip
asset_name: WebApp.Server.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Run actions/upload-release-asset@v1: Server.zip'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Server/Server.zip
asset_name: Server.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Run actions/upload-release-asset@v1: Server.NetFramework.zip'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Server.NetFramework/Server.NetFramework.zip
asset_name: Server.NetFramework.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}