diff --git a/.circleci/config.yml b/.circleci/config.yml index 8215a4cb..45dbfeb8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,33 +1,81 @@ -version: 2 +version: 2.1 + +commands: + install: + description: 'Yarn install' + steps: + - restore_cache: # Special step to restore the dependency cache + key: dependency-cache-{{ checksum "package.json" }} + - run: yarn install + - save_cache: + key: dependency-cache-{{ checksum "package.json" }} + paths: + - node_modules + - yarn.lock + jobs: - build: + lint: + working_directory: ~/repo docker: - image: circleci/node:12.10 steps: - checkout - - restore_cache: - name: Restore Yarn Package Cache - keys: - - yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} - - yarn-packages-{{ .Branch }} - - yarn-packages-master - - yarn-packages- - - run: - name: Install Dependencies - command: yarn install - - save_cache: - name: Save Yarn Package Cache - key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} - paths: - - node_modules/ - # Tests + - install - run: yarn lint + test: + working_directory: ~/repo + docker: + - image: circleci/node:12.10 + steps: + - checkout + - install - run: yarn test + build: + working_directory: ~/repo + docker: + - image: circleci/node:12.10 + steps: + - checkout + - install - run: yarn build - # Teardown - - store_test_results: - path: /tmp/circleci-test-results - - store_artifacts: - path: /tmp/circleci-artifacts - - store_artifacts: - path: /tmp/circleci-test-results + publish: + working_directory: ~/repo + docker: + - image: circleci/node:12.10 + steps: + - checkout + - attach_workspace: + # Must be absolute path or relative path from working_directory + at: ~/repo + - install + - run: + name: Authenticate with registry + command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc + - run: npm publish + +workflows: + version: 2 + deploy: + jobs: + - lint: + filters: + tags: + only: /.*/ + - test: + filters: + tags: + only: /.*/ + - build: + filters: + tags: + only: /.*/ + - publish: + requires: + - lint + - test + - build + filters: + branches: + ignore: /.*/ + tags: + only: /v[0-9]+\.[0-9]+\.[0-9]+.*/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f5d910a..11d8891c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Dependencies to their latest versions - CircleCI node version to 12.10 +- CircleCI configs to support auto publishing based on tags ## Change