This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
122 lines (109 loc) · 3.35 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
kind: pipeline
type: kubernetes
name: default
# Common step to inject the Docker image for the required Node version.
# Override by setting `builder_node_version` in `.globality/build.json`.
image: &image
image: node:18.20.3
steps:
# Add JFrog credentials to `.npmrc` so that:
# - we can access other private dependencies stored there
# - we can publish the package (modules shouldn't be publicly shared on NPM)
- name: authenticate-jfrog
<<: *image
environment:
ARTIFACTORY_USERNAME:
from_secret: ARTIFACTORY_USERNAME
ARTIFACTORY_PASSWORD:
from_secret: ARTIFACTORY_PASSWORD
commands:
- curl -u$ARTIFACTORY_USERNAME:$ARTIFACTORY_PASSWORD https://globality.jfrog.io/globality/api/npm/auth > .npmrc
- echo "registry=https://globality.jfrog.io/globality/api/npm/npm" >> .npmrc
# Install dependencies (first and third party) from NPM and JFrog
- name: install-node-dependencies
<<: *image
commands:
- yarn install
depends_on:
- authenticate-jfrog
# Next three steps run in parallel
# ↓
# ┌─────────┼──────────┐
# ╔══╧═══╗ ╔══╧═══╗ ╔═══╧═══╗
# ║ lint ║ ║ test ║ ║ build ║
# ╚══╤═══╝ ╚══╤═══╝ ╚═══╤═══╝
# └─────────┼──────────┘
# ↓
- name: lint
<<: *image
commands:
- yarn lint
depends_on:
- install-node-dependencies
- name: test
<<: *image
commands:
- yarn test
depends_on:
- install-node-dependencies
- name: build
<<: *image
commands:
- yarn build
depends_on:
- install-node-dependencies
# We now have a choice:
# - (normally) publish a `dev` build with the build number in the version
# - we can optionally publish a `latest` (release) build from a git tag
# ↓
# ┏━━━━┹─────┐
# ╔══╧══╗ ╔════╧════╗
# ║ dev ║ ║ release ║
# ╚═════╝ ╚═════════╝
- name: publish-repository-dev
<<: *image
when:
event:
exclude:
- tag
commands:
- npm config fix
# Mangle the `version` in `package.json` to append `-dev.nnn` where `nnn`
# is the build number.
- sed -i "/version/s/\",/-dev.${DRONE_BUILD_NUMBER}\",/" package.json
# Development builds are published with the `dev` tag.
# https://docs.npmjs.com/cli/v7/commands/npm-dist-tag
- npm publish --tag dev
depends_on:
- lint
- test
- build
- name: publish-repository-release
<<: *image
when:
event:
- tag
commands:
- npm config fix
# Releases are published with the `latest` tag.
# https://docs.npmjs.com/cli/v7/commands/npm-dist-tag
# > By default, the `latest` tag is used by npm to identify the current
# > version of a package.
- npm publish --tag latest
depends_on:
- lint
- test
- build
---
kind: secret
name: ARTIFACTORY_USERNAME
get:
path: secrets/dev/drone
name: DRONE_ARTIFACTORY_USERNAME
---
kind: secret
name: ARTIFACTORY_PASSWORD
get:
path: secrets/dev/drone
name: DRONE_ARTIFACTORY_PASSWORD