Sha256: 64dd06b25337bd7d3d7436ba50d7f9862f0d8abb78d81fdd955dd3758e7b481f

Contents?: true

Size: 1.43 KB

Versions: 13

Compression:

Stored size: 1.43 KB

Contents

import subprocess
import sys

INCREMENTS = {
	"patch": 2,
	"minor": 1,
	"major": 0,
}

def main():
	increment = sys.argv[-1]
	if increment not in ['patch', 'minor', 'major']:
		print 'Invalid INCREMENT value. Please use "patch", "minor", or "major".'
		os.Exit(1)

	increment = INCREMENTS[increment]

	current = subprocess.check_output("git describe", shell=True).split()
	last_stable = subprocess.check_output("git tag -l", shell=True).strip().split('\n')[-1]
	if current == last_stable:
		return

	last_stable_split = last_stable.split('.')
	last_stable_split[increment] = str(int(last_stable_split[increment]) + 1)

	if increment == 0:
		last_stable_split[1] = "0"
		last_stable_split[2] = "0"

	if increment == 1:
		last_stable_split[2] = "0"

	incremented = '.'.join(last_stable_split)
	print incremented

	replace_in_file('lib/smartystreets_ruby_sdk/version.rb', last_stable, incremented)

	subprocess.check_call('git add lib/smartystreets_ruby_sdk/version.rb', shell=True)
	subprocess.check_call('git commit -m "Incremented version number to {0}"'.format(incremented), shell=True)
	subprocess.check_call('git tag -a {0} -m "{0}"'.format(incremented), shell=True)
	subprocess.check_call('git push origin master --tags', shell=True)


def replace_in_file(filename, search, replace):
	with open(filename) as source:
		updated = source.read().replace(search, replace)

	with open(filename, 'w') as update:
		update.write(updated)


if __name__ == '__main__':
	main()

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
smartystreets_ruby_sdk-5.4.0 tag.py
smartystreets_ruby_sdk-5.3.3 tag.py
smartystreets_ruby_sdk-5.3.2 tag.py
smartystreets_ruby_sdk-5.3.1 tag.py
smartystreets_ruby_sdk-5.3.0 tag.py
smartystreets_ruby_sdk-5.2.2 tag.py
smartystreets_ruby_sdk-5.2.1 tag.py
smartystreets_ruby_sdk-5.2.0 tag.py
smartystreets_ruby_sdk-5.1.1 tag.py
smartystreets_ruby_sdk-5.1.0 tag.py
smartystreets_ruby_sdk-5.0.0 tag.py
smartystreets_ruby_sdk-4.2.0 tag.py
smartystreets_ruby_sdk-4.1.3 tag.py