-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (60 loc) · 2.01 KB
/
Copy pathpublish.yml
File metadata and controls
71 lines (60 loc) · 2.01 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: Publish to npm
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to publish. Must match package.json."
required: true
default: "2.0.1"
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
registry-url: https://registry.npmjs.org
- name: Verify tag matches package.json version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG_VERSION="${{ inputs.version }}"
else
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
fi
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "${TAG_VERSION}" != "${PKG_VERSION}" ]; then
echo "Requested version ${TAG_VERSION} does not match package.json version ${PKG_VERSION}"
exit 1
fi
- name: Install dependencies
run: npm ci
- name: Run release preflight
run: npm run release:preflight
- name: Preview package contents
run: npm pack --dry-run
- name: Verify npm publish authentication
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [ -z "${NODE_AUTH_TOKEN:-}" ]; then
echo "::error::NPM_TOKEN is not configured or is not available to this repository. Grant the same npm publish secret used by schema-dsl to vextjs/monSQLize, or configure npm trusted publishing and adjust this workflow."
exit 2
fi
npm whoami --registry=https://registry.npmjs.org/
- name: Publish to npm
run: npm publish --provenance --access public --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}