-
Notifications
You must be signed in to change notification settings - Fork 192
318 lines (275 loc) · 13.6 KB
/
cd.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
name: CD
run-name: CD-${{ github.run_id }}-${{ github.ref_name }}-${{ inputs.preid }}-${{ inputs.series }}
on:
workflow_dispatch:
inputs:
preid:
description: "preid name(alpha, beta, rc, stable)"
required: true
default: "rc"
series:
description: "release sprint series name"
required: false
default: ""
skip-version-rc:
description: "release RC version just with lerna publish, skip run lerna version(yes or no)"
required: false
default: "no"
pkgs:
type: string
required: false
description: "Please enter the package names you want to publish, such as cli, vscode, ui, sdk, server and template. Please separate multiple entries with spaces"
schedule:
- cron: "0 16 * * *"
permissions:
actions: read
contents: read
jobs:
cd:
runs-on: ubuntu-latest
env:
CI: true
PREID: ${{ github.event.inputs.preid }}
steps:
- name: Validate CD branch
if: ${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/hotfix/') && github.ref != 'refs/heads/dev' && !startsWith(github.ref, 'refs/heads/release/') }}
run: |
echo It's not allowed to run CD on other branch except main and dev.
exit 1
- name: Validate inputs for main or hotfix
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && github.event.inputs.preid != 'beta' && github.event.inputs.preid != 'rc' && github.event.inputs.preid != 'stable' }}
run: |
echo It's only allowed to release RC and stable on main branch.
exit 1
- name: Validate inputs for release
if: ${{ github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/heads/release/') && (github.event.inputs.preid != 'stable' && github.event.inputs.preid != 'rc')}}
run: |
echo It's only allowed to release stable on release branch
exit 1
- name: Valiadte inputs for dev
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev' && github.event.inputs.preid != 'alpha' }}
run: |
echo It's only allowed to alpha on dev branch.
exit 1
- name: Validate schedule
if: ${{ github.event_name == 'schedule' && github.ref != 'refs/heads/dev' }}
run: |
echo It's not allowed to run schedule release except dev branch.
exit 1
- name: Checkout branch
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CD_PAT }}
ref: ${{ github.ref }}
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v4
- name: Install wine64
run: |
sudo apt update
sudo apt install wine64 -y
- name: Setup npm registry
run: |
echo "${{ secrets.NPMRC }}" > ~/.npmrc
- name: manage pkgs to release
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pkgs }}
run: bash .github/scripts/lerna.sh ${{github.event.inputs.pkgs}}
- name: Setup project
run: |
npm run setup
- name: Setup git
run: |
git config --global user.name 'MSFT-yiz'
git config --global user.email '[email protected]'
- name: release alpha npm packages to npmjs.org
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
npx lerna version prerelease --preid=alpha.$(git rev-parse --short HEAD) --exact --no-push --allow-branch dev --yes
- name: release beta packages to npmjs.org
if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/')) && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'beta' }}
run: |
npx lerna version prerelease --preid=beta.$(date "+%Y%m%d%H") --exact --no-push --allow-branch ${GITHUB_REF#refs/*/} --yes
- name: version rc npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' && github.ref == 'refs/heads/main' && github.event.inputs.skip-version-rc == 'no'}}
run: |
npx lerna version prerelease --conventional-prerelease --preid=rc --no-changelog --yes
- name: version rc npm packages to npmjs.org on hotfix
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' && (startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/release/')) && github.event.inputs.skip-version-rc == 'no'}}
run: |
npx lerna version prerelease --conventional-prerelease --preid=rc-hotfix --no-changelog --allow-branch ${GITHUB_REF#refs/*/} --yes
- name: version stable npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/release/')) && github.event.inputs.preid == 'stable' }}
run: |
npx lerna version --conventional-commits --conventional-graduate --no-changelog --allow-branch ${GITHUB_REF#refs/*/} --yes
- name: version change
id: version-change
run: |
echo "CHANGED=$(git tag --points-at HEAD | xargs)" >> $GITHUB_OUTPUT
echo "TEMPLATE_VERSION=$(git tag --points-at HEAD | grep templates)" >> $GITHUB_OUTPUT
echo "EXTENSION_VERSION=$(git tag --points-at HEAD | grep ms-teams-vscode-extension@)" >> $GITHUB_OUTPUT
git tag --points-at HEAD | grep templates | grep rc | xargs -r git push -d origin
- name: update template rc tag
uses: richardsimko/[email protected]
if: ${{ (contains(steps.version-change.outputs.CHANGED, 'templates@') || contains(steps.version-change.outputs.CHANGED, '@microsoft/teamsfx')) && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' }}
with:
tag_name: "[email protected]"
env:
GITHUB_TOKEN: ${{ secrets.CD_PAT }}
- name: release templates' RC version to github
if: ${{ (contains(steps.version-change.outputs.CHANGED, 'templates@') || contains(steps.version-change.outputs.CHANGED, '@microsoft/teamsfx')) && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' }}
uses: ncipollo/[email protected]
with:
token: ${{ secrets.CD_PAT }}
prerelease: true
tag: "[email protected]"
artifacts: ${{ github.workspace }}/templates/build/*.zip
allowUpdates: true
removeArtifacts: true
- name: Create Templates Stable Release
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
uses: ncipollo/[email protected]
with:
artifacts: ${{ github.workspace }}/templates/build/*.zip
name: "Release for ${{ steps.version-change.outputs.TEMPLATE_VERSION }}"
token: ${{ secrets.CD_PAT }}
tag: ${{ steps.version-change.outputs.TEMPLATE_VERSION }}
allowUpdates: true
- name: Generate Tag List
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
run: git tag | grep templates > ${{ runner.temp }}/template-tags.txt
- name: Update Template Tag list Release
if: ${{ contains(steps.version-change.outputs.CHANGED, 'templates@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
uses: ncipollo/[email protected]
with:
artifacts: ${{ runner.temp }}/template-tags.txt
name: "Template Tag List"
body: "Release to maintain template tag list."
token: ${{ secrets.CD_PAT }}
tag: "template-tag-list"
allowUpdates: true
- name: replace sideloading placeholders
run: bash .github/scripts/sideloading-replace.sh
env:
SIDELOADING_SERVICE_ENDPOINT: ${{ secrets.SIDELOADING_SERVICE_ENDPOINT }}
SIDELOADING_SERVICE_SCOPE: ${{ secrets.SIDELOADING_SERVICE_SCOPE }}
- name: commit change on local
run: |
git add packages/fx-core/src/component/m365/serviceConstant.ts
git commit -m "build: replace sideloading placeholders"
- name: disable chat participant environment variable
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.preid != 'alpha') }}
run: bash .github/scripts/chat-participant-disabled.sh
- name: disable api proposals in package.json
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.preid != 'alpha') }}
uses: jossef/[email protected]
with:
file: packages/vscode-extension/package.json
field: enabledApiProposals
value: '[]'
parse_json: true
- name: disable chat participant in package.json
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.preid != 'alpha') }}
uses: jossef/[email protected]
with:
file: packages/vscode-extension/package.json
field: contributes.chatParticipants
value: '[]'
parse_json: true
- name: commit change on local
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.preid != 'alpha') }}
run: |
git add ./packages/vscode-extension/package.json ./packages/vscode-extension/src/chat/consts.ts
git commit -m "build: disable chat participant"
- name: update cli ai key
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid != 'alpha' }}
uses: jossef/action-set-json-field@v1
with:
file: ./packages/cli/package.json
field: aiKey
value: ${{ secrets.CLI_PUBLIC_AIKEY }}
- name: update extension ai key
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid != 'alpha' }}
uses: jossef/action-set-json-field@v1
with:
file: ./packages/vscode-extension/package.json
field: aiKey
value: ${{ secrets.EXT_PUBLIC_AIKEY }}
- name: commit change on local
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid != 'alpha' }}
run: |
git add ./packages/cli/package.json ./packages/vscode-extension/package.json
git commit -m "build: update ai key"
- name: publish alpha release to npm org
if: ${{ github.ref == 'refs/heads/dev'}}
run: |
npx lerna publish from-package --dist-tag=alpha --yes --allow-branch dev
- name: publish beta release to npm org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'beta' }}
run: |
npx lerna publish from-package --dist-tag=beta --yes
- name: publish rc npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'rc' }}
run: |
npx lerna publish from-package --dist-tag=rc --yes
- name: publish stable npm packages to npmjs.org
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
run: |
npx lerna publish from-package --yes
- name: pack server bits
if: ${{ contains(steps.version-change.outputs.CHANGED, '@microsoft/teamsfx-server') }}
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
sleep 20
pnpm --filter @microsoft/teamsfx-server run package
[ -d ./packages/server/lib ] && find ./packages/server/lib -type f -name '*.exe' -exec mv {} server.exe \;
- name: pack vsix
if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') }}
env:
NODE_OPTIONS: "--max_old_space_size=4096"
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 10
retry_on: error
command: |
sleep 20
npm run build
cd ./packages/vscode-extension
if [ "$PREID" == "beta" ]; then
pnpm dlx vsce package --no-dependencies --pre-release
else
pnpm dlx vsce package --no-dependencies
fi
- name: release stable VSCode extension to github
if: ${{ contains(steps.version-change.outputs.CHANGED, 'ms-teams-vscode-extension@') && github.event_name == 'workflow_dispatch' && github.event.inputs.preid == 'stable' }}
uses: ncipollo/[email protected]
with:
token: ${{ secrets.CD_PAT }}
tag: ${{ steps.version-change.outputs.EXTENSION_VERSION }}
artifacts: ./packages/**/*.vsix
artifactErrorsFailBuild: true
bodyFile: ./CHANGELOG.md
- name: save release info
run: |
rm -f changed.txt
rm -f versions.json
echo ${{steps.version-change.outputs.CHANGED}} > changed.txt
npx lerna ls -all --json > versions.json
echo ${{ inputs.series }} > series.txt
find ./packages/vscode-extension -type f -name '*.vsix' -exec mv {} . \;
- name: upload release info to artifact
uses: actions/upload-artifact@v3
with:
name: release
path: |
changed.txt
series.txt
versions.json
*.vsix
*.exe