-
Notifications
You must be signed in to change notification settings - Fork 24
62 lines (52 loc) · 1.75 KB
/
Copy pathpublish-npm.yml
File metadata and controls
62 lines (52 loc) · 1.75 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
name: Publish npm Package
on:
push:
tags:
- "*.*.*"
permissions:
contents: read
id-token: write
jobs:
publish:
if: ${{ !startsWith(github.ref_name, 'plugin-') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- name: Install dependencies
run: npm ci
- name: Verify tag matches package version
shell: bash
run: |
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
if [ "${PACKAGE_VERSION}" != "${GITHUB_REF_NAME}" ]; then
echo "Tag ${GITHUB_REF_NAME} does not match package.json version ${PACKAGE_VERSION}"
exit 1
fi
- name: Smoke test release package
run: npm run release:smoke
- name: Verify package contents
run: npm run release:check
- name: Check whether version already exists on npm
id: npm_version
shell: bash
run: |
PACKAGE_NAME="$(node -p "require('./package.json').name")"
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
echo "published=true" >> "$GITHUB_OUTPUT"
echo "Version ${PACKAGE_VERSION} is already published. Skipping npm publish."
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish package to npm
if: steps.npm_version.outputs.published != 'true'
run: npm publish --access public