Skip to content

Commit

Permalink
Add make publish task
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Feb 23, 2012
1 parent 051a958 commit fb46574
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Makefile
@@ -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)

Expand Down Expand Up @@ -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.