Skip to content

Instantly share code, notes, and snippets.

@CJKinni
Last active August 29, 2015 14:15
Show Gist options
  • Save CJKinni/6c6f0405a266cc53d574 to your computer and use it in GitHub Desktop.
Save CJKinni/6c6f0405a266cc53d574 to your computer and use it in GitHub Desktop.
Chrome Extension auto-increment version number and zip extension on commit via git hooks
#!/usr/bin/env ruby
require 'json'
filename = './manifest.json'
text = File.read(filename)
json = JSON.parse(text)
oldVersion = json['version']
version = json['version'].split(".")
if (version[2] == "9")
version[2] = "0"
version[1] = (version[1].to_i + 1).to_s
else
version[-1] = (version[-1].to_i + 1).to_s
end
vstring = version[0] + "." + version[1] + "." + version[2]
json['version'] = vstring
File.open(filename, "w") do |f|
f.write(JSON.pretty_generate(json))
end
Dir.chdir('..')
`zip -r "TrademarkSearchHelper/Builds/TrademarkSearchHelper-#{oldVersion}.zip" "TrademarkSearchHelper" -x "*.zip*"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment