浏览代码

[+] Deploy tool: Automatically update help page and regenerate man

Azalea (on HyDEV-Daisy) 2 年之前
父节点
当前提交
92ae4b4316
共有 3 个文件被更改,包括 30 次插入6 次删除
  1. 20 0
      tools/deploy-release.py
  2. 5 5
      tools/deploy.md
  3. 5 1
      tools/reformat_readme.py

+ 20 - 0
tools/deploy-release.py

@@ -69,6 +69,25 @@ def edit_versions(version: str):
     path.write_text('\n'.join(lines))
 
 
+def finalize_neofetch():
+    """
+    Finalize current version
+    """
+    # 1. Update distro list
+    path = Path('neofetch')
+    content = path.read_text()
+    content = re.compile(r'(?<=# Flag:    --ascii_distro\n#\n).*?(?=ascii_distro=)', re.DOTALL)\
+        .sub(generate_help(100, '# ') + '\n', content)
+    content = re.compile(r"""(?<=Which Distro's ascii art to print\n\n).*?{distro}_small to use them\.""", re.DOTALL)\
+        .sub(generate_help(100, ' ' * 32), content)
+    path.write_text(content)
+
+    # 2. Regenerate man page
+    Path('neofetch.1').write_text(subprocess.check_output(['help2man', './neofetch']).decode())
+
+    # 3. Reformat readme links
+    reformat_readme()
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='HyFetch Release Utility')
     parser.add_argument('version', help='Version to release')
@@ -77,4 +96,5 @@ if __name__ == '__main__':
 
     pre_check()
     edit_versions(args.version)
+    finalize_neofetch()
 

+ 5 - 5
tools/deploy.md

@@ -1,10 +1,10 @@
 ### Things to do before deploying...
 
-* [ ] Check file permissions (+x)
-* [ ] Update version numbers (`README.md`, `package.json`, `hyfetch/constants.py`, `neofetch`)
-* [ ] Check Shellcheck (should be automatic)
-* [ ] Update distro list in neofetch help (`tools/list_distros.py`)
-* [ ] Regenerate man page (`help2man ./neofetch > neofetch.1`)
+* [x] Check file permissions (+x)
+* [x] Check Shellcheck (should be automatic)
+* [x] Update version numbers (`README.md`, `package.json`, `hyfetch/constants.py`, `neofetch`)
+* [x] Update distro list in neofetch help (`tools/list_distros.py`)
+* [x] Regenerate man page (`help2man ./neofetch > neofetch.1`)
 * [ ] 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
 * [ ] Formally deploy to pypi and npm (`tools/deploy.sh`, `npm publish`)

+ 5 - 1
tools/reformat_readme.py

@@ -10,7 +10,7 @@ from pathlib import Path
 RE_SHORTHAND = re.compile(r"""[a-z0-9]+?/[a-z0-9]+?#[0-9]+""")
 
 
-if __name__ == '__main__':
+def reformat_readme():
     readme = Path('README.md').read_text()
 
     for shorthand in RE_SHORTHAND.findall(readme):
@@ -19,3 +19,7 @@ if __name__ == '__main__':
         readme = readme.replace(shorthand, f'[{user}#{pull}](https://github.com/{user}/{repo}/pull/{pull})')
 
     Path('README.md').write_text(readme)
+
+
+if __name__ == '__main__':
+    reformat_readme()