-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.drone.yml
97 lines (85 loc) · 2.05 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
kind: pipeline
type: kubernetes
name: default
service_account_name: drone-log-vendor-npm-dynamodb-lock
node_selector:
app: drone
environment:
AWS_REGION: eu-west-1
image_pull_secrets:
- DOCKERCONFIG
services:
- name: dynamodb
image: amazon/dynamodb-local
node_js: &node_js
image: node:16.13.0
volumes:
- name: cache
path: /root/.cache
environment:
GITHUB_PKG_TOKEN:
from_secret: GITHUB_PACKAGES_TOKEN
NPM_PKG_TOKEN:
from_secret: NPM_PACKAGES_TOKEN
when:
event:
- push
- pull_request
- tag
steps:
- name: install
<<: *node_js
commands:
- sed 's/$${GITHUB_PKG_TOKEN}/'$$GITHUB_PKG_TOKEN'/g' .npmrc.github > .npmrc || exit 1
- yarn install || exit 1
- name: prepare
<<: *node_js
commands:
- yarn prepare || exit 1
depends_on:
- "install"
- name: test-lint
<<: *node_js
commands:
- yarn lint || exit 1
depends_on:
- "prepare"
- name: test-unit
<<: *node_js
commands:
- yarn test:unit || exit 1
depends_on:
- "prepare"
- name: test-e2e
<<: *node_js
commands:
- yarn test:e2e || exit 1
depends_on:
- "prepare"
- name: publish
<<: *node_js
commands:
- apt update
- DEBIAN_FRONTEND=noninteractive apt-get -yq install jq
- PACKAGE_VERSION=$(jq .version package.json -r)
- |
if [ $DRONE_TAG = v$PACKAGE_VERSION ]
then
echo "Pushed tag matches package version, publishing package to Github Packages"
sed 's/$${GITHUB_PKG_TOKEN}/'$$GITHUB_PKG_TOKEN'/g' .npmrc.github > .npmrc
npm publish || exit 1
echo "Publishing package to NPM"
sed 's/$${NPM_PKG_TOKEN}/'$$NPM_PKG_TOKEN'/g' .npmrc.npm > .npmrc
npm publish --access public || exit 1
else
echo "Pushed tag does not match package version, will not publish package"
fi
when:
event:
- tag
ref:
- refs/tags/v*
depends_on:
- "test-lint"
- "test-unit"
- "test-e2e"