Last active
April 23, 2019 14:43
-
-
Save benjamincharity/dfd8d58ee08eb0bb42a2551144c0a21e to your computer and use it in GitHub Desktop.
CircleCI deploy to NPM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you go about pushing the updated
package.json
to the git repo? How do you avoid conflicts etc?