-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (126 loc) · 4.18 KB
/
Copy pathpublish-npm.yml
File metadata and controls
147 lines (126 loc) · 4.18 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: publish npm
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
publishToNPM:
description: "Publish to npm?"
required: true
default: "no"
permissions:
contents: write
id-token: write
jobs:
build-bindings:
runs-on: ${{ matrix.host }}
strategy:
fail-fast: false
matrix:
include:
- host: windows-latest
target: x86_64-pc-windows-msvc
build: npm run build -- --target x86_64-pc-windows-msvc
- host: windows-latest
target: aarch64-pc-windows-msvc
build: npm run build -- --target aarch64-pc-windows-msvc
- host: macos-latest
target: x86_64-apple-darwin
build: npm run build -- --target x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
build: npm run build -- --target aarch64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: npm run build -- --target x86_64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: npm run build -- --target aarch64-unknown-linux-gnu --use-napi-cross
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: "24"
cache: "npm"
cache-dependency-path: node/package-lock.json
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Node dependencies
working-directory: node
run: npm ci
- name: Build native binding
working-directory: node
run: ${{ matrix.build }}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-${{ matrix.target }}
path: node/geddes.*.node
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: build-bindings
if: github.event_name == 'push' || inputs.publishToNPM == 'yes'
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: "24"
cache: "npm"
cache-dependency-path: node/package-lock.json
registry-url: "https://registry.npmjs.org"
- name: Upgrade npm for trusted publishing
run: npm install -g npm@^11.10.0
- name: Install Node dependencies
working-directory: node
run: npm ci
- name: Sync Node package version from Cargo.toml
working-directory: node
run: npm run sync:version
- name: Determine npm dist-tag
id: dist_tag
working-directory: node
run: |
VERSION="$(node -p "require('./package.json').version")"
if [[ "$VERSION" == *-* ]]; then
TAG="next"
else
TAG="latest"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Using npm dist-tag '$TAG' for version '$VERSION'"
- name: Create npm target directories
working-directory: node
run: npx napi create-npm-dirs
- name: Download all native artifacts
uses: actions/download-artifact@v8
with:
pattern: bindings-*
path: node/artifacts
merge-multiple: true
- name: Move artifacts into npm package dirs
working-directory: node
run: npx napi artifacts --output-dir artifacts
- name: Dry-run prepublish
working-directory: node
run: npx napi prepublish -t npm --dry-run
- name: Prepublish native packages
working-directory: node
run: npx napi prepublish -t npm
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
NPM_CONFIG_TAG: ${{ steps.dist_tag.outputs.tag }}
- name: Publish JS package
working-directory: node
run: npm publish --ignore-scripts --provenance --access public --tag "${{ steps.dist_tag.outputs.tag }}"