Skip to content

Commit

Permalink
chore: upgrade circleci to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yeojz committed Jun 20, 2018
1 parent f987367 commit 1676f12
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 27 deletions.
181 changes: 181 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
aliases:
- &restore_test_cache
keys:
- test-{{ .Environment.PROJECT_CACHE_VERSION }}-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}

- &save_test_cache
paths:
- ./node_modules
key: test-{{ .Environment.PROJECT_CACHE_VERSION }}-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}

- &restore_release_cache
keys:
- release-{{ .Environment.PROJECT_CACHE_VERSION }}-{{ checksum "package-lock.json" }}

- &save_release_cache
paths:
- ./node_modules
key: release-{{ .Environment.PROJECT_CACHE_VERSION }}-{{ checksum "package-lock.json" }}

- &install_npm
name: install dependencies
command: |
npm install
- &build_package
name: build package
command: |
npm run clean
npm run build
- &filter_common
branches:
ignore: gh-pages
tags:
ignore: /.*/

- &filter_tag_all
tags:
only: /^v.*/
branches:
ignore: /.*/

- &filter_tag_stable
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
branches:
ignore: /.*/

- &filter_tag_beta
tags:
only: /^v[0-9]+(\.[0-9]+)*\-[0-9]+$/
branches:
ignore: /.*/

- &node_tests
working_directory: ~/yeojz/babel-plugin-transform-assets-import-to-string
steps:
- checkout
- restore-cache: *restore_test_cache
- run: *install_npm
- save_cache: *save_test_cache
- run: *build_package
- run:
name: test
command: npm run test

- &defaults
working_directory: ~/yeojz/babel-plugin-transform-assets-import-to-string
docker:
- image: circleci/node:8

- &npm_publish
steps:
- checkout
- restore-cache: *restore_release_cache
- run: *install_npm
- run:
name: install conventional-github-releaser
command: npm install --no-save conventional-github-releaser
- save_cache: *save_release_cache
- run:
name: update github release description
command: npx conventional-github-releaser -p angular
- run:
name: build for npm
command: |
npm run clean
npm run build
- run:
working_directory: ~/yeojz/babel-plugin-transform-assets-import-to-string
name: publish to npm
command: |
echo "npm tag = $RUNTIME_NPM_TAG"
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm publish --tag $RUNTIME_NPM_TAG
else
echo "skipping publication."
fi
version: 2
jobs:
node_v8:
<<: *defaults
steps:
- checkout
- restore-cache: *restore_test_cache
- run: *install_npm
- save_cache: *save_test_cache
- run: *build_package
- run:
name: test
command: npm run test
- run:
name: lint
command: |
npm run lint
- run:
name: send coverage report
command: npm run coveralls
when: on_success

node_v6:
docker:
- image: circleci/node:6
<<: *node_tests

node_v10:
docker:
- image: circleci/node:10
<<: *node_tests

publish_npm_stable:
environment:
RUNTIME_NPM_TAG: latest
<<: *defaults
<<: *npm_publish

publish_npm_beta:
environment:
RUNTIME_NPM_TAG: next
<<: *defaults
<<: *npm_publish

workflows:
version: 2
dev-builds:
jobs:
- node_v6:
filters: *filter_common
- node_v8:
filters: *filter_common
- node_v10:
filters: *filter_common
release-builds:
jobs:
- node_v6:
filters: *filter_tag_all
- node_v8:
filters: *filter_tag_all
- node_v10:
filters: *filter_tag_all
- publish_npm_beta:
requires:
- node_v6
- node_v8
- node_v10
filters: *filter_tag_beta
- hold:
type: approval
requires:
- node_v6
- node_v8
- node_v10
filters: *filter_tag_stable
- publish_npm_stable:
requires:
- hold
filters: *filter_tag_stable

27 changes: 0 additions & 27 deletions circle.yml

This file was deleted.

0 comments on commit 1676f12

Please sign in to comment.