Skip to content

Commit 7eacee6

Browse files
authored
Merge pull request #1535 from AnswerDotAI/check-version-before-changelog
check version before changelog
2 parents b30aff0 + 206cced commit 7eacee6

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: true
1515
matrix:
1616
os: [ubuntu, macos]
17-
version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
17+
version: ["3.10", "3.11", "3.12", "3.13"]
1818
runs-on: ${{ matrix.os }}-latest
1919
steps:
2020
- uses: answerdotai/workflows/nbdev-ci@master

nbdev/release.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ghapi.core import *
1313

1414
from datetime import datetime
15+
from packaging.version import Version
1516
import shutil,subprocess
1617

1718
from .doclinks import *
@@ -71,8 +72,11 @@ def changelog(self:Release,
7172
"Create the CHANGELOG.md file, or return the proposed text if `debug` is `True`"
7273
if not self.changefile.exists(): self.changefile.write_text("# Release notes\n\n<!-- do not remove -->\n")
7374
marker = '<!-- do not remove -->\n'
74-
try: self.commit_date = self.gh.repos.get_latest_release().published_at
75-
except HTTP404NotFoundError: self.commit_date = '2000-01-01T00:00:004Z'
75+
try: self.commit_date = (lr:=self.gh.repos.get_latest_release()).published_at
76+
except HTTP404NotFoundError: lr,self.commit_date = None,'2000-01-01T00:00:004Z'
77+
if lr and (Version(self.cfg.version) <= Version(lr.tag_name)):
78+
print(f'Error: Version bump required: expected: >{lr.tag_name}, got: {self.cfg.version}.')
79+
raise SystemExit(1)
7680
res = f"\n## {self.cfg.version}\n"
7781
issues = self._issue_groups()
7882
res += '\n'.join(_issues_txt(*o) for o in zip(issues, self.groups.values()))

nbs/api/18_release.ipynb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"from ghapi.core import *\n",
159159
"\n",
160160
"from datetime import datetime\n",
161+
"from packaging.version import Version\n",
161162
"import shutil,subprocess\n",
162163
"\n",
163164
"from nbdev.doclinks import *"
@@ -285,8 +286,11 @@
285286
" \"Create the CHANGELOG.md file, or return the proposed text if `debug` is `True`\"\n",
286287
" if not self.changefile.exists(): self.changefile.write_text(\"# Release notes\\n\\n<!-- do not remove -->\\n\")\n",
287288
" marker = '<!-- do not remove -->\\n'\n",
288-
" try: self.commit_date = self.gh.repos.get_latest_release().published_at\n",
289-
" except HTTP404NotFoundError: self.commit_date = '2000-01-01T00:00:004Z'\n",
289+
" try: self.commit_date = (lr:=self.gh.repos.get_latest_release()).published_at\n",
290+
" except HTTP404NotFoundError: lr,self.commit_date = None,'2000-01-01T00:00:004Z'\n",
291+
" if lr and (Version(self.cfg.version) <= Version(lr.tag_name)): \n",
292+
" print(f'Error: Version bump required: expected: >{lr.tag_name}, got: {self.cfg.version}.')\n",
293+
" raise SystemExit(1)\n",
290294
" res = f\"\\n## {self.cfg.version}\\n\"\n",
291295
" issues = self._issue_groups()\n",
292296
" res += '\\n'.join(_issues_txt(*o) for o in zip(issues, self.groups.values()))\n",
@@ -867,13 +871,6 @@
867871
"#| hide\n",
868872
"import nbdev; nbdev.nbdev_export()"
869873
]
870-
},
871-
{
872-
"cell_type": "code",
873-
"execution_count": null,
874-
"metadata": {},
875-
"outputs": [],
876-
"source": []
877874
}
878875
],
879876
"metadata": {

0 commit comments

Comments
 (0)