Skip to content

Commit 4c13a88

Browse files
authored
chore: standardize release script (#270)
* chore: standardize release script * chore: add explicit registry * chore: add circleci script for publishing to npm
1 parent ca5b865 commit 4c13a88

File tree

2 files changed

+80
-18
lines changed

2 files changed

+80
-18
lines changed

.circleci/config.yml

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,85 @@
1-
version: 2
2-
jobs:
3-
build:
1+
version: 2.1
2+
3+
deploy_filters: &deploy_filters
4+
filters:
5+
branches:
6+
ignore: /.*/
7+
tags:
8+
# Trigger on tags that begin with `v`
9+
only: /^v.*/
10+
11+
12+
executors:
13+
node:
414
docker:
5-
- image: circleci/node:lts
15+
- image: circleci/node:14
616

7-
steps:
8-
- checkout
917

18+
commands:
19+
save_yarn_cache:
20+
description: Save cache for future build
21+
steps:
22+
- save_cache:
23+
key: v1-yarn-deps-{{ checksum "yarn.lock" }}
24+
paths:
25+
- ~/.cache/yarn
26+
restore_yarn_cache:
27+
description: Restore cache from previous build
28+
steps:
1029
- restore_cache:
1130
keys:
12-
- v1-dependencies-{{ checksum "yarn.lock" }}
13-
- v1-dependencies-
31+
- v1-yarn-deps-{{ checksum "yarn.lock" }}
1432

15-
- run: yarn install --frozen-lock
33+
jobs:
34+
build:
35+
executor: node
36+
steps:
37+
- checkout
38+
- restore_yarn_cache
39+
- run:
40+
name: Install dependencies and build
41+
command: yarn install --frozen-lockfile
42+
- save_yarn_cache
43+
- run:
44+
name: Check License Headers
45+
command: yarn check-license-headers
46+
- run:
47+
name: Check formatting
48+
command: yarn format:check
49+
- run:
50+
name: Run linter
51+
command: yarn lint
52+
- run:
53+
name: Run unit tests
54+
command: yarn test
1655

17-
- save_cache:
18-
paths:
19-
- node_modules
20-
key: v1-dependencies-{{ checksum "yarn.lock" }}
56+
deploy:
57+
executor: node
58+
steps:
59+
- checkout
60+
- restore_yarn_cache
61+
- run:
62+
name: Install dependencies and build
63+
command: yarn install --frozen-lockfile
64+
- run:
65+
name: Configure NPM authentication
66+
command: npm config set "//registry.npmjs.org/:_authToken" "$NPM_AUTOMATION_TOKEN"
67+
- run:
68+
name: Publish package
69+
command: yarn release:publish
2170

22-
- run: yarn check-license-headers
23-
- run: yarn format:check
24-
- run: yarn lint
25-
- run: yarn test
71+
workflows:
72+
workflow:
73+
jobs:
74+
- build
75+
build_and_test:
76+
jobs:
77+
- build
78+
build_and_test_and_deploy:
79+
jobs:
80+
- build:
81+
<<: *deploy_filters
82+
- deploy:
83+
<<: *deploy_filters
84+
requires:
85+
- build

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"lint": "eslint src/ tests/",
2828
"format": "prettier --write '**/*.{js,json,md,html,css}'",
2929
"format:check": "prettier --check '**/*.{js,json,md,html,css}'",
30-
"release": "npm publish --access public",
30+
"release": "yarn release:publish",
31+
"release:version": "npm version",
32+
"release:publish": "npm publish --access public --registry=https://registry.npmjs.org",
3133
"test": "jest"
3234
},
3335
"dependencies": {

0 commit comments

Comments
 (0)