Skip to content
Browse files

Automating version management a little, adding new simple make tasks …

…to automatically bump major/minor/patch version number in `package.json` and `README.md`. No commit is done, both files is just updated.
  • Loading branch information...
1 parent e99f5b1 commit 32d46f1de029e1f7e6da9676226ca5aca256e272 @arboleya committed
Showing with 63 additions and 6 deletions.
  1. +44 −0 build/bumper.coffee
  2. +19 −6 makefile
View
44 build/bumper.coffee
@@ -0,0 +1,44 @@
+fs = require 'fs'
+path = require 'path'
+
+filepath = path.join __dirname, "../package.json"
+json = JSON.parse (fs.readFileSync filepath, "utf-8")
+version = json.version
+
+[major,minor,patch] = version.split '.'
+
+switch process.argv[2]
+ when '--major'
+ major++
+ minor = 0
+ patch = 0
+ break
+ when '--minor'
+ minor++
+ patch = 0
+ break
+ when '--patch'
+ patch++
+ break
+ when '--version'
+ console.log version
+ process.exit()
+
+new_version = "#{major}.#{minor}.#{patch}"
+
+console.log version
+console.log new_version
+
+# updating README
+filepath = path.join __dirname, "../README.md"
+contents = fs.readFileSync filepath, 'utf-8'
+search = />\sVersion\s[0-9]+.[0-9]+.[0-9]+/
+replace = '> Version ' + new_version
+fs.writeFileSync filepath, (contents.replace search, replace)
+
+# updating package.json
+filepath = path.join __dirname, "../package.json"
+contents = fs.readFileSync filepath, 'utf-8'
+search = /"version":\s"[0-9]+.[0-9]+.[0-9]+"/
+replace = "\"version\": \"#{new_version}\""
+fs.writeFileSync filepath, (contents.replace search, replace)
View
25 makefile
@@ -1,5 +1,7 @@
.PHONY: build
+VERSION=`coffee build/bumper --version`
+
watch:
build/coffee-toaster/bin/toaster . -w
@@ -9,16 +11,27 @@ build:
test: build
node_modules/vows/bin/vows spec/*.coffee --spec
+
+bump.minor:
+ coffee build/bumper.coffee --minor
+
+bump.major:
+ coffee build/bumper.coffee --major
+
+bump.patch:
+ coffee build/bumper.coffee --patch
+
+
publish:
- git tag $(v)
- git push origin $(v)
+ git tag $(VERSION)
+ git push origin $(VERSION)
git push origin master
npm publish
re-publish:
- git tag -d $(v)
- git tag $(v)
- git push origin :$(v)
- git push origin $(v)
+ git tag -d $(VERSION)
+ git tag $(VERSION)
+ git push origin :$(VERSION)
+ git push origin $(VERSION)
git push origin master -f
npm publish -f

0 comments on commit 32d46f1

Please sign in to comment.
Something went wrong with that request. Please try again.