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.

44 lines
1.5 KiB

  1. #!/usr/bin/env python
  2. # ZIP one file as "tendermint" into a ZIP like tendermint_VERSION_OS_ARCH.zip
  3. # Use environment variables CIRCLE_TAG, GOOS and GOARCH for easy input parameters.
  4. # Optimized for CircleCI
  5. import os
  6. import argparse
  7. import zipfile
  8. import hashlib
  9. BLOCKSIZE = 65536
  10. def zip_asset(file,destination,arcname,version,goos,goarch):
  11. filename = os.path.basename(file)
  12. output = "{0}/{1}_{2}_{3}_{4}.zip".format(destination,arcname,version,goos,goarch)
  13. with zipfile.ZipFile(output,'w') as f:
  14. f.write(filename=file,arcname=arcname)
  15. f.comment=filename
  16. return output
  17. if __name__ == "__main__":
  18. parser = argparse.ArgumentParser()
  19. parser.add_argument("--file", default="build/tendermint_{0}_{1}".format(os.environ.get('GOOS'),os.environ.get('GOARCH')), help="File to zip")
  20. parser.add_argument("--destination", default="build", help="Destination folder for files")
  21. parser.add_argument("--version", default=os.environ.get('CIRCLE_TAG'), help="Version number for binary, e.g.: v1.0.0")
  22. parser.add_argument("--goos", default=os.environ.get('GOOS'), help="GOOS parameter")
  23. parser.add_argument("--goarch", default=os.environ.get('GOARCH'), help="GOARCH parameter")
  24. args = parser.parse_args()
  25. if args.version is None:
  26. raise parser.error("argument --version is required")
  27. if args.goos is None:
  28. raise parser.error("argument --goos is required")
  29. if args.goarch is None:
  30. raise parser.error("argument --goarch is required")
  31. file = zip_asset(args.file,args.destination,"tendermint",args.version,args.goos,args.goarch)
  32. print(file)