-
-
Notifications
You must be signed in to change notification settings - Fork 9
290 lines (254 loc) · 11.6 KB
/
deploy.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Tag, Release, & Publish
on:
push:
branches:
- master
jobs:
build:
name: 'Release'
runs-on: ubuntu-latest
steps:
# Checkout updated source code
- uses: actions/checkout@v2
name: Checkout Code
- uses: actions/setup-node@v1
name: Setup Node.js
with:
node-version: '16'
- uses: actions/cache@v2
name: Establish Docker Cache
id: cache
with:
path: docker-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Load cached Docker layers
run: |
if [ -d "docker-cache" ]; then
cat docker-cache/x* > my-image.tar
docker load < my-image.tar
rm -rf docker-cache
fi
- name: Setup Build Tooling
id: setup
run: |
base=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-base/tags?page_size=1'|jq '."results"[]["name"]')
base=$(sed -e 's/^"//' -e 's/"$//' <<<"$base")
echo Retrieving author/dev/dev-base:$base
docker pull author/dev-base:$base
deno=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-deno/tags?page_size=1'|jq '."results"[]["name"]')
deno=$(sed -e 's/^"//' -e 's/"$//' <<<"$deno")
echo Retrieving author/dev/dev-deno:$deno
docker pull author/dev-deno:$deno
browser=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-browser/tags?page_size=1'|jq '."results"[]["name"]')
browser=$(sed -e 's/^"//' -e 's/"$//' <<<"$browser")
echo Retrieving author/dev/dev-browser:$browser
docker pull author/dev-browser:$browser
node=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-node/tags?page_size=1'|jq '."results"[]["name"]')
node=$(sed -e 's/^"//' -e 's/"$//' <<<"$node")
echo Retrieving author/dev/dev-node:$node
docker pull author/dev-node:$node
# node -e "const p=new Set(Object.keys(require('./package.json').peerDependencies));p.delete('@author.io/dev');console.log('npm i ' + Array.from(p).join(' '))"
version=$(npm show @author.io/dev version)
echo $version
npm i -g @author.io/dev@$version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test
if: success()
run: |
npm i
dev -v
npm run ci
- name: Tag
id: autotagger
if: success()
uses: butlerlogic/action-autotag@stable
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create
# an environment variable indicating it is a prerelease.
- name: Pre-release
if: steps.autotagger.outputs.tagname != ''
run: |
if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi
- name: Release
id: create_release
if: steps.autotagger.outputs.tagname != ''
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
release_name: ${{ steps.autotagger.outputs.tagname }}
body: ${{ steps.autotagger.outputs.tagmessage }}
draft: false
prerelease: env.IS_PRERELEASE != ''
# Build tarballs of the module code.
- name: Build Release Artifacts
id: build_release
if: steps.create_release.outputs.id != ''
run: |
ln -s /node_modules ./node_modules
dev build --pack --mode ci --peer
cp -rf .dist ./dist
# Upload tarballs to the release.
- name: Upload Release Artifacts
uses: AButler/[email protected]
if: steps.create_release.outputs.id != ''
with:
files: '.dist/*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.autotagger.outputs.tagname }}
- name: Publish to npm
id: publish_npm
if: steps.autotagger.outputs.tagname != ''
uses: author/action-publish@stable
with:
scan: ./dist
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
- name: Rollback Release
if: failure() && steps.create_release.outputs.id != ''
uses: author/action-rollback@stable
with:
tag: ${{ steps.autotagger.outputs.tagname }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Failure Notification
if: failure() && steps.create_release.outputs.id != ''
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: Github # Optional. (defaults to webhook app)
SLACK_CHANNEL: author # Optional. (defaults to webhook)
SLACK_AVATAR: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/Npm-logo.svg/320px-Npm-logo.svg.png"
uses: Ilshidur/action-slack@master
with:
args: '@author.io/shell ${{ steps.autotagger.outputs.tagname }} failed to publish and was rolled back.' # Optional
- name: Success Notification
if: success() && steps.autotagger.outputs.tagname != ''
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: Github # Optional. (defaults to webhook app)
SLACK_CHANNEL: author # Optional. (defaults to webhook)
SLACK_AVATAR: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/Npm-logo.svg/320px-Npm-logo.svg.png"
uses: Ilshidur/action-slack@master
with:
args: '@author.io/shell ${{ steps.autotagger.outputs.tagname }} published to npm.' # Optional
- name: Inaction Notification
if: steps.autotagger.outputs.tagname == ''
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: Github # Optional. (defaults to webhook app)
SLACK_CHANNEL: author # Optional. (defaults to webhook)
SLACK_AVATAR: "https://cdn.freebiesupply.com/logos/large/2x/nodejs-icon-logo-png-transparent.png" # Optional. can be (repository, sender, an URL) (defaults to webhook app avatar)
uses: Ilshidur/action-slack@master
with:
args: "New code was added to author/shell master branch." # Optional
# # If the version has changed, create a new git tag for it.
# - name: Tag
# id: autotagger
# uses: butlerlogic/action-autotag@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # The remaining steps all depend on whether or not
# # a new tag was created. There is no need to release/publish
# # updates until the code base is in a releaseable state.
# # If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create
# # an environment variable indicating it is a prerelease.
# - name: Pre-release
# if: steps.autotagger.outputs.tagname != ''
# run: |
# if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi
# # Create a github release
# # This will create a snapshot of the module,
# # available in the "Releases" section on Github.
# - name: Release
# id: create_release
# if: steps.autotagger.outputs.tagname != ''
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ steps.autotagger.outputs.tagname }}
# release_name: ${{ steps.autotagger.outputs.tagname }}
# body: ${{ steps.autotagger.outputs.tagmessage }}
# draft: false
# prerelease: env.IS_PRERELEASE != ''
# - uses: actions/setup-node@v1
# if: steps.create_release.outputs.id != ''
# with:
# node-version: '13'
# # Build tarballs of the module code.
# - name: Build Release Artifacts
# id: build_release
# if: steps.create_release.outputs.id != ''
# run: |
# npm install
# cd ./build && npm install && cd ../
# npm run build --if-present
# for d in .dist/*/*/ ; do tar -cvzf ${d%%/}-${{ steps.autotagger.outputs.version }}.tar.gz ${d%%}*; done;
# if [[ ${{ github.ref }} == *"-"* ]]; then echo ::set-output isprerelease=true;else echo ::set-output isprerelease=false;fi
# # Upload tarballs to the release.
# - name: Upload Release Artifacts
# uses: AButler/[email protected]
# if: steps.create_release.outputs.id != ''
# with:
# files: './.dist/**/*.tar.gz'
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# release-tag: ${{ steps.autotagger.outputs.tagname }}
# # Build npm packages
# - name: Build Module Artifacts
# id: build_npm
# if: steps.create_release.outputs.id != ''
# run: |
# npm install
# cd ./build && npm install && cd ../
# npm run build --if-present
# # Use this action to publish a single module to npm.
# - name: Publish
# id: publish_npm
# if: steps.autotagger.outputs.tagname != ''
# uses: author/action-publish@master
# with:
# scan: .dist
# env:
# REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
# - name: Rollback Release
# if: failure() && steps.create_release.outputs.id != ''
# uses: author/action-rollback@stable
# with:
# tag: ${{ steps.autotagger.outputs.tagname }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Failure Notification
# if: failure() && steps.create_release.outputs.id != ''
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_USERNAME: Github # Optional. (defaults to webhook app)
# SLACK_CHANNEL: author # Optional. (defaults to webhook)
# SLACK_AVATAR: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/Npm-logo.svg/320px-Npm-logo.svg.png"
# uses: Ilshidur/action-slack@master
# with:
# args: '@author.io/shell ${{ steps.autotagger.outputs.tagname }} failed to publish and was rolled back.' # Optional
# - name: Success Notification
# if: success() && steps.autotagger.outputs.tagname != ''
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_USERNAME: Github # Optional. (defaults to webhook app)
# SLACK_CHANNEL: author # Optional. (defaults to webhook)
# SLACK_AVATAR: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/Npm-logo.svg/320px-Npm-logo.svg.png"
# uses: Ilshidur/action-slack@master
# with:
# args: '@author.io/shell ${{ steps.autotagger.outputs.tagname }} published to npm.' # Optional
# - name: Inaction Notification
# if: steps.autotagger.outputs.tagname == ''
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_USERNAME: Github # Optional. (defaults to webhook app)
# SLACK_CHANNEL: author # Optional. (defaults to webhook)
# SLACK_AVATAR: "https://cdn.freebiesupply.com/logos/large/2x/nodejs-icon-logo-png-transparent.png" # Optional. can be (repository, sender, an URL) (defaults to webhook app avatar)
# uses: Ilshidur/action-slack@master
# with:
# args: "New code was added to author/shell master branch." # Optional