Permalink
Browse files

Add make publish task

  • Loading branch information...
1 parent 051a958 commit fb465740823ffd2b33fa78494ce2dabe0d3adfb7 @ixti ixti committed Feb 23, 2012
Showing with 20 additions and 6 deletions.
  1. +20 −6 Makefile
View
@@ -1,14 +1,16 @@
PATH := $(shell pwd)/node_modules/.bin:${PATH}
-PROJECT := $(notdir ${PWD})
-TMP_PATH := /tmp/${PROJECT}-$(shell date +%s)
+NPM_PACKAGE := $(shell node -e 'console.log(require("./package.json").name)')
+NPM_VERSION := $(shell node -e 'console.log(require("./package.json").version)')
+
+TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
REMOTE_NAME ?= origin
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
-CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master)
-GITHUB_NAME := nodeca/js-yaml
-SRC_URL_FMT := https://github.com/${GITHUB_NAME}/blob/${CURR_HEAD}/{file}\#L{line}
+CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master)
+GITHUB_PROJ := nodeca/${NPM_PACKAGE}
+SRC_URL_FMT := https://github.com/${GITHUB_PROJ}/blob/${CURR_HEAD}/{file}\#L{line}
JS_FILES := $(shell find ./bin ./lib ./test -type f -name '*.js' -print)
@@ -73,8 +75,20 @@ gh-pages:
git push --force remote +master:gh-pages
rm -rf ${TMP_PATH}
+publish:
+ @if test 0 -ne `git status --porcelain | wc -l` ; then \
+ echo "Unclean working tree. Commit or stash changes first." >&2 ; \
+ exit 128 ; \
+ fi
+ @if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \
+ echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \
+ exit 128 ; \
+ fi
+ git tag ${NPM_VERSION} && git push origin ${NPM_VERSION}
+ npm publish https://github.com/${GITHUB_PROJ}/tarball/${NPM_VERSION}
+
todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true
-.PHONY: test lint dev-deps gh-pages todo
+.PHONY: publish test lint dev-deps gh-pages todo
.SILENT: todo test test-functional test-issues

0 comments on commit fb46574

Please sign in to comment.