44 push :
55 tags :
66 - ' v*'
7+ branches :
8+ - test-publish/*
79 workflow_dispatch :
810 inputs :
9- publish :
10- description : ' Publish to PyPI (uncheck for dry run )'
11+ dry_run :
12+ description : ' Dry run (do not publish to PyPi )'
1113 required : false
1214 type : boolean
13- default : true
15+ # Caveat: The type of default value is string, so we should not provide
16+ # one otherwise "inputs.dry_run" would be both boolean and string.
1417 dev_release :
1518 description : ' Development release (DEV_RELEASE=1)'
1619 required : false
1720 type : boolean
18- default : false
1921
2022permissions :
2123 contents : read
@@ -29,19 +31,22 @@ jobs:
2931 - uses : ./.github/actions/build-docs
3032
3133 deploy_documentation :
32- if : ${{ github.event_name == 'push' || inputs.publish }}
3334 needs : build_documentation
3435 permissions :
3536 pages : write
3637 id-token : write
3738 runs-on : ubuntu-latest
3839 environment :
39- name : github-pages
40+ name : ${{ inputs.dry_run && 'none' || ' github-pages' }}
4041 url : ${{ steps.deployment.outputs.page_url }}
4142 steps :
4243 - name : Deploy to GitHub Pages
4344 id : deployment
4445 uses : actions/deploy-pages@v4
46+ - name : Dry run check
47+ if : failure() && inputs.dry_run
48+ shell : bash
49+ run : echo 'Expected deployment failure'
4550
4651 build_linux_release :
4752 if : github.repository == 'ml-explore/mlx'
@@ -161,7 +166,7 @@ jobs:
161166 permissions :
162167 id-token : write
163168 environment :
164- name : pypi
169+ name : ${{ inputs.dry_run && 'none' || ' pypi' }}
165170 url : https://pypi.org/p/mlx
166171 steps :
167172 - uses : actions/download-artifact@v7
@@ -177,10 +182,13 @@ jobs:
177182 - name : Display structure of downloaded files
178183 run : du -ah dist
179184 - name : Publish package distributions to PyPI
180- if : ${{ github.event_name == 'push' || inputs.publish }}
181185 uses : pypa/gh-action-pypi-publish@release/v1
182186 with :
183187 repository-url : https://upload.pypi.org/legacy/
188+ - name : Dry run check
189+ if : failure() && inputs.dry_run
190+ shell : bash
191+ run : echo 'Expected deployment failure'
184192
185193 pypi-publish-cuda :
186194 name : Upload CUDA release to PyPI
@@ -189,7 +197,7 @@ jobs:
189197 permissions :
190198 id-token : write
191199 environment :
192- name : pypi
200+ name : ${{ inputs.dry_run && 'none' || ' pypi' }}
193201 url : https://pypi.org/p/mlx-cuda
194202 steps :
195203 - uses : actions/download-artifact@v7
@@ -200,10 +208,13 @@ jobs:
200208 - name : Display structure of downloaded files
201209 run : du -ah dist
202210 - name : Publish package distributions to PyPI
203- if : ${{ github.event_name == 'push' || inputs.publish }}
204211 uses : pypa/gh-action-pypi-publish@release/v1
205212 with :
206213 repository-url : https://upload.pypi.org/legacy/
214+ - name : Dry run check
215+ if : failure() && inputs.dry_run
216+ shell : bash
217+ run : echo 'Expected deployment failure'
207218
208219 pypi-publish-cpu :
209220 name : Upload CPU release to PyPI
@@ -212,7 +223,7 @@ jobs:
212223 permissions :
213224 id-token : write
214225 environment :
215- name : pypi
226+ name : ${{ inputs.dry_run && 'none' || ' pypi' }}
216227 url : https://pypi.org/p/mlx-cpu
217228 steps :
218229 - uses : actions/download-artifact@v7
@@ -223,10 +234,13 @@ jobs:
223234 - name : Display structure of downloaded files
224235 run : du -ah dist
225236 - name : Publish package distributions to PyPI
226- if : ${{ github.event_name == 'push' || inputs.publish }}
227237 uses : pypa/gh-action-pypi-publish@release/v1
228238 with :
229239 repository-url : https://upload.pypi.org/legacy/
240+ - name : Dry run check
241+ if : failure() && inputs.dry_run
242+ shell : bash
243+ run : echo 'Expected deployment failure'
230244
231245 pypi-publish-metal :
232246 name : Upload Metal release to PyPI
@@ -235,7 +249,7 @@ jobs:
235249 permissions :
236250 id-token : write
237251 environment :
238- name : pypi
252+ name : ${{ inputs.dry_run && 'none' || ' pypi' }}
239253 url : https://pypi.org/p/mlx-metal
240254 steps :
241255 - uses : actions/download-artifact@v7
@@ -245,7 +259,10 @@ jobs:
245259 - name : Display structure of downloaded files
246260 run : du -ah dist
247261 - name : Publish package distributions to PyPI
248- if : ${{ github.event_name == 'push' || inputs.publish }}
249262 uses : pypa/gh-action-pypi-publish@release/v1
250263 with :
251264 repository-url : https://upload.pypi.org/legacy/
265+ - name : Dry run check
266+ if : failure() && inputs.dry_run
267+ shell : bash
268+ run : echo 'Expected deployment failure'
0 commit comments