You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.9KB

  1. import sys
  2. import os
  3. import glob
  4. import json
  5. import time
  6. import build
  7. build.system("git pull")
  8. build.system("git submodule update --init --recursive")
  9. plugin_dirs = sys.argv[1:]
  10. if not plugin_dirs:
  11. plugin_dirs = glob.glob("repos/*")
  12. built_slugs = []
  13. for plugin_dir in plugin_dirs:
  14. manifest_filename = f"{plugin_dir}/plugin.json"
  15. try:
  16. with open(manifest_filename, "r") as f:
  17. manifest = json.load(f)
  18. except IOError:
  19. # Skip plugins without plugin.json
  20. continue
  21. slug = manifest['slug']
  22. library_manifest_filename = f"manifests/{slug}.json"
  23. library_manifest = None
  24. try:
  25. with open(library_manifest_filename, "r") as f:
  26. library_manifest = json.load(f)
  27. except IOError:
  28. pass
  29. # Check if the build is up to date
  30. if library_manifest and manifest['version'] == library_manifest['version']:
  31. continue
  32. # Build repo
  33. print()
  34. print(f"Building {slug}")
  35. try:
  36. build.build(plugin_dir)
  37. build.move_stage()
  38. except Exception as e:
  39. print(e)
  40. print(f"{slug} build failed")
  41. input()
  42. continue
  43. finally:
  44. build.delete_stage()
  45. # Copy manifest
  46. with open(library_manifest_filename, "w") as f:
  47. json.dump(manifest, f, indent=" ")
  48. built_slugs.append(slug)
  49. # Open plugin issue thread
  50. os.system(f"qutebrowser \"https://github.com/VCVRack/library/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+in%3Atitle+{slug}\" &")
  51. if not built_slugs:
  52. print("Nothing to build")
  53. exit(0)
  54. print("Press enter to upload packages and push library repo")
  55. input()
  56. # Upload packages
  57. build.system("cd ../packages && make upload")
  58. # Commit repository
  59. build.system("git add manifests")
  60. built_slugs_str = ", ".join(built_slugs)
  61. build.system(f"git commit -m 'Update build for {built_slugs_str}'")
  62. build.system("git push")
  63. # Delete screenshot cache
  64. for slug in built_slugs:
  65. build.system("rm -rf '../screenshots/{slug}'")
  66. print()
  67. print("Built " + ", ".join(built_slugs))
  68. print("Remember to generate and upload screenshots")