forked from diffCheckOrg/diffCheck
-
Notifications
You must be signed in to change notification settings - Fork 1
363 lines (308 loc) · 10.8 KB
/
publish-release.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
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
name: publish-release
on:
release:
types: [published]
workflow_dispatch:
jobs:
################################################################################
## Building
################################################################################
sync-version:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Install Python and pythonnet
uses: actions/setup-python@v2
with:
python-version: '3.9.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install invoke
- name: Update the version across the project and commit the changes
run: invoke versionize
- name: Install GitHub CLI
run: |
choco install gh
- name: Authenticate GitHub CLI
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
- name: Create a new branch and commit the version change
# Delete branch remotely version-sync-branch (if exists)
run: |
git fetch --prune
if git branch -r | grep -q 'origin/version-sync-branch'; then
git push origin --delete version-sync-branch
else
echo "Branch version-sync-branch does not exist."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
# 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 }}
# 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
# 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 }}
# 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
env:
GITHUB_TOKEN: ${{ secrets.DF_COBOT_PAT_TOKEN }}
shell: pwsh
build-ghusers:
runs-on: windows-latest
needs: sync-version
steps:
- uses: actions/checkout@v2
- uses: NuGet/[email protected]
- name: Install CPython and pythonnet package
run: |
choco install python --version=3.9.10
python -m pip install pythonnet==3.0.3
python -m pip install invoke
- name: create the build folder
run: mkdir build
- name: Flag the ghuser codes with the correct package version
run: invoke flagerize
- name: Invoke the componentizer
run: |
mkdir build/gh
invoke ghcomponentize
- uses: actions/upload-artifact@v4
with:
name: ghuser-components
path: build/gh
build-yak-package:
runs-on: windows-latest
needs: build-ghusers
steps:
- uses: actions/checkout@v2
- name: Install Python and pythonnet
uses: actions/setup-python@v2
with:
python-version: '3.9.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install invoke
pip install pythonnet
- name: Download the ghuser components
uses: actions/download-artifact@v4
with:
name: ghuser-components
path: build/gh
- name: Build the yak package
run: invoke yakerize
- name: Save artifact the yak package as an artifact
uses: actions/upload-artifact@v4
with:
name: yak_package_artifact
path: build/yak/*.yak
#===============================================================================
pypi_build:
runs-on: windows-latest
needs: sync-version
steps:
- uses: actions/checkout@v4
- name: Install Python and pythonnet
uses: actions/setup-python@v2
with:
python-version: '3.9.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install invoke
- name: Sync the version across the project (mainly for python package)
run: invoke versionize
- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.9.1
- name: Create diff_check conda environment
run: conda env create -f environment.yml
- name: Activate diff_check conda environment
run: conda activate diff_check
- name: Cmake Configure
run: |
cmake -S . -B build -A x64 -DBUILD_PYTHON_MODULE=ON -DBUILD_TESTS=OFF -DRUN_TESTS=OFF
- name: CMake Build
run: cmake --build build --config Release
- name: Copying the dlls/pyd for python pypi package
run: |
copy ${{github.workspace}}/build/bin/Release/diffCheck.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
copy ${{github.workspace}}/build/bin/Release/Open3D.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
copy ${{github.workspace}}/build/Release/*.pyd ${{github.workspace}}/src/gh/diffCheck/diffCheck
- name: Build wheel
run: |
cd ${{github.workspace}}/src/gh/diffCheck/
python setup.py bdist_wheel
cd ${{github.workspace}}
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: diffcheck_pypi_dist
path: ${{github.workspace}}/src/gh/diffCheck/dist/
################################################################################
## Publishing
################################################################################
publish_test_yak:
needs: build-yak-package
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: yak_package_artifact
path: build/yak
- name: Publish to Yak test server
run: |
$YAK_FILE=$(ls *.yak)
echo "Yak file: $YAK_FILE"
..\..\invokes\yaker\exec\Yak.exe push --source https://test.yak.rhino3d.com $YAK_FILE
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
continue-on-error: true
- name: Verify the Yak test package
run: |
..\..\invokes\yaker\exec\Yak.exe search --source https://test.yak.rhino3d.com --all --prerelease script-sync
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
publish_to_yak:
needs: publish_test_yak
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: yak_package_artifact
path: build/yak
- name: Publish to Yak server
run: |
$YAK_FILE=$(ls *.yak)
echo "Yak file: $YAK_FILE"
..\..\invokes\yaker\exec\Yak.exe push $YAK_FILE
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
# check the real release
- name: Verify the Yak test package
run: |
..\..\invokes\yaker\exec\Yak.exe search --all --prerelease script-sync
working-directory: build/yak
env:
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
#===============================================================================
publish_test_pypi:
needs: pypi_build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/diffCheck
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: diffcheck_pypi_dist
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish_to_pypi:
needs: publish_test_pypi
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/diffCheck
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: diffcheck_pypi_dist
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
################################################################################
## Upload release artifacts
################################################################################
release_artifacts:
needs: [build-yak-package, pypi_build]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Download yak artifact
uses: actions/download-artifact@v4
with:
name: yak_package_artifact
path: build/yak
- name: Download pypi dist artifact
uses: actions/download-artifact@v4
with:
name: diffcheck_pypi_dist
path: dist/
- name: Get YAK artifact path
id: get_yak_path
run: |
echo "::set-output name=yak_path::$(find build/yak -name '*.yak')"
shell: bash
- name: Get PyPI dist path
id: get_pypi_dist_path
run: |
echo "::set-output name=pypi_dist_path::$(find dist/ -name '*.whl')"
shell: bash
- name: Print YAK artifact path
run: |
echo ${{ steps.get_yak_path.outputs.yak_path }}
shell: bash
- name: Print PyPI dist path
run: |
echo ${{ steps.get_pypi_dist_path.outputs.pypi_dist_path }}
shell: bash
- 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: diffCheck.yak
asset_content_type: application/octet-stream
- name: Upload .whl 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_pypi_dist_path.outputs.pypi_dist_path }}
asset_name: diffCheck-py-dist.whl
asset_content_type: application/octet-stream