Repository navigation
79 lines (73 loc) · 2.63 KB
/
Copy pathpublish.yml
File metadata and controls
79 lines (73 loc) · 2.63 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
name: Stage release
on:
push:
tags: ["v*"]
permissions:
contents: read
jobs:
stage:
runs-on: ubuntu-latest
permissions:
contents: read
# Lets npm exchange a GitHub OIDC token for a short-lived token that can
# only stage a version. Approving it on npm still requires 2FA.
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Use Node.js 24.x
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
# Staged publishing needs npm >= 11.15.0
node-version: 24.x
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Check tag, version, branch and changelog
run: |
VERSION="$(node -p "require('./package.json').version")"
if [ "v$VERSION" != "$GITHUB_REF_NAME" ]; then
echo "Tag $GITHUB_REF_NAME does not match package.json version $VERSION"
exit 1
fi
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/master; then
echo "Tagged commit $GITHUB_SHA is not on master"
exit 1
fi
node .github/scripts/changelog-entry.js > /dev/null
- name: Write review summary
run: |
PREVIOUS="$(git describe --tags --abbrev=0 --match 'v*' "$GITHUB_SHA^")"
{
echo "### Review before approving on npm"
echo
echo "Compare the commit in this run's header with the one below. Then review every changed file:"
echo
echo "https://github.com/$GITHUB_REPOSITORY/compare/$PREVIOUS...$GITHUB_SHA"
} >> "$GITHUB_STEP_SUMMARY"
# This job can stage on npm, so don't run install scripts of dependencies.
- run: npm ci --ignore-scripts
# Runs prepublishOnly: clean, lint, tsc and unit tests
- run: npm test
- run: npm stage publish
draft-release:
needs: stage
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Create draft GitHub release from changelog
env:
GH_TOKEN: ${{ github.token }}
run: |
node .github/scripts/changelog-entry.js > notes.md
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--draft \
--verify-tag \
--title "${GITHUB_REF_NAME#v}" \
--notes-file notes.md