-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (209 loc) · 7.54 KB
/
dotnet.6.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
name: 6.Todo Build (auto versioning)
on:
push:
branches: [ main ]
paths-ignore:
- '**/**.md'
- './img/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
PROJECT_PATH_TODO_UI: './src/todo.ui/todo.ui.csproj'
PROJECT_PATH_TODO_REPO: './src/todo.repo/todo.repo.csproj'
PROJECT_PATH_TODO_INFRA_BICEP: './src/todo.infra/azuredeploy.bicep'
PROJECT_PATH_TODO_INFRA_JSON: './src/todo.infra/azuredeploy.json'
PROJECT_OUT_PATH_TODO_UI: './out/todo.ui'
PROJECT_OUT_PATH_TODO_REPO: './out/todo.repo'
PROJECT_DIR_PATH_TODO_INFRA: './src/todo.infra/'
RESOURCE_GROUP: tododevops-dev
PROJECT_PATH_TODO_INFRA_PARAM: './src/todo.infra/azuredeploy.parameters.dev.json'
jobs:
build_repo:
needs: create_draft_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Build projects
- name: build and publish todo repo
run: |
dotnet restore ${{env.PROJECT_PATH_TODO_REPO}}
dotnet build ${{env.PROJECT_PATH_TODO_REPO}} --configuration Release
dotnet publish ${{env.PROJECT_PATH_TODO_REPO}} -c Release -o '${{ env.PROJECT_OUT_PATH_TODO_REPO }}'
# upload artifacts
- name: upload repo artifacts
uses: actions/upload-artifact@v2
with:
name: package.repo
path: '${{ env.PROJECT_OUT_PATH_TODO_REPO }}'
build_ui:
needs: create_draft_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build and publish todo ui
run: |
dotnet restore ${{env.PROJECT_PATH_TODO_UI}}
dotnet build ${{env.PROJECT_PATH_TODO_UI}} --configuration Release
dotnet publish ${{env.PROJECT_PATH_TODO_UI}} -c Release -o '${{ env.PROJECT_OUT_PATH_TODO_UI }}'
# upload artifacts
- name: upload ui artifacts
uses: actions/upload-artifact@v2
with:
name: package.ui
path: '${{ env.PROJECT_OUT_PATH_TODO_UI }}'
deploy_infra_dev:
needs: create_draft_release
runs-on: ubuntu-latest
outputs:
webapp_name_repo: ${{env.webapp_name_repo}}
webapp_name_ui: ${{env.webapp_name_ui}}
steps:
- uses: actions/checkout@v2
- name: 'build bicep 💪'
run: |
az bicep build --file ${{env.PROJECT_PATH_TODO_INFRA_BICEP}}
- name: login to azure from cli
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: create/update infrastructure from arm template
uses: azure/CLI@v1
with:
inlineScript: |
outputs=$(az deployment group create -g ${{env.RESOURCE_GROUP}} --template-file ${{env.PROJECT_PATH_TODO_INFRA_JSON}} --parameters ${{env.PROJECT_PATH_TODO_INFRA_PARAM}})
webapp_name_repo_out=$(echo $outputs | jq -r .properties.outputs.webapp_name_repo.value)
webapp_name_ui_out=$(echo $outputs | jq -r .properties.outputs.webapp_name_ui.value)
echo webapp_name_repo=$webapp_name_repo_out >> $GITHUB_ENV
echo webapp_name_ui=$webapp_name_ui_out >> $GITHUB_ENV
- name: logout
run: |
az logout
deploy_repo_dev:
needs: [deploy_infra_dev, build_repo]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: package.repo
path: ./release
- name: login to azure from cli
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'deploy todo repo'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ needs.deploy_infra_dev.outputs.webapp_name_repo }}
package: ./release
- name: logout
run: |
az logout
deploy_ui_dev:
needs: [deploy_infra_dev, build_ui]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: package.ui
path: ./release/
- name: login to azure from cli
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'deploy todo ui'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ needs.deploy_infra_dev.outputs.webapp_name_ui }}
package: ./release/
- name: logout
run: |
az logout
create_draft_release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: install gitversion
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: '5.x'
- name: get next version
id: nextversion
uses: gittools/actions/gitversion/execute@v0.9.7
with:
useConfigFile: true
additionalArguments: /updateAssemblyInfo
- name: check-in AssemblyInfo.cs
shell: bash
run: |
git config --global user.email "build@mcmlab.com"
git config --global user.name "GitHub Action"
git add .
git commit -m "update version to ${{ steps.nextversion.outputs.semVer }}"
git push
- name: 'Calculated Release Version -> ${{ steps.nextversion.outputs.semVer }}'
shell: bash
run: |
echo Calculated Release Version : ${{ steps.nextversion.outputs.semVer }}
- name: create draft release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: v${{ steps.nextversion.outputs.semVer }}
release_name: v${{ steps.nextversion.outputs.semVer }}
draft: true
prerelease: false
- name: store release and version info to a file
run: |
mkdir -p datashare_version
echo '${{ steps.nextversion.outputs.semVer }}' > ./datashare_version/release_version.txt
echo '${{ steps.create_release.outputs.upload_url }}' > ./datashare_version/release_url.txt
echo '${{ steps.create_release.outputs.id }}' > ./datashare_version/release_id.txt
- name: cache release and version info file
uses: actions/cache@v2
env:
cache-name: version_cache
with:
path: ./datashare_version/
key: version_cache_key_${{ github.run_number }}_${{ github.run_id }}
finalize_release:
needs: [ deploy_ui_dev, deploy_repo_dev ]
runs-on: ubuntu-latest
steps:
- name: restore release and version info cache
uses: actions/cache@v2
env:
cache-name: version_cache
with:
path: ./datashare_version/
key: version_cache_key_${{ github.run_number }}_${{ github.run_id }}
- name: extract release and version info from cache
shell: bash
run: |
echo release_version=`cat ./datashare_version/release_version.txt` >> $GITHUB_ENV
echo release_url=`cat ./datashare_version/release_url.txt` >> $GITHUB_ENV
echo release_id=`cat ./datashare_version/release_id.txt` >> $GITHUB_ENV
- uses: actions/download-artifact@v2
with:
path: ./release/
- name: zip deployed binaries
run: 'tar cvzf todo.${{env.release_version}}.tar.gz ./release/'
- name: upload zipped binaries to release page
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.release_url }}
asset_path: "todo.${{env.release_version}}.tar.gz"
asset_name: "todo_v${{env.release_version}}.tar.gz"
asset_content_type: application/zip
- name: publish release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ env.release_id }}