This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.drone.yml
151 lines (149 loc) · 3.99 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: TSProjectGenerator
kind: pipeline
type: docker
steps:
- name: install
image: node
commands:
- npm install --unsafe-perm
- name: build
image: node
depends_on:
- install
commands:
- npm run build
- name: lint
image: node
depends_on:
- install
commands:
- npm run lint
- name: test
image: node
depends_on:
- build
commands:
- npm run test
- name: prepare release
image: node
depends_on:
- lint
- test
commands:
- npm install @stdlib/utils-escape-regexp-string --no-save
- node -e "console.log(require('@stdlib/utils-escape-regexp-string')('${DRONE_TAG}'))" > .tagName.txt
- export TagName=$$(cat .tagName.txt)
- echo "/^## \(.* \($${TagName}\|\[$${TagName}\]\)\)\$/" > .tagHeading.txt
when:
event:
- tag
- name: check release prerequisites
image: node
depends_on:
- prepare release
environment:
NPM_TOKEN:
from_secret: npm_token
GITHUB_PACKAGE_TOKEN:
from_secret: github_packages_token
GITHUB_PUBLISH_TOKEN:
from_secret: github_publish_token
commands:
- npm i --no-save @octokit/rest
- >
testNPM() {
echo "//registry.npmjs.org/:_authToken=$1" > ~/.npmrc
npm whoami > /dev/null 2>&1
}
- >
testGitHub() {
node -e 'new (require("@octokit/rest").Octokit)({ auth: "'"$1"'" }).request("GET /user").catch(() => process.exit(1))' > /dev/null 2>&1
}
- export TagHeading=$$(cat .tagHeading.txt)
- '[ ! -z "$$(sed "$${TagHeading}p;d" CHANGELOG.md)" ] || { echo "No Changelog Entries Found!" && false; }'
- testNPM $NPM_TOKEN || { echo "The NPM Access Token is invalid!" && false; }
- testGitHub $GITHUB_PACKAGE_TOKEN || { echo "The GitHub Package Token is invalid!" && false; }
- testGitHub $GITHUB_PUBLISH_TOKEN || { echo "The GitHub Publish Token is invalid!" && false; }
when:
event:
- tag
- name: create package
image: node
depends_on:
- check release prerequisites
commands:
- npm pack --workspaces
when:
event:
- tag
- name: prepare release notes
image: alpine
depends_on:
- check release prerequisites
commands:
- export TagName=$$(cat .tagName.txt)
- export TagHeading=$$(cat .tagHeading.txt)
- export HeadingPattern='/## \(.* \(v[0-9.]*\|\[.*\]\)\)/'
- cp -f CHANGELOG.md .releaseNotes.md
- sed -i "1,$${TagHeading}{ $${TagHeading}P ; d } ; $${HeadingPattern},\$d" .releaseNotes.md
- cp -f .releaseNotes.md .releaseTitle.md
- sed -i "2,\$d ; s$${HeadingPattern}\\\\1/" .releaseTitle.md
when:
event:
- tag
- name: publish package to npm
image: node
depends_on:
- create package
environment:
NPM_TOKEN:
from_secret: npm_token
commands:
- echo "//registry.npmjs.org/:_authToken=$${NPM_TOKEN}" > ~/.npmrc
- npm publish --workspaces
when:
event:
- tag
ref:
- refs/tags/v[0-9]*.[0-9]*.[0-9]*
- name: publish package to github
image: node
depends_on:
- publish package to npm
environment:
GITHUB_TOKEN:
from_secret: github_packages_token
commands:
- echo "//npm.pkg.github.com/:_authToken=$${GITHUB_TOKEN}" > ~/.npmrc
- echo "registry=https://npm.pkg.github.com" >> ~/.npmrc
- npm publish --workspaces
when:
event:
- tag
ref:
- refs/tags/v[0-9]*.[0-9]*.[0-9]*
- name: publish release
image: plugins/github-release
depends_on:
- create package
- prepare release notes
commands: []
settings:
api_key:
from_secret: github_publish_token
files:
- "*.tgz"
title: .releaseTitle.md
note: .releaseNotes.md
when:
event:
- tag
trigger:
ref:
- refs/heads/**
- refs/pull/**
- refs/tags/**
event:
- push
- pull_request
- tag