This script will push a new version of the given package on GitHub and PyPI.
It assumes that you are in the main directory of the package and have successfully ran buildout, and that you have submitted all changes that should go into the new version.
By default, four steps are executed, in this order:
- tag: The --stable-version will be set, added to GitHub, tagged in GitHub and pushed.
- pypi: The --stable-version will be registered and uploaded to PyPI
- docs: The documentation will be generated and uploaded to PythonHosted
- latest: The --latest-version will be set and committed to GitHub
If any of these commands fail, the remaining steps will be skipped, unless you specify the --keep-going option
parser.add_argument("--stable-version",'-s',required=True,help="The stable version for the package")
parser.add_argument("--latest-version",'-l',required=True,help="The latest version for the package")
parser.add_argument("--steps",nargs="+",choices=['tag','pypi','docs','latest'],default=['tag','pypi','docs','latest'],help="Select the steps that you want to execute")
parser.add_argument("--dry-run",'-q',action='store_true',help="Only print the actions, but do not execute them")
parser.add_argument("--keep-going",'-f',action='store_true',help="Run all steps, even if some of them fail. HANDLE THIS FLAG WITH CARE!")
parser.add_argument("--verbose",'-v',action='store_true',help="Print more information")
args=parser.parse_args()
# assert the the version file is there
version_file='version.txt'
assertos.path.exists(version_file)
defrun_commands(version,*calls):
"""Updates the version.txt to the given version and runs the given commands."""
ifargs.verboseorargs.dry_run:
print (" - cat '%s' > %s"%(version,version_file))
ifnotargs.dry_run:
# update version to stable version, if not done yet
print ("\nTagging version '%s'"%args.stable_version)
# update stable version on github and add a tag
run_commands(args.stable_version,['git','submodule','add','version.txt'],['git','commit','-m','"Increased version to %s [skip ci]"'%args.stable_version],['git''tag','v%s'%args.stable_version],['git','push','--tags'])
else:
print ("\nSkipping the 'tag' step since the the current version '%s' is already the stable version '%s'"%(current_version,args.latest_version))
print ("\nSetting latest version '%s'"%args.latest_version)
run_commands(args.latest_version,['git','submodule','add','version.txt'],['git','commit','-m','"Increased version to %s [skip ci]"'%args.latest_version],['git','push'])