Add release.py script for making releases and add documentation for this.
This commit is contained in:
parent
e4daeb15d2
commit
ec1725c507
2 changed files with 47 additions and 4 deletions
44
release.py
Executable file
44
release.py
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def get_version():
|
||||
path = os.path.join(
|
||||
dir_path,
|
||||
'theanarchistlibrary_store',
|
||||
'__init__.py',
|
||||
)
|
||||
with open(path, 'r') as file:
|
||||
lines = file.read().split('\n')
|
||||
for line in lines:
|
||||
line_ = line.lower().strip()
|
||||
if line_.startswith('version = '):
|
||||
parts = line_[10:].lstrip('(').rstrip(')').split(',')
|
||||
numbers = [int(part) for part in parts]
|
||||
return '{}.{}.{}'.format(*numbers)
|
||||
|
||||
|
||||
def release():
|
||||
version = get_version()
|
||||
tgt_fn = f'theanarchistlibrary_store_v{version}.zip'
|
||||
tgt_path = os.path.join(dir_path, 'releases', tgt_fn)
|
||||
src_glob = os.path.join(
|
||||
dir_path,
|
||||
'theanarchistlibrary_store',
|
||||
'**',
|
||||
)
|
||||
with ZipFile(tgt_path, 'w') as zip:
|
||||
for path in glob.glob(src_glob, recursive=True):
|
||||
arcname = path[(len(src_glob) - 2):]
|
||||
if arcname:
|
||||
zip.write(path, arcname=arcname)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
release()
|
Loading…
Add table
Add a link
Reference in a new issue