1+ name : publish-release
2+
3+ on :
4+ release :
5+ types : [published]
6+ workflow_dispatch :
7+
8+ jobs :
9+ # ###############################################################################
10+ # # Building
11+ # ###############################################################################
12+ sync-version :
13+ runs-on : windows-latest
14+
15+ steps :
16+ - uses : actions/checkout@v2
17+
18+ - name : Install Python and pythonnet
19+ uses : actions/setup-python@v2
20+ with :
21+ python-version : ' 3.9.10'
22+
23+ - name : Install Python dependencies
24+ run : |
25+ python -m pip install --upgrade pip
26+ pip install invoke
27+
28+ - name : Update the version across the project and commit the changes
29+ run : invoke versionize
30+
31+ - name : Install GitHub CLI
32+ run : |
33+ choco install gh
34+ - name : Authenticate GitHub CLI
35+ run : |
36+ echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
37+
38+ - name : Create a new branch and commit the version change
39+ # Delete branch remotely version-sync-branch (if exists)
40+ run : |
41+ git fetch --prune
42+ if git branch -r | grep -q 'origin/version-sync-branch'; then
43+ git push origin --delete version-sync-branch
44+ else
45+ echo "Branch version-sync-branch does not exist."
46+ fi
47+ env :
48+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
49+ shell : bash
50+ # Create new branch and commit version change
51+ - run : |
52+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
53+ git config --global user.name "github-actions[bot]"
54+ git checkout -b version-sync-branch
55+ git commit -am "ACTION_BOT: Sync version for release"
56+ git push --set-upstream origin version-sync-branch
57+ env:
58+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+ # Close existing pull requests for version-sync-branch
60+ - run : |
61+ gh pr list --state open --head version-sync-branch --json number --jq '.[].number' | ForEach-Object { gh pr close $_ }
62+ env:
63+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+ shell: pwsh
65+ # Create pull request
66+ - run : |
67+ gh pr create --title "ACTION_BOT: Sync version for release" --body "Sync version for release" --base main --head version-sync-branch --label ACTION_BOT
68+ env:
69+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+ # Merge pull request
71+ - run : |
72+ $pr = gh pr list --head version-sync-branch --json number --jq '.[0].number'
73+ gh pr merge $pr --squash --delete-branch --admin
74+ env:
75+ GITHUB_TOKEN: ${{ secrets.DF_COBOT_PAT_TOKEN }}
76+ shell: pwsh
77+
78+ build-ghusers :
79+ runs-on : windows-latest
80+ needs : sync-version
81+
82+ steps :
83+ - uses : actions/checkout@v2
84+ - uses : NuGet/setup-nuget@v1.0.5
85+
86+ - name : Install CPython and pythonnet package
87+ run : |
88+ choco install python --version=3.9.10
89+ python -m pip install pythonnet==3.0.3
90+ python -m pip install invoke
91+
92+ - name : create the build folder
93+ run : mkdir build
94+
95+ - name : Flag the ghuser codes with the correct package version
96+ run : invoke flagerize
97+
98+ - name : Invoke the componentizer
99+ run : |
100+ mkdir build/gh
101+ invoke ghcomponentize
102+
103+ - uses : actions/upload-artifact@v4
104+ with :
105+ name : ghuser-components
106+ path : build/gh
107+
108+ build-yak-package :
109+ runs-on : windows-latest
110+ needs : build-ghusers
111+
112+ steps :
113+ - uses : actions/checkout@v2
114+
115+ - name : Install Python and pythonnet
116+ uses : actions/setup-python@v2
117+ with :
118+ python-version : ' 3.9.10'
119+
120+ - name : Install Python dependencies
121+ run : |
122+ python -m pip install --upgrade pip
123+ pip install invoke
124+ pip install pythonnet
125+
126+ - name : Download the ghuser components
127+ uses : actions/download-artifact@v4
128+ with :
129+ name : ghuser-components
130+ path : build/gh
131+
132+ - name : Build the yak package
133+ run : invoke yakerize
134+
135+ - name : Save artifact the yak package as an artifact
136+ uses : actions/upload-artifact@v4
137+ with :
138+ name : yak_package_artifact
139+ path : build/yak/*.yak
140+
141+ # ===============================================================================
142+
143+ pypi_build :
144+ runs-on : windows-latest
145+ needs : sync-version
146+
147+ steps :
148+ - uses : actions/checkout@v4
149+
150+ - name : Setup conda environment
151+ uses : conda-incubator/setup-miniconda@v2
152+ with :
153+ auto-update-conda : true
154+ python-version : 3.9.1
155+
156+ - name : Create diff_check conda environment
157+ run : conda env create -f environment.yml
158+
159+ - name : Activate diff_check conda environment
160+ run : conda activate diff_check
161+
162+ - name : Cmake Configure
163+ run : |
164+ cmake -S . -B build -A x64 -DBUILD_PYTHON_MODULE=ON -DBUILD_TESTS=OFF -DRUN_TESTS=OFF
165+ - name : CMake Build
166+ run : cmake --build build --config Release
167+
168+ - name : Copying the dlls/pyd for python pypi package
169+ run : |
170+ copy ${{github.workspace}}/build/bin/Release/diffCheck.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
171+ copy ${{github.workspace}}/build/bin/Release/Open3D.dll ${{github.workspace}}/src/gh/diffCheck/diffCheck/dlls
172+ copy ${{github.workspace}}/build/Release/*.pyd ${{github.workspace}}/src/gh/diffCheck/diffCheck
173+
174+ - name : Build wheel
175+ run : |
176+ cd ${{github.workspace}}/src/gh/diffCheck/
177+ python setup.py bdist_wheel
178+ cd ${{github.workspace}}
179+
180+ - name : Upload wheel
181+ uses : actions/upload-artifact@v4
182+ with :
183+ name : diffcheck_pypi_dist
184+ path : ${{github.workspace}}/src/gh/diffCheck/dist/
185+
186+ # ###############################################################################
187+ # # Publishing
188+ # ###############################################################################
189+
190+ publish_test_yak :
191+ needs : build-yak-package
192+ runs-on : windows-latest
193+
194+ steps :
195+ - name : Checkout repo
196+ uses : actions/checkout@v2
197+
198+ - name : Download artifact
199+ uses : actions/download-artifact@v4
200+ with :
201+ name : yak_package_artifact
202+ path : build/yak
203+
204+ - name : Publish to Yak test server
205+ run : |
206+ $YAK_FILE=$(ls *.yak)
207+ echo "Yak file: $YAK_FILE"
208+ ..\..\invokes\yaker\exec\Yak.exe push --source https://test.yak.rhino3d.com $YAK_FILE
209+ working-directory : build/yak
210+ env :
211+ YAK_TOKEN : ${{ secrets.YAK_DF_TOKEN }}
212+ continue-on-error : true
213+ - name : Verify the Yak test package
214+ run : |
215+ ..\..\invokes\yaker\exec\Yak.exe search --source https://test.yak.rhino3d.com --all --prerelease script-sync
216+ working-directory : build/yak
217+ env :
218+ YAK_TOKEN : ${{ secrets.YAK_DF_TOKEN }}
219+
220+ publish_to_yak :
221+ needs : publish_test_yak
222+ runs-on : windows-latest
223+
224+ steps :
225+ - name : Checkout repo
226+ uses : actions/checkout@v2
227+
228+ - name : Download artifact
229+ uses : actions/download-artifact@v4
230+ with :
231+ name : yak_package_artifact
232+ path : build/yak
233+
234+ - name : Publish to Yak server
235+ run : |
236+ $YAK_FILE=$(ls *.yak)
237+ echo "Yak file: $YAK_FILE"
238+ ..\..\invokes\yaker\exec\Yak.exe push $YAK_FILE
239+ working-directory : build/yak
240+ env :
241+ YAK_TOKEN : ${{ secrets.YAK_DF_TOKEN }}
242+ # check the real release
243+ - name : Verify the Yak test package
244+ run : |
245+ ..\..\invokes\yaker\exec\Yak.exe search --all --prerelease script-sync
246+ working-directory : build/yak
247+ env :
248+ YAK_TOKEN : ${{ secrets.YAK_DF_TOKEN }}
249+
250+ # ===============================================================================
251+
252+ publish_test_pypi :
253+ needs : pypi_build
254+ runs-on : ubuntu-latest
255+ environment :
256+ name : testpypi
257+ url : https://test.pypi.org/p/diffCheck
258+ permissions :
259+ id-token : write
260+
261+ steps :
262+ - name : Download all the dists
263+ uses : actions/download-artifact@v4
264+ with :
265+ name : diffcheck_pypi_dist
266+ path : dist/
267+ - name : Publish distribution to TestPyPI
268+ uses : pypa/gh-action-pypi-publish@release/v1
269+ with :
270+ repository-url : https://test.pypi.org/legacy/
271+
272+ publish_to_pypi :
273+ needs : publish_test_pypi
274+ runs-on : ubuntu-latest
275+ environment :
276+ name : pypi
277+ url : https://pypi.org/project/diffCheck
278+ permissions :
279+ id-token : write
280+
281+ steps :
282+ - name : Download all the dists
283+ uses : actions/download-artifact@v4
284+ with :
285+ name : diffcheck_pypi_dist
286+ path : dist/
287+
288+ - name : Publish distribution to PyPI
289+ uses : pypa/gh-action-pypi-publish@release/v1
290+
291+
292+ # ###############################################################################
293+ # # Upload release artifacts
294+ # ###############################################################################
295+ release_artifacts :
296+ needs : [build-yak-package, pypi_build]
297+ runs-on : ubuntu-latest
298+ if : github.event_name == 'release'
299+
300+ steps :
301+ - name : Checkout repo
302+ uses : actions/checkout@v2
303+
304+ - name : Download yak artifact
305+ uses : actions/download-artifact@v4
306+ with :
307+ name : yak_package_artifact
308+ path : build/yak
309+ - name : Download pypi dist artifact
310+ uses : actions/download-artifact@v4
311+ with :
312+ name : diffcheck_pypi_dist
313+
314+ - name : Get YAK artifact path
315+ id : get_yak_path
316+ run : |
317+ echo "::set-output name=yak_path::$(find build/yak -name '*.yak')"
318+ shell : bash
319+ - name : Get PyPI dist path
320+ id : get_pypi_dist_path
321+ run : |
322+ echo "::set-output name=pypi_dist_path::$(find dist -name '*.whl')"
323+ shell : bash
324+ - name : Print YAK artifact path
325+ run : |
326+ echo ${{ steps.get_yak_path.outputs.yak_path }}
327+ shell : bash
328+ - name : Print PyPI dist path
329+ run : |
330+ echo ${{ steps.get_pypi_dist_path.outputs.pypi_dist_path }}
331+ shell : bash
332+
333+ - name : Upload .yak artifact
334+ uses : actions/upload-release-asset@v1
335+ env :
336+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
337+ with :
338+ upload_url : ${{ github.event.release.upload_url }}
339+ asset_path : ${{ steps.get_yak_path.outputs.yak_path }}
340+ asset_name : diffCheck.yak
341+ asset_content_type : application/octet-stream
342+ - name : Upload .whl artifact
343+ uses : actions/upload-release-asset@v1
344+ env :
345+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
346+ with :
347+ upload_url : ${{ github.event.release.upload_url }}
348+ asset_path : ${{ steps.get_pypi_dist_path.outputs.pypi_dist_path }}
349+ asset_name : diffCheck-py-dist.whl
350+ asset_content_type : application/octet-stream
0 commit comments