-
-
Notifications
You must be signed in to change notification settings - Fork 101
397 lines (386 loc) · 13.6 KB
/
build.yaml
File metadata and controls
397 lines (386 loc) · 13.6 KB
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: build
on: [push, pull_request_target]
jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: deno task cache
working-directory: ${{ github.workspace }}/fedify/
- run: deno task test --coverage=.cov --junit-path=.test-report.xml
env:
RUST_BACKTRACE: ${{ runner.debug }}
LOG: ${{ runner.debug && 'always' || '' }}
working-directory: ${{ github.workspace }}/fedify/
- uses: dorny/test-reporter@v2
if: success() || failure()
with:
name: "Test Results (${{ matrix.os }})"
path: fedify/.test-report.xml
reporter: jest-junit
continue-on-error: true
- if: '!cancelled()'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: fedify/.test-report.xml
- run: deno coverage --lcov .cov > .cov.lcov
working-directory: ${{ github.workspace }}/fedify/
continue-on-error: true
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: fedify/.cov.lcov
continue-on-error: true
- run: "true"
test-node:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: pnpm/action-setup@v4
with:
version: 10
- run: deno task test:node
working-directory: ${{ github.workspace }}/fedify/
test-bun:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- uses: pnpm/action-setup@v4
with:
version: 10
- run: deno task test:bun
working-directory: ${{ github.workspace }}/fedify/
lint:
runs-on: ubuntu-latest
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: deno task hooks:pre-commit
release-test:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: pnpm/action-setup@v4
with:
version: 10
- run: '[[ "$(jq -r .version deno.json)" = "$(jq -r .version package.json)" ]]'
working-directory: ${{ github.workspace }}/fedify/
- run: deno task publish --dry-run
working-directory: ${{ github.workspace }}/fedify/
- run: deno task npm
working-directory: ${{ github.workspace }}/fedify/
- run: npm publish --dry-run fedify-fedify-*.tgz
working-directory: ${{ github.workspace }}/fedify/
env:
DNT_SKIP_TEST: "true"
- run: deno task publish-dry-run
working-directory: ${{ github.workspace }}/cli/
publish:
needs: [test, test-node, test-bun, lint, release-test]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
outputs:
version: ${{ steps.versioning.outputs.version }}
short_version: ${{ steps.versioning.outputs.short_version }}
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: pnpm/action-setup@v4
with:
version: 10
- if: github.event_name == 'push' && github.ref_type == 'branch'
run: |
jq \
--arg build "$GITHUB_RUN_NUMBER" \
--arg commit "${GITHUB_SHA::8}" \
'.version = .version + "-dev." + $build + "+" + $commit' \
deno.json > deno.json.tmp
mv deno.json.tmp deno.json
working-directory: ${{ github.workspace }}/fedify/
- if: github.event_name == 'pull_request_target'
run: |
jq \
--arg pr_number "$PR_NUMBER" \
--arg build "$GITHUB_RUN_NUMBER" \
--arg commit "${PR_SHA::8}" \
'.version = .version + "-pr." + $pr_number + "." + $build + "+" + $commit' \
deno.json > deno.json.tmp
mv deno.json.tmp deno.json
working-directory: ${{ github.workspace }}/fedify/
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
- id: versioning
run: |
set -ex
echo version="$(jq -r .version deno.json)" >> $GITHUB_OUTPUT
echo short_version="$(jq -r .version deno.json | sed 's/[+].*//')" >> $GITHUB_OUTPUT
working-directory: ${{ github.workspace }}/fedify/
- run: deno task -r sync-version
- if: github.ref_type == 'tag'
run: |
set -ex
[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]
! grep -i "to be released" CHANGES.md
working-directory: ${{ github.workspace }}/fedify/
# Don't know why, but the .gitignore list is not overridden by include list
# in deno.json:
- run: rm vocab/.gitignore
working-directory: ${{ github.workspace }}/fedify/
- run: deno task npm
working-directory: ${{ github.workspace }}/fedify/
- run: deno task pack
working-directory: ${{ github.workspace }}/cli/
- run: 'deno task npm "$(jq -r .version deno.json)"'
working-directory: ${{ github.workspace }}/cli/
- id: extract-changelog
uses: dahlia/submark@5a5ff0a58382fb812616a5801402f5aef00f90ce
with:
input-file: CHANGES.md
heading-level: 2
heading-title-text: version ${{ github.ref_name }}
ignore-case: true
omit-heading: true
- run: 'cat "$CHANGES_FILE"'
env:
CHANGES_FILE: ${{ steps.extract-changelog.outputs.output-file }}
- uses: actions/upload-artifact@v4
with:
name: dist
path: |
fedify/fedify-fedify-*.tgz
cli/fedify-cli-*
- if: github.event_name == 'push' && github.ref_type == 'tag'
uses: softprops/action-gh-release@v1
with:
body_path: ${{ steps.extract-changelog.outputs.output-file }}
name: Fedify ${{ github.ref_name }}
files: |
fedify/fedify-fedify-*.tgz
cli/fedify-cli-*
generate_release_notes: false
- run: deno task publish --allow-dirty
working-directory: ${{ github.workspace }}/fedify/
- run: deno task publish --allow-dirty
working-directory: ${{ github.workspace }}/cli/
- run: |
set -ex
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
npm publish --provenance --access public fedify-fedify-*.tgz
elif [[ "$GITHUB_EVENT_NAME" = "pull_request_target" ]]; then
npm publish \
--provenance \
--access public \
--tag "pr-$PR_NUMBER" \
fedify-fedify-*.tgz
else
npm publish --provenance --access public --tag dev fedify-fedify-*.tgz
fi
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
working-directory: ${{ github.workspace }}/fedify/
- if: github.event_name == 'push' && github.ref_type == 'tag'
run: |
set -ex
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
npm publish --provenance --access public fedify-cli-*.tgz
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
working-directory: ${{ github.workspace }}/cli/
- if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v3
with:
message: |
The latest push to this pull request has been published to JSR and npm as a pre-release:
- [`jsr:@fedify/fedify@${{ steps.versioning.outputs.version }}`][1]
- [`jsr:@fedify/cli@${{ steps.versioning.outputs.version }}`][2]
- [`npm:@fedify/fedify@${{ steps.versioning.outputs.short_version }}`][3]
[1]: https://jsr.io/@fedify/fedify@${{ steps.versioning.outputs.version }}
[2]: https://jsr.io/@fedify/cli@${{ steps.versioning.outputs.version }}
[3]: https://www.npmjs.com/package/@fedify/fedify/v/${{ steps.versioning.outputs.short_version }}
pr-number: ${{ github.event.pull_request.number }}
publish-examples-blog:
if: github.event_name == 'push'
needs: [test, lint]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: deno task codegen
working-directory: ${{ github.workspace }}/fedify/
- uses: denoland/deployctl@v1
with:
project: fedify-blog
entrypoint: ./examples/blog/main.ts
root: .
publish-docs:
needs: [publish]
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
deployments: write
pull-requests: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- uses: pnpm/action-setup@v4
with:
version: 10
- run: |
set -ex
pnpm install
pnpm add -D "@fedify/fedify@$SHORT_VERSION"
if [[ "$GITHUB_EVENT_NAME" = "push" && "$GITHUB_REF_TYPE" = "tag" ]]; then
EXTRA_NAV_TEXT=Unstable \
EXTRA_NAV_LINK="$UNSTABLE_DOCS_URL" \
SITEMAP_HOSTNAME="$STABLE_DOCS_URL" \
JSR_REF_VERSION=stable \
pnpm run build
else
EXTRA_NAV_TEXT=Stable \
EXTRA_NAV_LINK="$STABLE_DOCS_URL" \
SITEMAP_HOSTNAME="$UNSTABLE_DOCS_URL" \
JSR_REF_VERSION=unstable \
pnpm run build
fi
env:
SHORT_VERSION: ${{ needs.publish.outputs.short_version }}
PLAUSIBLE_DOMAIN: ${{ secrets.PLAUSIBLE_DOMAIN }}
STABLE_DOCS_URL: ${{ vars.STABLE_DOCS_URL }}
UNSTABLE_DOCS_URL: ${{ vars.UNSTABLE_DOCS_URL }}
working-directory: ${{ github.workspace }}/docs/
- uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
- id: deployment
if: github.event_name == 'push' && github.ref_type == 'tag'
uses: actions/deploy-pages@v4
- if: github.event_name == 'pull_request_target' || github.ref_type == 'branch'
uses: nwtgck/actions-netlify@v3.0
with:
publish-dir: docs/.vitepress/dist
production-branch: main
production-deploy:
${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'true' || 'false' }}
github-token: ${{ github.token }}
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 2
# cSpell: ignore submark softprops npmjs deployctl nwtgck thollander elif