Skip to content

Commit 1d4265c

Browse files
authored
chore: integrate NPM publish with CircleCI (#130)
Also run docker as non-root user.
1 parent 9fd094b commit 1d4265c

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

.circleci/config.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
2+
release_tags: &release_tags
3+
tags:
4+
only: /^v\d+(\.\d+){2}(-.*)?$/
5+
26
# "Include" for unit tests definition.
37
unit_tests: &unit_tests
48
steps:
59
- checkout
6-
- run:
7-
name: Configure npm to allow running scripts as root.
8-
command: npm config set unsafe-perm true
910
- run:
1011
name: Install modules and dependencies.
1112
command: npm install
@@ -22,10 +23,14 @@ workflows:
2223
version: 2
2324
tests:
2425
jobs:
25-
- node4
26-
- node6
27-
- node8
28-
- node9
26+
- node4:
27+
filters: *release_tags
28+
- node6:
29+
filters: *release_tags
30+
- node8:
31+
filters: *release_tags
32+
- node9:
33+
filters: *release_tags
2934
- publish_npm:
3035
requires:
3136
- node4
@@ -35,35 +40,42 @@ workflows:
3540
filters:
3641
branches:
3742
ignore: /.*/
38-
tags:
39-
only: /^v[\d.]+$/
43+
<<: *release_tags
4044

4145
jobs:
4246
node4:
4347
docker:
4448
- image: node:4
49+
user: node
4550
<<: *unit_tests
4651
node6:
4752
docker:
4853
- image: node:6
54+
user: node
4955
<<: *unit_tests
5056
node8:
5157
docker:
5258
- image: node:8
59+
user: node
5360
<<: *unit_tests
5461
node9:
5562
docker:
5663
- image: node:9
64+
user: node
5765
<<: *unit_tests
5866

5967
publish_npm:
6068
docker:
6169
- image: node:8
70+
user: node
6271
steps:
6372
- checkout
6473
- run:
6574
name: Set NPM authentication.
6675
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
6776
- run:
68-
name: Publish the module to npm.
69-
command: npm publish
77+
name: Install modules and dependencies.
78+
command: npm install
79+
- run:
80+
name: Publish the module to npm.
81+
command: npm publish

0 commit comments

Comments
 (0)