-
Notifications
You must be signed in to change notification settings - Fork 2
304 lines (254 loc) · 8.48 KB
/
publish.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
name: PublishScriptSync
on:
release:
types: [published]
workflow_dispatch:
jobs:
####################### sync version #######################
sync_version:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Python setup
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install invoke
- name: Install GitHub CLI
run: |
choco install gh
- name: Authenticate GitHub CLI
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
- name: Sync version
run: invoke syncv
- name: Delete branch remotely version-sync-branch (if exists)
run: |
git fetch --prune
git branch -r | grep version-sync-branch && git push origin --delete version-sync-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new branch and commit version change
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b version-sync-branch
git commit -am "ACTION_BOT: Sync version for release"
git push --set-upstream origin version-sync-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Close existing pull requests for version-sync-branch
run: |
gh pr list --state open --head version-sync-branch --json number --jq '.[].number' | ForEach-Object { gh pr close $_ }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
- name: Create pull request
run: |
gh pr create --title "ACTION_BOT: Sync version for release" --body "Sync version for release" --base main --head version-sync-branch --label ACTION_BOT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Merge pull request
run: |
$pr = gh pr list --head version-sync-branch --json number --jq '.[0].number'
gh pr merge $pr --squash --delete-branch --admin --force
env:
GITHUB_TOKEN: ${{ secrets.ADMIN_PAT_TOKEN }}
shell: pwsh
######################## build/publish yak ##########################
build_yak:
runs-on: windows-latest
needs: sync_version
steps:
- uses: actions/checkout@v2
- name: Python setup
uses: actions/setup-python@v2
with:
python-version: '3.9.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install invoke
pip install pythonnet
# install dotnet for building the RhinoCs plugin
- name: Install .NET Framework 4.8
uses: microsoft/[email protected]
- name: Run Invoke Yakerizer task
run: invoke yakerize
- name: Save artifact
uses: actions/upload-artifact@v2
with:
name: scriptsync_yak_package
path: yaker\build\*.yak
publish_yak:
needs: build_yak
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: scriptsync_yak_package
path: yaker\build
- name: Publish to Yak test server
run: |
$YAK_FILE=$(ls *.yak)
echo "Yak file: $YAK_FILE"
..\exec\Yak.exe push --source https://test.yak.rhino3d.com $YAK_FILE
working-directory: yaker\build
env:
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }}
continue-on-error: true
- name: Verify the Yak test package
run: |
..\exec\Yak.exe search --source https://test.yak.rhino3d.com --all --prerelease script-sync
working-directory: yaker\build
env:
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }}
- name: Publish to Yak server
run: |
$YAK_FILE=$(ls *.yak)
echo "Yak file: $YAK_FILE"
..\exec\Yak.exe push $YAK_FILE
working-directory: yaker\build
env:
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }}
# check the real release
- name: Verify the Yak test package
run: |
..\exec\Yak.exe search --all --prerelease script-sync
working-directory: yaker\build
env:
YAK_TOKEN: ${{ secrets.YAK_IBOIS_TOKEN }}
######################## build/publish vsix #########################
build_vsix:
runs-on: windows-latest
needs: sync_version
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
- name: Python setup
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install pip and invoke
run: |
python -m pip install --upgrade pip
pip install invoke
- name: Install vsce
run: npm install -g vsce
- name: Build VSIX package
run: |
cd VSCode/scriptsync
npm install
vsce package
- name: Save artifact
uses: actions/upload-artifact@v2
with:
name: script-sync-vsix
path: VSCode/scriptsync/*.vsix
publish_vsix:
needs: build_vsix
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
- name: Python setup
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install pip and invoke
run: |
python -m pip install --upgrade pip
pip install invoke
- name: Install VSCE
run: npm install -g vsce
- name: Install TypeScript
run: npm install -g typescript
- name: Install dependencies
run: |
npm install
npm install @types/vscode
npm install @types/mocha --save-dev
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: script-sync-vsix
path: VSCode\scriptsync
- name: Get the full path of the downloaded vsix artifact
id: get_vsix_path
run: |
echo "::set-output name=vsix_path::$(find VSCode/scriptsync -name '*.vsix')"
shell: bash
- name: Publish to VSCode Marketplace
run: |
vsce publish -p ${{ secrets.AZURE_OP_TOKEN }} --packagePath ${{ steps.get_vsix_path.outputs.vsix_path }}
working-directory: .\VSCode\scriptsync
- name: Verify the VSCode Marketplace package
run: |
vsce show ibois-epfl.script-sync
###################### release artifacts ########################
release_artifacts:
needs: [build_yak, build_vsix]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- name: Download Yak artifact
uses: actions/download-artifact@v2
with:
name: scriptsync_yak_package
path: yaker/build
- name: Download VSIX artifact
uses: actions/download-artifact@v2
with:
name: script-sync-vsix
path: VSCode/scriptsync
# # list what's in the directory VSCode\scriptsync
# - name: List VSIX artifact
# run: |
# ls -la VSCode/scriptsync
# shell: bash
# get the path of the name terminating with .vsix and set it to a variable
- name: Get VSIX artifact path and save it to an output
id: get_vsix_path
run: |
echo "::set-output name=vsix_path::$(find VSCode/scriptsync -name '*.vsix')"
shell: bash
- name: Get YAK artifact path
id: get_yak_path
run: |
echo "::set-output name=yak_path::$(find yaker/build -name '*.yak')"
shell: bash
- name: Print VSIX artifact path
run: |
echo ${{ steps.get_vsix_path.outputs.vsix_path }}
shell: bash
- name: Print YAK artifact path
run: |
echo ${{ steps.get_yak_path.outputs.yak_path }}
shell: bash
- name: Upload .vsix artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.get_vsix_path.outputs.vsix_path }}
asset_name: script-sync-vsix.vsix
asset_content_type: application/octet-stream
- name: Upload .yak artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.get_yak_path.outputs.yak_path }}
asset_name: script-sync.yak
asset_content_type: application/octet-stream