Repository navigation
71 lines (59 loc) · 2.03 KB
/
Copy pathrelease.yml
File metadata and controls
71 lines (59 loc) · 2.03 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm
# The tag is the release, and `pend-analytics --version` reads package.json.
# If those disagree, everyone who pinned the tag gets a build that
# misreports its own version, so fail before the release exists.
- name: Check the tag matches package.json
run: |
tag="${GITHUB_REF_NAME#v}"
pkg="$(node -p "require('./package.json').version")"
if [ "$tag" != "$pkg" ]; then
echo "::error::tag v$tag does not match package.json version $pkg"
exit 1
fi
echo "tag v$tag matches package.json"
# A tag can be placed on any commit, not only one CI has seen, so the full
# gate runs again here rather than trusting the branch.
- run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Build
run: npm run build
# Consumers install from a git tag, so the packed tarball is what they
# actually get. This fails if `files` omits something the package needs.
- name: Check the package contents
run: npm pack --dry-run
# Body comes from docs/releases/vX.Y.Z.md so every tag uses the same
# headed format. --generate-notes is not a fallback.
- name: Publish the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
notes="docs/releases/${GITHUB_REF_NAME}.md"
if [ ! -f "$notes" ]; then
echo "::error::missing $notes - write it from docs/releasing.md"
exit 1
fi
gh release create "$GITHUB_REF_NAME" \
--title "$GITHUB_REF_NAME" \
--notes-file "$notes" \
--verify-tag