Skip to content

Commit 0b2db4a

Browse files
committed
Add push_release function for programmatic releases - fixes #1554
1 parent 780f166 commit 0b2db4a

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

nbdev/_modidx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@
309309
'nbdev.release.conda_output_path': ('api/release.html#conda_output_path', 'nbdev/release.py'),
310310
'nbdev.release.latest_pypi': ('api/release.html#latest_pypi', 'nbdev/release.py'),
311311
'nbdev.release.nbdev_bump_version': ('api/release.html#nbdev_bump_version', 'nbdev/release.py'),
312+
'nbdev.release.push_release': ('api/release.html#push_release', 'nbdev/release.py'),
312313
'nbdev.release.pypi_details': ('api/release.html#pypi_details', 'nbdev/release.py'),
313314
'nbdev.release.pypi_json': ('api/release.html#pypi_json', 'nbdev/release.py'),
314315
'nbdev.release.release_both': ('api/release.html#release_both', 'nbdev/release.py'),

nbdev/release.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/18_release.ipynb.
44

55
# %% auto #0
6-
__all__ = ['GH_HOST', 'CONDA_WARNING', 'Release', 'changelog', 'release_git', 'release_gh', 'pypi_json', 'latest_pypi',
7-
'pypi_details', 'conda_output_path', 'write_conda_meta', 'write_requirements', 'anaconda_upload',
8-
'release_conda', 'chk_conda_rel', 'release_pypi', 'release_both', 'bump_version', 'nbdev_bump_version']
6+
__all__ = ['GH_HOST', 'CONDA_WARNING', 'Release', 'changelog', 'push_release', 'release_git', 'release_gh', 'pypi_json',
7+
'latest_pypi', 'pypi_details', 'conda_output_path', 'write_conda_meta', 'write_requirements',
8+
'anaconda_upload', 'release_conda', 'chk_conda_rel', 'release_pypi', 'release_both', 'bump_version',
9+
'nbdev_bump_version']
910

1011
# %% ../nbs/api/18_release.ipynb #c35cc2b8
1112
from fastcore.all import *
@@ -114,16 +115,18 @@ def changelog(
114115
res = Release(repo=repo).changelog(debug=debug)
115116
if debug: print(res)
116117

118+
# %% ../nbs/api/18_release.ipynb #15b66643
119+
def push_release(token:str=None):
120+
"Create a GitHub release (changelog should already be committed/pushed). Returns the release."
121+
return Release(token=token).release()
122+
117123
# %% ../nbs/api/18_release.ipynb #6d3c5cd8
118124
@call_parse
119-
def release_git(
120-
token:str=None # Optional GitHub token (otherwise `token` file is used)
121-
):
125+
def release_git(token:str=None):
122126
"Tag and create a release in GitHub for the current version"
123-
ver = Release(token=token).release()
124-
print(f"Released {ver}")
127+
print(f"Released {push_release(token)}")
125128

126-
# %% ../nbs/api/18_release.ipynb #ad73518a
129+
# %% ../nbs/api/18_release.ipynb #94ee72b1
127130
@call_parse
128131
def release_gh(
129132
token:str=None # Optional GitHub token (otherwise `token` file is used)
@@ -135,8 +138,7 @@ def release_gh(
135138
if not input("Make release now? (y/n) ").lower().startswith('y'): sys.exit(1)
136139
run('git commit -am release')
137140
run('git push')
138-
ver = Release(token=token).release()
139-
print(f"Released {ver}")
141+
print(f"Released {push_release(token)}")
140142

141143
# %% ../nbs/api/18_release.ipynb #5b4d4aa2
142144
from fastcore.all import *

nbs/api/18_release.ipynb

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,19 @@
412412
" if debug: print(res)"
413413
]
414414
},
415+
{
416+
"cell_type": "code",
417+
"execution_count": null,
418+
"id": "15b66643",
419+
"metadata": {},
420+
"outputs": [],
421+
"source": [
422+
"#| export\n",
423+
"def push_release(token:str=None):\n",
424+
" \"Create a GitHub release (changelog should already be committed/pushed). Returns the release.\"\n",
425+
" return Release(token=token).release()"
426+
]
427+
},
415428
{
416429
"cell_type": "code",
417430
"execution_count": null,
@@ -421,18 +434,15 @@
421434
"source": [
422435
"#| export\n",
423436
"@call_parse\n",
424-
"def release_git(\n",
425-
" token:str=None # Optional GitHub token (otherwise `token` file is used)\n",
426-
"):\n",
437+
"def release_git(token:str=None):\n",
427438
" \"Tag and create a release in GitHub for the current version\"\n",
428-
" ver = Release(token=token).release()\n",
429-
" print(f\"Released {ver}\")"
439+
" print(f\"Released {push_release(token)}\")"
430440
]
431441
},
432442
{
433443
"cell_type": "code",
434444
"execution_count": null,
435-
"id": "ad73518a",
445+
"id": "94ee72b1",
436446
"metadata": {},
437447
"outputs": [],
438448
"source": [
@@ -448,8 +458,7 @@
448458
" if not input(\"Make release now? (y/n) \").lower().startswith('y'): sys.exit(1)\n",
449459
" run('git commit -am release')\n",
450460
" run('git push')\n",
451-
" ver = Release(token=token).release()\n",
452-
" print(f\"Released {ver}\")"
461+
" print(f\"Released {push_release(token)}\")"
453462
]
454463
},
455464
{
@@ -931,13 +940,7 @@
931940
]
932941
}
933942
],
934-
"metadata": {
935-
"kernelspec": {
936-
"display_name": "python3",
937-
"language": "python",
938-
"name": "python3"
939-
}
940-
},
943+
"metadata": {},
941944
"nbformat": 4,
942945
"nbformat_minor": 5
943946
}

0 commit comments

Comments
 (0)