Repository navigation
45 lines (42 loc) · 1.56 KB
/
Copy pathrelease.yml
File metadata and controls
45 lines (42 loc) · 1.56 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
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write # create the GitHub Release
id-token: write # npm provenance
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
cache: npm
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm test
- name: Verify tag matches package version
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
[ "${GITHUB_REF_NAME}" = "v${PKG_VERSION}" ] || { echo "Tag ${GITHUB_REF_NAME} != package version v${PKG_VERSION}"; exit 1; }
- name: Verify CHANGELOG.md has an entry for this version
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
node scripts/extract-changelog.mjs "${PKG_VERSION}" > /dev/null
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
node scripts/extract-changelog.mjs "${PKG_VERSION}" > /tmp/release-notes.md
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--notes-file /tmp/release-notes.md