-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (42 loc) · 1.37 KB
/
Copy pathrelease.yml
File metadata and controls
49 lines (42 loc) · 1.37 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
name: Publish to npm
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Release tag to publish (for example, v0.2.2)
required: true
default: v0.2.2
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 20
registry-url: https://registry.npmjs.org
cache: npm
- name: Verify tag matches package.json version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG_VERSION="${{ inputs.tag }}"
TAG_VERSION="${TAG_VERSION#v}"
fi
PKG_VERSION="$(node -p "require('./package.json').version")"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Release tag v$TAG_VERSION does not match package.json version $PKG_VERSION"
exit 1
fi
- run: npm ci
- name: Publish (beta)
if: github.event.release.prerelease == true
run: npm publish --tag beta --access public
- name: Publish (stable)
if: github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false
run: npm publish --tag latest --access public