-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 2.19 KB
/
Copy pathpublish.yml
File metadata and controls
65 lines (55 loc) · 2.19 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
name: Publish to npm
# Publishes the package to npm with an npm provenance statement.
# Provenance (a Sigstore build attestation) is required for n8n Cloud
# verification and can only be generated from a CI job with OIDC, so all
# releases must go through this workflow rather than a local `npm publish`.
#
# Trigger: push a version tag, e.g.
# git tag v1.3.2 && git push origin v1.3.2
# The tag must match the `version` in package.json.
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: read
id-token: write # required for npm provenance (Sigstore OIDC)
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Verify publish runs from a matching tag
# Publishes only from a tag ref whose name equals v<package.json version>,
# so every provenance-backed release is tied to a tagged commit. The
# ref-type check is load-bearing: workflow_dispatch can run from a branch,
# and without it a branch named like the version (e.g. v1.3.5) would pass
# the name check and publish untagged.
run: |
if [ "$GITHUB_REF_TYPE" != "tag" ]; then
echo "::error::Publish must run from a tag ref, got $GITHUB_REF_TYPE $GITHUB_REF_NAME"
exit 1
fi
PKG_VERSION="v$(node -p "require('./package.json').version")"
if [ "$PKG_VERSION" != "$GITHUB_REF_NAME" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG_VERSION"
exit 1
fi
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Verify icon assets are bundled
run: |
test -f dist/nodes/Hedy/hedy.png || { echo "::error::dist/nodes/Hedy/hedy.png is missing — the build did not bundle the node icon"; exit 1; }
- name: Publish to npm with provenance
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}