-
Notifications
You must be signed in to change notification settings - Fork 10
/
.drone.yml
154 lines (152 loc) · 4.3 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
152
153
154
name: MarkdownConverter
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-debug
- name: lint
image: node
depends_on:
- install
commands:
- npm run lint
- name: test
image: manuth/vscode-test-runner
depends_on:
- build
commands:
- xvfb-run 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:
VSCE_TOKEN:
from_secret: vsce_token
OVSX_TOKEN:
from_secret: ovsx_token
GITHUB_PUBLISH_TOKEN:
from_secret: github_publish_token
commands:
- npm i --no-save @octokit/rest
- export PUBLISHER=$$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json').toString()).publisher)")
- >
testOVSX() {
url='https://open-vsx.org/api/-/namespace/create?token='"$1"
output=$(curl -X POST $url --header 'Content-Type: application/json' --data-raw '{ "name": "'"$PUBLISHER"'" }')
node -e 'JSON.parse('"'$output'"').error.includes("Invalid access token") && process.exit(1);'
}
- >
testVSCE() {
npx vsce verify-pat $PUBLISHER --pat $1 > /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; }'
- testOVSX $OVSX_TOKEN || { echo "The Open VSX Token is invalid!" && false; }
- testVSCE $VSCE_TOKEN || { echo "The Visual Studio Marketplace Token is invalid!" && false; }
- testGitHub $GITHUB_PUBLISH_TOKEN || { echo "The GitHub Publish Token is invalid!" && false; }
when:
event:
- tag
- name: create extension
image: node
depends_on:
- check release prerequisites
commands:
- npm run package
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 extension to ovsx marketplace
image: node
depends_on:
- create extension
environment:
OVSX_TOKEN:
from_secret: ovsx_token
commands:
- npm run ovsx -- publish --pat $OVSX_TOKEN
when:
event:
- tag
ref:
- refs/tags/v[0-9]*.[0-9]*.[0-9]*
- name: publish extension to vscode marketplace
image: node
depends_on:
- publish extension to ovsx marketplace
environment:
VSCE_TOKEN:
from_secret: vsce_token
commands:
- npm run vsce -- publish --pat $VSCE_TOKEN
when:
event:
- tag
ref:
- refs/tags/v[0-9]*.[0-9]*.[0-9]*
- name: publish release
image: plugins/github-release
depends_on:
- create extension
- prepare release notes
commands: []
settings:
api_key:
from_secret: github_publish_token
files:
- "*.vsix"
title: .releaseTitle.md
note: .releaseNotes.md
when:
event:
- tag
trigger:
ref:
- refs/heads/**
- refs/pull/**
- refs/tags/**
event:
- push
- pull_request
- tag