-
Notifications
You must be signed in to change notification settings - Fork 7
299 lines (286 loc) · 9.97 KB
/
radius-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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name: Radius Build
on:
push:
branches: [bicep-extensibility]
tags:
- v*
pull_request:
branches: [bicep-extensibility]
workflow_dispatch:
env:
CI: true
# don't print dotnet logo
DOTNET_NOLOGO: true
# disable telemetry (reduces dotnet tool output in logs)
DOTNET_CLI_TELEMETRY_OPTOUT: true
RELEASE_PATH: ./release
# ORAS (OCI Registry As Storage) CLI version
ORAS_VERSION: 1.1.0
# Container registry url for GitHub container registry.
CONTAINER_REGISTRY: 'ghcr.io/radius-project/radius'
# URL to get source code for building the image
IMAGE_SRC: https://github.com/radius-project/bicep
jobs:
build:
name: Build Bicep - ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
# should be the full list of RIDs that we support in the CLI
matrix:
include:
- os: windows-latest
rid: win-x64
name: windows-x64
ext: '.exe'
- os: windows-latest
rid: win-arm64
name: windows-arm64
ext: '.exe'
- os: ubuntu-latest
rid: linux-x64
name: linux-x64
ext: ''
- os: ubuntu-latest
rid: linux-arm
name: linux-arm
ext: ''
- os: ubuntu-latest
rid: linux-arm64
name: linux-arm64
ext: ''
- os: macos-latest
rid: osx-x64
name: macos-x64
ext: ''
- os: macos-latest
rid: osx-arm64
name: macos-arm64
ext: ''
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Publish Bicep ${{ matrix.name }}
run: >
dotnet publish ./src/Bicep.Cli/Bicep.Cli.csproj
--configuration Release
--self-contained true
-p:PublishTrimmed=true
-p:PublishSingleFile=true
-p:TrimmerDefaultAction=copyused
-p:SuppressTrimAnalysisWarnings=true
-r ${{ matrix.rid }}
-o ./artifacts/bicep/${{ matrix.name }}
- name: Test
if: ${{ matrix.name == 'linux-x64' }}
run: dotnet test --configuration release --blame --collect:"XPlat Code Coverage" --settings ./.github/workflows/codecov.runsettings --results-directory ./TestResults/
- name: Upload Test Results
if: ${{ matrix.name == 'linux-x64' }}
uses: actions/upload-artifact@v4
with:
name: Bicep.TestResults
path: ./TestResults/**/*.trx
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.name }}
path: ./artifacts
if-no-files-found: error
- name: Move rad-bicep to release directory
shell: bash
run: |
mkdir ${{ env.RELEASE_PATH }}
cp ./artifacts/bicep/${{ matrix.name }}/rad-bicep${{ matrix.ext }} ./release/$release_file
env:
release_file: rad-bicep-${{ matrix.name }}${{ matrix.ext }}
- name: Upload rad-bicep
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.name }}
path: ${{ env.RELEASE_PATH }}
if-no-files-found: error
vscode-bicep-build:
name: Build Bicep vscode extension
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 16
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Publish Language Server
run: >
dotnet publish --configuration release
./src/Bicep.LangServer/Bicep.LangServer.csproj
-o "./src/vscode-bicep/bicepLanguageServer"
- name: npm ci
run: npm ci
working-directory: ./src/vscode-bicep
- name: Enable params
run: npm run params
working-directory: ./src/vscode-bicep
- name: Run lint
run: npm run lint
working-directory: ./src/vscode-bicep
- name: Run unit tests
run: npm run test:unit
working-directory: ./src/vscode-bicep
- name: Run snapshot tests
run: npm run test:snapshot
working-directory: ./src/vscode-bicep
- name: Build prod
run: npm run build:prod
working-directory: ./src/vscode-bicep
- name: Create VSIX
run: npm run package
working-directory: ./src/vscode-bicep
- name: Copy VSIX
run: >
mkdir -p ./artifacts/vscode &&
cp ./src/vscode-bicep/rad-vscode-bicep.vsix ./artifacts/vscode/rad-vscode-bicep.vsix
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: ./artifacts
if-no-files-found: error
- name: Copy VSIX to release
run: >
mkdir -p ${{ env.RELEASE_PATH }}/vscode &&
cp ./src/vscode-bicep/rad-vscode-bicep.vsix ${{ env.RELEASE_PATH }}/rad-vscode-bicep.vsix
- name: Upload VSIX to release
uses: actions/upload-artifact@v4
with:
name: release-vscode-ext
path: ${{ env.RELEASE_PATH }}
if-no-files-found: error
publish_release:
if: startsWith(github.ref, 'refs/tags/v')
name: Publish to GitHub Release
needs: ["build", "vscode-bicep-build"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py
- name: Download releases
uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: ${{ env.RELEASE_PATH }}
- name: generate checksum files
run: cd ${{ env.RELEASE_PATH }} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd -
- name: Display release
run: ls -R
working-directory: ./release
- name: Pre-release
if: ${{ contains(env.REL_VERSION, '-rc') }}
run: |
gh release create v${{ env.REL_VERSION }} \
${{ env.RELEASE_PATH }}/* \
--generate-notes \
--prerelease \
--verify-tag \
--title "Radius Bicep v${{ env.REL_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }}
- name: Official release
if: ${{ !contains(env.REL_VERSION, '-rc') }}
run: |
gh release create v${{ env.REL_VERSION }} \
${{ env.RELEASE_PATH }}/* \
--generate-notes \
--verify-tag \
--title "Radius Bicep v${{ env.REL_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }}
publish:
if: ${{ github.event_name == 'push' }}
name: Publish to GHCR
needs: ["build", "vscode-bicep-build"]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
runtime:
- name: windows-x64
id: win-x64
extension: .exe
- name: windows-arm64
id: win-arm64
extension: .exe
- name: linux-x64
id: linux-x64
- name: linux-arm
id: linux-arm
- name: linux-arm64
id: linux-arm64
- name: macos-x64
id: osx-x64
- name: macos-arm64
id: osx-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
submodules: true
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts-${{ matrix.runtime.name }}
path: artifacts
- name: Display artifacts
run: ls -R
working-directory: ./artifacts
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: oras-project/setup-oras@main
with:
version: ${{ env.ORAS_VERSION }}
- run: oras version
- name: Push rad bicep binaries to GHCR (${{ matrix.runtime.name }})
run: |
cd ./artifacts/bicep/${{ matrix.runtime.name }} && oras push --annotation "org.opencontainers.image.source=${{ env.IMAGE_SRC }}" ${{ env.CONTAINER_REGISTRY }}/bicep/rad-bicep/${{ matrix.runtime.name }}:${{ env.UPDATE_RELEASE == 'true' && env.REL_CHANNEL || 'latest' }} ./rad-bicep${{ matrix.runtime.extension }}
- name: Check uploaded
run: curl --fail ${{ env.CONTAINER_REGISTRY }}/bicep/rad-bicep/${{ matrix.runtime.name }}:latest -v > out