[U] Deploy tool: Automatically create release and deploy
This commit is contained in:
parent
712cf097f4
commit
d8ce41a212
2 changed files with 56 additions and 1 deletions
55
tools/deploy-release.py
Normal file → Executable file
55
tools/deploy-release.py
Normal file → Executable file
|
@ -37,6 +37,7 @@ def edit_versions(version: str):
|
||||||
:param version: Version to release
|
:param version: Version to release
|
||||||
"""
|
"""
|
||||||
# 1. package.json
|
# 1. package.json
|
||||||
|
print('Editing package.json...')
|
||||||
path = Path('package.json')
|
path = Path('package.json')
|
||||||
content = json.loads(path.read_text())
|
content = json.loads(path.read_text())
|
||||||
cur = pv.parse(content['version'])
|
cur = pv.parse(content['version'])
|
||||||
|
@ -45,11 +46,13 @@ def edit_versions(version: str):
|
||||||
path.write_text(json.dumps(content, ensure_ascii=False, indent=2))
|
path.write_text(json.dumps(content, ensure_ascii=False, indent=2))
|
||||||
|
|
||||||
# 2. hyfetch/constants.py
|
# 2. hyfetch/constants.py
|
||||||
|
print('Editing hyfetch/constants.py...')
|
||||||
path = Path('hyfetch/constants.py')
|
path = Path('hyfetch/constants.py')
|
||||||
content = [f"VERSION = '{version}'" if l.startswith('VERSION = ') else l for l in path.read_text().split('\n')]
|
content = [f"VERSION = '{version}'" if l.startswith('VERSION = ') else l for l in path.read_text().split('\n')]
|
||||||
path.write_text('\n'.join(content))
|
path.write_text('\n'.join(content))
|
||||||
|
|
||||||
# 3. README.md
|
# 3. README.md
|
||||||
|
print('Editing README.md...')
|
||||||
path = Path('README.md')
|
path = Path('README.md')
|
||||||
content = path.read_text()
|
content = path.read_text()
|
||||||
changelog_i = content.index('<!-- CHANGELOG STARTS HERE --->')
|
changelog_i = content.index('<!-- CHANGELOG STARTS HERE --->')
|
||||||
|
@ -59,6 +62,7 @@ def edit_versions(version: str):
|
||||||
path.write_text(content)
|
path.write_text(content)
|
||||||
|
|
||||||
# 4. neofetch script
|
# 4. neofetch script
|
||||||
|
print('Editing neofetch...')
|
||||||
path = Path('neofetch')
|
path = Path('neofetch')
|
||||||
lines = path.read_text().split('\n')
|
lines = path.read_text().split('\n')
|
||||||
version_i = next(i for i, l in enumerate(lines) if l.startswith('version='))
|
version_i = next(i for i, l in enumerate(lines) if l.startswith('version='))
|
||||||
|
@ -74,6 +78,7 @@ def finalize_neofetch():
|
||||||
Finalize current version
|
Finalize current version
|
||||||
"""
|
"""
|
||||||
# 1. Update distro list
|
# 1. Update distro list
|
||||||
|
print('Updating distro list in neofetch...')
|
||||||
path = Path('neofetch')
|
path = Path('neofetch')
|
||||||
content = path.read_text()
|
content = path.read_text()
|
||||||
content = re.compile(r'(?<=# Flag: --ascii_distro\n#\n).*?(?=ascii_distro=)', re.DOTALL)\
|
content = re.compile(r'(?<=# Flag: --ascii_distro\n#\n).*?(?=ascii_distro=)', re.DOTALL)\
|
||||||
|
@ -83,11 +88,58 @@ def finalize_neofetch():
|
||||||
path.write_text(content)
|
path.write_text(content)
|
||||||
|
|
||||||
# 2. Regenerate man page
|
# 2. Regenerate man page
|
||||||
|
print('Regenerating neofetch man page...')
|
||||||
Path('neofetch.1').write_text(subprocess.check_output(['help2man', './neofetch']).decode())
|
Path('neofetch.1').write_text(subprocess.check_output(['help2man', './neofetch']).decode())
|
||||||
|
|
||||||
# 3. Reformat readme links
|
# 3. Reformat readme links
|
||||||
|
print('Reformatting readme links...')
|
||||||
reformat_readme()
|
reformat_readme()
|
||||||
|
|
||||||
|
|
||||||
|
def post_check():
|
||||||
|
"""
|
||||||
|
Check after changes are made
|
||||||
|
"""
|
||||||
|
subprocess.check_call(shlex.split('shellcheck neofetch'))
|
||||||
|
|
||||||
|
|
||||||
|
def create_release(v: str):
|
||||||
|
"""
|
||||||
|
Create release commit and tag
|
||||||
|
"""
|
||||||
|
print('Committing changes...')
|
||||||
|
|
||||||
|
# 1. Add files
|
||||||
|
subprocess.check_call(['git', 'add', 'hyfetch/constants.py', 'neofetch', 'neofetch.1', 'package.json', 'README.md'])
|
||||||
|
|
||||||
|
# 2. Commit
|
||||||
|
subprocess.check_call(['git', 'commit', '-m', f'[U] Release {v}'])
|
||||||
|
|
||||||
|
# 3. Create tag
|
||||||
|
subprocess.check_call(['git', 'tag', v])
|
||||||
|
|
||||||
|
i = input('Please check the commit is correct. Press y to continue or any other key to cancel.')
|
||||||
|
assert i == 'y'
|
||||||
|
|
||||||
|
# 4. Push
|
||||||
|
print('Pushing commits...')
|
||||||
|
subprocess.check_call(['git', 'push'])
|
||||||
|
|
||||||
|
|
||||||
|
def deploy():
|
||||||
|
"""
|
||||||
|
Deploy release to pip and npm
|
||||||
|
"""
|
||||||
|
print('Deploying to pypi...')
|
||||||
|
subprocess.check_call(['bash', './deploy.sh'])
|
||||||
|
print('Done!')
|
||||||
|
|
||||||
|
print('Deploying to npm...')
|
||||||
|
otp = input('Please provide 2FA OTP for NPM: ')
|
||||||
|
subprocess.check_call(['npm', 'publish', '--otp', otp])
|
||||||
|
print('Done!')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description='HyFetch Release Utility')
|
parser = argparse.ArgumentParser(description='HyFetch Release Utility')
|
||||||
parser.add_argument('version', help='Version to release')
|
parser.add_argument('version', help='Version to release')
|
||||||
|
@ -97,4 +149,7 @@ if __name__ == '__main__':
|
||||||
pre_check()
|
pre_check()
|
||||||
edit_versions(args.version)
|
edit_versions(args.version)
|
||||||
finalize_neofetch()
|
finalize_neofetch()
|
||||||
|
post_check()
|
||||||
|
create_release(args.version)
|
||||||
|
deploy()
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
* [x] Regenerate man page (`help2man ./neofetch > neofetch.1`)
|
* [x] Regenerate man page (`help2man ./neofetch > neofetch.1`)
|
||||||
* [ ] Create an RC release and deploy to pypi, try installing and testing on many distros.
|
* [ ] Create an RC release and deploy to pypi, try installing and testing on many distros.
|
||||||
* [ ] Change back to stable release, create tag, create GitHub release
|
* [ ] Change back to stable release, create tag, create GitHub release
|
||||||
* [ ] Formally deploy to pypi and npm (`tools/deploy.sh`, `npm publish`)
|
* [x] Formally deploy to pypi and npm (`tools/deploy.sh`, `npm publish`)
|
||||||
* [ ] Update ArchLinux AUR and NixOS packaging
|
* [ ] Update ArchLinux AUR and NixOS packaging
|
||||||
|
|
Loading…
Reference in a new issue