forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 3
387 lines (317 loc) · 12.4 KB
/
create-release.yml
File metadata and controls
387 lines (317 loc) · 12.4 KB
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: 🚀 Create release
on:
push: # Temporarily added for testing
branches: feat-create-request
workflow_dispatch:
inputs:
skip-release:
default: false
description: Skip release
type: boolean
defaults:
run:
shell: bash
env:
node-version: 22
jobs:
# prepare:
# name: Prepare
# outputs:
# branch-name: ${{ steps.get-branch-name.outputs.branch-name }}
# permissions:
# contents: read
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v6
# - id: get-branch-name
# name: Get branch name
# run: |
# BRANCH_NAME=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
# echo branch-name=$BRANCH_NAME | tee --append $GITHUB_OUTPUT
# # - uses: actions/setup-node@v6
# # with:
# # node-version: ${{ env.node-version }}
# # - id: version-type
# # name: Determine version type
# # run: 'if [[ "$(cat ./package.json | jq -r ''.version'')" == *-0 ]]; then echo version-type=prerelease | tee --append $GITHUB_OUTPUT; else echo version-type=production | tee --append $GITHUB_OUTPUT; fi'
# # - if: steps.version-type.outputs.version-type != 'production'
# # name: Set version
# # run: |
# # BRANCH_NAME=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
# # COMMITISH=${{ github.sha }}
# # NOW=$(date +%Y%m%d%H%M)
# # SHORT_COMMITISH=${COMMITISH:0:7}
# # # npm version simply ignoring the build metadata + (plus) sign, we need to use dot or hyphen instead.
# # npm version --no-git-tag-version $(echo $(cat ./package.json | jq -r '.version') | cut -d- -f1)-$BRANCH_NAME.$NOW.$SHORT_COMMITISH
# # - id: version
# # name: Get version
# # run: echo version=$(cat package.json | jq -r '.version') | tee --append $GITHUB_OUTPUT
# build:
# name: Build
# permissions:
# contents: read
# needs: prepare
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v6
# - uses: actions/setup-node@v6
# with:
# node-version: ${{ env.node-version }}
# - run: npm clean-install
# - name: npm version ${{ needs.prepare.outputs.version }}
# run: |
# npm version ${{ needs.prepare.outputs.version }} \
# --include-workspace-root \
# --no-git-tag-version \
# --no-workspaces-update \
# --workspaces
# - env:
# NODE_ENV: production
# run: npm run build
# - name: Pack as tarball
# run: |
# npm pack \
# --workspace=./packages/core \
# --workspace=./packages/api \
# --workspace=./packages/component \
# --workspace=./packages/bundle \
# --workspace=./packages/fluent-theme
# # - name: Generate SBOM
# # # --workspace has no effect, the resulting SBOM still contains other packages in the workspace
# # run: npm sbom --package-lock-only --sbom-format spdx --sbom-type library | tee ./sbom.spdx.json
# - uses: actions/upload-artifact@v7
# with:
# name: tarball
# path: ./*.tgz
# - uses: actions/upload-artifact@v7
# with:
# name: bundle-iife
# path: ./packages/bundle/dist/webchat*.js
# - uses: actions/upload-artifact@v7
# with:
# name: bundle-esm
# path: ./packages/bundle/static/**/*
# - uses: actions/upload-artifact@v7
# with:
# name: fluent-theme-iife
# path: ./packages/fluent-theme/dist/**/*
# - uses: actions/upload-artifact@v7
# with:
# name: fluent-theme-esm
# path: ./packages/fluent-theme/static/**/*
# # - name: Upload SBOM artifact
# # uses: actions/upload-artifact@v7
# # with:
# # name: sbom
# # path: ./sbom.spdx.json
build:
environment:
deployment: false
name: azure-devops
name: Build
outputs:
version: ${{ steps.azdo-build.outputs.version }}
version-type: ${{ steps.azdo-build.outputs.version-type }}
permissions:
contents: read
id-token: write
runs-on: ubuntu-slim
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- id: get-branch-name
name: Get branch name
run: |
BRANCH_NAME=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
echo branch-name=$BRANCH_NAME | tee --append $GITHUB_OUTPUT
- id: azdo-build
uses: ./.github/actions/azdo-build
with:
artifact-name: azdo-artifact
azdo-org: ${{ vars.AZDO_ORG }}
azdo-pipeline-name: ${{ vars.AZDO_PIPELINE_NAME }}
azdo-project: ${{ vars.AZDO_PROJECT }}
azure-client-id: ${{ vars.AZURE_CLIENT_ID }}
azure-subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
azure-tenant-id: ${{ vars.AZURE_TENANT_ID }}
download-artifact-name: drop_build_main
# pipeline-variable: ProjectBranch=${{ steps.get-branch-name.outputs.branch-name }}
pipeline-variable: |
ProjectBranch=${{ steps.get-branch-name.outputs.branch-name }}
ProjectRepository=${{ github.repository }}
- name: Download AzDO build artifact
uses: actions/download-artifact@v8
with:
name: azdo-artifact
- name: Extract artifact (bundle)
run: |
mkdir -p ./bundle/
cd ./bundle/
tar \
--extract \
--file=../tgzfiles/botframework-webchat-${{ steps.azdo-build.outputs.version }}.tgz \
--strip-component=1 \
package/dist/ \
package/static/
- name: Extract artifact (fluent-theme)
run: |
mkdir -p ./fluent-theme/
cd ./fluent-theme/
tar \
--extract \
--file=../tgzfiles/botframework-webchat-fluent-theme-${{ steps.azdo-build.outputs.version }}.tgz \
--strip-component=1 \
package/dist/ \
package/static/
- name: Upload artifact (tarball)
uses: actions/upload-artifact@v7
with:
name: tarball
path: ./tgzfiles/*.tgz
- name: Upload artifact (bundle-iife)
uses: actions/upload-artifact@v7
with:
name: bundle-iife
path: ./bundle/dist/webchat*.js
- name: Upload artifact (bundle-esm)
uses: actions/upload-artifact@v7
with:
name: bundle-esm
path: ./bundle/static/
- name: Upload artifact (fluent-theme-iife)
uses: actions/upload-artifact@v7
with:
name: fluent-theme-iife
path: ./fluent-theme/dist/webchat*.js
- name: Upload artifact (fluent-theme-esm)
uses: actions/upload-artifact@v7
with:
name: fluent-theme-esm
path: ./fluent-theme/static/
- name: Upload artifact (sbom)
uses: actions/upload-artifact@v7
with:
name: sbom
path: ./_manifest/spdx_2.2/manifest.spdx.json
upload-changelog:
name: Upload changelog
needs: build
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.node-version }}
- run: npm install --global keep-a-changelog@2 prettier
- if: needs.build.outputs.version-type != 'production'
name: Tag unreleased as latest
run: npx keep-a-changelog --format markdownlint --release=${{ needs.build.outputs.version }}
- name: Extract latest entry
run: npx keep-a-changelog --format markdownlint --latest-release-full | tee ./CHANGELOG.latest.md
- name: Format extracted entry
run: npx prettier CHANGELOG.latest.md --tab-width 3 --write
- name: Upload changelog
uses: actions/upload-artifact@v7
with:
name: changelog
path: ./CHANGELOG.latest.md
release:
environment:
name: github-release
url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ steps.release.outputs.tag }}
name: Release
needs:
- build
- upload-changelog
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifact (tarball)
uses: actions/download-artifact@v8
with:
name: tarball
path: ./asset
- name: Download artifact (bundle-iife)
uses: actions/download-artifact@v8
with:
name: bundle-iife
path: ./asset
- name: Download artifact (changelog)
uses: actions/download-artifact@v8
with:
name: changelog
path: ./
- name: Download artifact (sbom)
uses: actions/download-artifact@v8
with:
name: sbom
path: ./asset
- id: compute-hash
name: Compute build metadata
run: |
echo git-short-sha=`echo ${{ github.sha }} | cut -c 1-7` | tee --append $GITHUB_OUTPUT
echo release-date=`date "+%Y-%m-%d %R:%S"` | tee --append $GITHUB_OUTPUT
echo sha384-es5=`cat webchat-es5.js | openssl dgst -sha384 -binary | openssl base64 -A` | tee --append $GITHUB_OUTPUT
echo sha384-full=`cat webchat.js | openssl dgst -sha384 -binary | openssl base64 -A` | tee --append $GITHUB_OUTPUT
echo sha384-minimal=`cat webchat-minimal.js | openssl dgst -sha384 -binary | openssl base64 -A` | tee --append $GITHUB_OUTPUT
- name: Build release notes
run: |
tee ./release.txt <<EOF
This release is for internal testing only. **Please do not use this build in production environment.**
| Build time | Run ID | Source version | Git ref | Package version |
| - | - | - | - | - |
| ${{ steps.compute-hash.outputs.release-date }}Z | [\`${{ github.run_id }}\`](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | [\`${{ steps.compute-hash.outputs.git-short-sha }}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) | \`${{ github.ref }}\` | \`${{ needs.build.outputs.version }}\` |
\`\`\`html
<script
crossorigin="anonymous"
integrity="sha384-${{ steps.compute-hash.outputs.sha384-full }}"
src="https://cdn.botframework.com/botframework-webchat@${{ needs.build.outputs.version }}/dist/webchat.js"
></script>
<script
crossorigin="anonymous"
integrity="sha384-${{ steps.compute-hash.outputs.sha384-es5 }}"
src="https://cdn.botframework.com/botframework-webchat@${{ needs.build.outputs.version }}/dist/webchat-es5.js"
></script>
<script
crossorigin="anonymous"
integrity="sha384-${{ steps.compute-hash.outputs.sha384-minimal }}"
src="https://cdn.botframework.com/botframework-webchat@${{ needs.build.outputs.version }}/dist/webchat-minimal.js"
></script>
\`\`\`
# Changelog
EOF
cat ./CHANGELOG.latest.md | tee --append ./release.txt
- uses: actions/upload-artifact@v7
with:
name: release-notes
overwrite: true
path: ./release.txt
- env:
# Use actions/create-github-app-token if create release would need to trigger another workflow.
GH_TOKEN: ${{ github.token }}
id: release
if: '!inputs.skip-release'
name: Create release
# Do not upload assets while creating release, otherwise, it will not trigger "release created" event.
run: |
if [[ "${{ needs.build.outputs.version-type }}" == "prerelease" ]]; then PRERELEASE=1; fi
TAG=v${{ needs.build.outputs.version }}
gh release create $TAG \
--notes-file ./release.txt \
${PRERELEASE:+--prerelease} \
--repo ${{ github.repository }} \
--target ${{ github.ref }}
echo tag=$TAG | tee --append $GITHUB_OUTPUT
- env:
GH_TOKEN: ${{ github.token }}
if: '!inputs.skip-release'
name: Upload assets
run: |
gh release upload ${{ steps.release.outputs.tag }} \
--repo ${{ github.repository }} \
./asset/*.js \
./asset/*.tgz \
./asset/manifest.spdx.json