1010from nox .sessions import Session
1111
1212
13- HERE = Path (__file__ ).parent
13+ ROOT = Path (__file__ ).parent
1414POSARGS_PATTERN = re .compile (r"^(\w+)\[(.+)\]$" )
1515
1616
@@ -39,7 +39,7 @@ def example(session: Session) -> None:
3939 """Run an example"""
4040 if not session .posargs :
4141 print ("No example name given. Choose from:" )
42- for found_example_file in (HERE / "docs" / "source" / "examples" ).glob ("*.py" ):
42+ for found_example_file in (ROOT / "docs" / "source" / "examples" ).glob ("*.py" ):
4343 print ("-" , found_example_file .stem )
4444 return None
4545
@@ -175,6 +175,44 @@ def test_docs(session: Session) -> None:
175175 session .run ("sphinx-build" , "-b" , "doctest" , "docs/source" , "docs/build" )
176176
177177
178+ @nox .session
179+ def tag (session : Session ):
180+ try :
181+ session .run (
182+ "git" ,
183+ "diff" ,
184+ "--cached" ,
185+ "--exit-code" ,
186+ silent = True ,
187+ external = True ,
188+ )
189+ except Exception :
190+ session .error ("Cannot create a tag - tROOT are uncommited changes" )
191+
192+ version = (ROOT / "VERSION" ).read_text ().strip ()
193+ install_requirements_file (session , "make-release" )
194+ session .run ("pysemver" , "check" , version )
195+
196+ session .run ("git" , "tag" , version , external = True )
197+
198+ if "push" in session .posargs :
199+ session .run ("git" , "push" , "--tags" , external = True )
200+
201+
202+ @nox .session
203+ def update_version (session : Session ) -> None :
204+ if len (session .posargs ) > 1 :
205+ session .error ("To many arguments" )
206+
207+ try :
208+ version = session .posargs [0 ]
209+ except IndexError :
210+ session .error ("No version tag given" )
211+
212+ install_requirements_file (session , "make-release" )
213+ session .run ("python" , "scripts/update_versions.py" , version )
214+
215+
178216@nox .session (reuse_venv = True )
179217def latest_pull_requests (session : Session ) -> None :
180218 """A basic script for outputing changelog info"""
@@ -190,7 +228,7 @@ def latest_closed_issues(session: Session) -> None:
190228
191229
192230def install_requirements_file (session : Session , name : str ) -> None :
193- file_path = HERE / "requirements" / (name + ".txt" )
231+ file_path = ROOT / "requirements" / (name + ".txt" )
194232 assert file_path .exists (), f"requirements file { file_path } does not exist"
195233 session .install ("-r" , str (file_path ))
196234
0 commit comments