Skip to content

Commit 3a783ad

Browse files
authored
chore: add release scripts (#94)
* chore: add release scripts * chore: add circleci script for publishing to npm
1 parent efa96be commit 3a783ad

File tree

2 files changed

+69
-15
lines changed

2 files changed

+69
-15
lines changed

.circleci/config.yml

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@ version: 2.1
22

33
supported-eslint-versions: &supported-eslint-versions ["local", "7"]
44

5+
deploy_filters: &deploy_filters
6+
filters:
7+
branches:
8+
ignore: /.*/
9+
tags:
10+
# Trigger on tags that begin with `v`
11+
only: /^v.*/
12+
13+
commands:
14+
save_yarn_cache:
15+
description: Save Yarn cache for future build
16+
steps:
17+
- save_cache:
18+
key: v1-yarn-deps-{{ checksum "yarn.lock" }}
19+
paths:
20+
- ~/.cache/yarn
21+
22+
restore_yarn_cache:
23+
description: Restore Yarn cache from previous build
24+
steps:
25+
- restore_cache:
26+
keys:
27+
- v1-yarn-deps-{{ checksum "yarn.lock" }}
28+
529
jobs:
630
build:
731
parameters:
@@ -16,18 +40,12 @@ jobs:
1640

1741
steps:
1842
- checkout
43+
- restore_yarn_cache
44+
- run:
45+
name: Install dependencies and build
46+
command: yarn install --frozen-lockfile
1947

20-
- restore_cache:
21-
keys:
22-
- v1-dependencies-{{ checksum "yarn.lock" }}
23-
- v1-dependencies-
24-
25-
- run: yarn install --frozen-lock
26-
27-
- save_cache:
28-
paths:
29-
- node_modules
30-
key: v1-dependencies-{{ checksum "yarn.lock" }}
48+
- save_yarn_cache
3149
- when:
3250
condition:
3351
not:
@@ -36,10 +54,31 @@ jobs:
3654
- run:
3755
name: Override version of eslint@<<parameters.eslint-version>>
3856
command: yarn add eslint@<<parameters.eslint-version>> --dev
39-
- run: yarn format:check
40-
- run: yarn lint
41-
- run: yarn test
57+
- run:
58+
name: Check formatting
59+
command: yarn format:check
60+
- run:
61+
name: Run linter
62+
command: yarn lint
63+
- run:
64+
name: Run unit tests
65+
command: yarn test
4266

67+
deploy:
68+
docker:
69+
- image: circleci/node
70+
steps:
71+
- checkout
72+
- restore_yarn_cache
73+
- run:
74+
name: Install dependencies and build
75+
command: yarn install --frozen-lockfile
76+
- run:
77+
name: Configure NPM authentication
78+
command: npm config set "//registry.npmjs.org/:_authToken" "$NPM_AUTOMATION_TOKEN"
79+
- run:
80+
name: Publish package
81+
command: yarn release:publish
4382

4483
workflows:
4584
build_and_test:
@@ -48,3 +87,16 @@ workflows:
4887
matrix:
4988
parameters:
5089
eslint-version: *supported-eslint-versions
90+
91+
build_and_test_and_deploy:
92+
jobs:
93+
- build:
94+
<<: *deploy_filters
95+
matrix:
96+
parameters:
97+
eslint-version: *supported-eslint-versions
98+
99+
- deploy:
100+
<<: *deploy_filters
101+
requires:
102+
- build

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"format": "prettier --write \"**/*.{js,md}\"",
1616
"format:check": "prettier --check \"**/*.{js,md}\"",
1717
"lint": "eslint",
18-
"test": "mocha"
18+
"test": "mocha",
19+
"release:version": "npm version",
20+
"release:publish": "npm publish --registry=https://registry.npmjs.org"
1921
},
2022
"dependencies": {
2123
"@babel/core": "~7.17.8",

0 commit comments

Comments
 (0)