Repository navigation
59 lines (53 loc) · 2.12 KB
/
Copy pathrelease.yml
File metadata and controls
59 lines (53 loc) · 2.12 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
name: Release
# Publishes the five workspace packages (packages/* and plugins/*) to npm
# when a tag matching v* is pushed. The tag must equal every package.json
# version, so a release is one commit that bumps all five together.
on:
push:
tags: ['v*']
permissions:
id-token: write # npm provenance
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The version comes from package.json's packageManager field; naming
# one here too makes the action refuse to run when they differ.
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
# Writes the .npmrc that maps NODE_AUTH_TOKEN to the registry.
registry-url: https://registry.npmjs.org
- run: pnpm install --frozen-lockfile
- run: pnpm fixtures # download the pinned CommonMark spec
- run: pnpm test
- run: pnpm typecheck
- run: pnpm build
- name: Tag version must match every package.json
run: |
node - "$GITHUB_REF_NAME" <<'JS'
const { readFileSync } = require('node:fs')
const tag = process.argv[2].replace(/^v/, '')
const files = [
'packages/renderer', 'packages/editor',
'plugins/variables', 'plugins/mermaid', 'plugins/slides',
].map((dir) => `${dir}/package.json`)
const mismatched = files
.map((file) => ({ file, version: JSON.parse(readFileSync(file, 'utf8')).version }))
.filter(({ version }) => version !== tag)
if (mismatched.length) {
for (const { file, version } of mismatched) {
console.error(`${file}: version ${version} does not match tag ${tag}`)
}
process.exit(1)
}
console.log(`All ${files.length} packages are at ${tag}`)
JS
- name: Publish to npm with provenance
run: pnpm -r --filter './packages/*' --filter './plugins/*' publish --access public --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}