Skip to content

Commit

Permalink
build(ci): add publish step and use circleci workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaspden committed Feb 1, 2020
1 parent d439d25 commit f6e2abe
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 16 deletions.
101 changes: 87 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,111 @@
version: 2.1
jobs:
build:
---
executors:
node:
docker:
- image: circleci/node:10.16.0
working_directory: ~/app
jobs:
build:
executor: node
steps:
- attach_workspace:
at: ~/
- run:
command: yarn build
name: Build the Typescript files
- persist_to_workspace:
paths:
- app
root: ~/
check:
executor: node
steps:
- attach_workspace:
at: ~/
- run:
command: |
npx prettier --check \
'**/*.md' \
'**/*.json' \
'**/*.ts' \
'**/*.yml' \
.prettierrc
name: Check that each file is formatted appropriately
publish:
executor: node
steps:
- attach_workspace:
at: ~/
- run:
name: Add authentication for the npm registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
- run:
name: Publish the project to npm
command: npm publish --access public
setup:
executor: node
steps:
- add_ssh_keys:
fingerprints:
- '88:6f:95:4d:b2:1a:5e:25:cc:d5:7f:ac:25:93:2e:11'
- 88:6f:95:4d:b2:1a:5e:25:cc:d5:7f:ac:25:93:2e:11
- run:
name: Setup git author email address
command: git config --global user.email "$USER_EMAIL"
name: Setup git author email address
- run:
name: Setup git author name
command: git config --global user.name "$USER_NAME"
name: Setup git author name
- checkout
- restore_cache:
name: Restores the Yarn package cache if possible
key: dependency-cache-{{ checksum "yarn.lock" }}
name: Restores the Yarn package cache if possible
- run:
name: Install package dependencies
command: yarn install
name: Install package dependencies
- save_cache:
name: Saves the Yarn package cache
key: dependency-cache-{{ checksum "yarn.lock" }}
name: Saves the Yarn package cache
paths:
- ~/.cache/yarn
- persist_to_workspace:
paths:
- app
root: ~/
test:
executor: node
steps:
- attach_workspace:
at: ~/
- run:
name: Run unit tests with code
command: yarn test:cov
name: Run unit tests with code
- store_artifacts:
path: coverage
- run:
name: Upload test coverage report to Codecov
command: yarn codecov
- run:
name: Build the Typescript files
command: yarn build
name: Upload test coverage report to Codecov
version: 2.1
workflows:
build_test_and_publish:
jobs:
- setup
- build:
requires:
- setup
- check:
requires:
- setup
- test:
requires:
- setup
- publish:
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
requires:
- build
- check
- test
type: approval
version: 2
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

---

*Add any extra details about your changes*
_Add any extra details about your changes_
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### Project Specific ###
coverage/
lib/

### Linux ###
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coverage/**
lib/**
node_modules/**
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"build": "tsc -p tsconfig.build.json",
"codecov": "codecov",
"format": "prettier --write \"src/**/*.ts\" \"example/**/*.ts\"",
"format": "prettier --write '**/*.md' '**/*.json' '**/*.ts' '**/*.yml' .prettierrc",
"prebuild": "rimraf lib",
"prepublish:npm": "yarn build",
"publish:npm": "yarn publish --access public",
Expand Down

0 comments on commit f6e2abe

Please sign in to comment.