CircleCI deploy to NPM
machine:
node:
version: 6.9.5
dependencies:
pre:
- 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
test:
override:
- rm -rf $CIRCLE_ARTIFACTS/coverage
- npm run lint
- npm run test
- cp -r coverage $CIRCLE_ARTIFACTS
- node node_modules/coveralls/bin/coveralls.js < coverage/coverage.lcov
compile:
override:
- npm run build
deployment:
feature:
branch: master
commands:
- ./config/npm-deploy-feature.sh
production:
tag: /(v)?[0-9]+(\.[0-9]+)*/
commands:
- ./config/npm-deploy.sh
#!/bin/bash
git config --global -l
git config --global user.email circleci@circleci
git config --global user.name CircleCI
git remote --v
# Get the last tag from GitHub
lastTag=$(git describe --tags $(git rev-list --tags --max-count=1))
# Bump the version
npm version $lastTag-feature.$CIRCLE_BUILD_NUM
# Push the new tag to Github
git push --tags
# Copy files to dist
cpx package.json dist
cpx README.md dist
# Publish to NPM
npm publish --tag feature
#!/bin/bash
# Get the last tag from GitHub
lastTag=$(git describe --tags $(git rev-list --tags --max-count=1))
# Print it to the console for verification
echo "Bumping version to new tag: ${lastTag}"
# Bump the version
npm --no-git-tag-version version $lastTag
# Copy files to dist
cpx package.json dist
cpx README.md dist
# Publish to NPM
npm publish