work on CI set_version
This commit is contained in:
		
							parent
							
								
									189f60e1d8
								
							
						
					
					
						commit
						ba80b3c88d
					
				| 
						 | 
					@ -3,6 +3,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
from distutils.version import LooseVersion
 | 
					from distutils.version import LooseVersion
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_version():
 | 
					def get_version():
 | 
				
			||||||
    p = subprocess.run(["git describe|sed 's/-/.post/'|cut -d'-' -f1"], shell=True, stdout=subprocess.PIPE)
 | 
					    p = subprocess.run(["git describe|sed 's/-/.post/'|cut -d'-' -f1"], shell=True, stdout=subprocess.PIPE)
 | 
				
			||||||
| 
						 | 
					@ -10,9 +12,35 @@ def get_version():
 | 
				
			||||||
    return output
 | 
					    return output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def set_version(version):
 | 
					def set_version(version):
 | 
				
			||||||
 | 
					    # modify the files to reflect the new version
 | 
				
			||||||
 | 
					    files = [os.abspath('./src/msspec/__init__.py'),
 | 
				
			||||||
 | 
					             os.abspath('./src/msspec/msspecgui/__init__.py')]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for f in files:
 | 
				
			||||||
 | 
					        with open(f, "w") as fd:
 | 
				
			||||||
 | 
					            f.write("# Auto-generated file, do not edit\n")
 | 
				
			||||||
 | 
					            f.write(f"__version__ = \"{version}\"\n")
 | 
				
			||||||
 | 
					            f.write(f"__sha__ = \"$Id$\"\n")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    with open(os.abspath("./VERSION"), "w") as fd:
 | 
				
			||||||
 | 
					            f.write(f"MsSpec-{version}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # commit them
 | 
				
			||||||
 | 
					    files = [os.abspath('./src/msspec/__init__.py'),
 | 
				
			||||||
 | 
					             os.abspath('./src/msspec/msspecgui/__init__.py'),
 | 
				
			||||||
 | 
					             os.abspath("./VERSION")]
 | 
				
			||||||
 | 
					    for f in files:
 | 
				
			||||||
 | 
					        cmd = ['git', 'add', f]
 | 
				
			||||||
 | 
					        subprocess.run(cmd)
 | 
				
			||||||
 | 
					    msg = 'Update version'
 | 
				
			||||||
 | 
					    cmd = ['git', 'commit', '-m', msg]
 | 
				
			||||||
 | 
					    subprocess.run(cmd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # create the tag
 | 
				
			||||||
    cmd = ['git', 'tag', '-a', version, '-m', f"Python MsSpec ({version})"]
 | 
					    cmd = ['git', 'tag', '-a', version, '-m', f"Python MsSpec ({version})"]
 | 
				
			||||||
    subprocess.run(cmd)
 | 
					    subprocess.run(cmd)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ask_new_version(current_version):
 | 
					def ask_new_version(current_version):
 | 
				
			||||||
    version = LooseVersion(current_version)
 | 
					    version = LooseVersion(current_version)
 | 
				
			||||||
    components = version.version
 | 
					    components = version.version
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
__version__ = '1.4post4'
 | 
					__version__ = '1.5post1'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
__version__ = '1.4post4'
 | 
					__version__ = '1.5post1'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue