-
Notifications
You must be signed in to change notification settings - Fork 241
82 lines (72 loc) · 2.87 KB
/
init-npm-packages.yml
File metadata and controls
82 lines (72 loc) · 2.87 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
name: Initialize NPM Platform Packages
# Creates placeholder packages on npm for any new napi platform targets.
# npm requires packages to exist before OIDC/provenance publishing can work,
# so this must be run once per new target before the first release that includes it.
#
# After running, configure Trusted Publishing on npmjs.com for each new package:
# Package Settings > Trusted Publisher > GitHub Actions > pydantic/monty
on:
workflow_dispatch: {}
jobs:
init-packages:
name: Initialize missing platform packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
working-directory: crates/monty-js
- name: Create npm dirs
run: npm run create-npm-dirs
working-directory: crates/monty-js
- name: Check and create missing platform packages
working-directory: crates/monty-js
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
created=()
for pkg_dir in npm/*/; do
name=$(node -p "require('./${pkg_dir}package.json').name")
if npm view "$name" version > /dev/null 2>&1; then
echo "✓ $name already exists"
continue
fi
echo "Creating placeholder for $name..."
tmp=$(mktemp -d)
node -e "
const pkg = require('./${pkg_dir}package.json');
const placeholder = {
name: pkg.name,
version: '0.0.0',
description: 'Placeholder for OIDC trusted publishing setup — this version contains no code.',
license: pkg.license,
repository: pkg.repository,
publishConfig: pkg.publishConfig,
os: pkg.os,
cpu: pkg.cpu,
};
if (pkg.libc) placeholder.libc = pkg.libc;
require('fs').writeFileSync('${tmp}/package.json', JSON.stringify(placeholder, null, 2));
"
(cd "$tmp" && npm publish --access public)
rm -rf "$tmp"
created+=("$name")
echo "✓ Created $name@0.0.0"
done
echo ""
if [ ${#created[@]} -eq 0 ]; then
echo "All platform packages already exist on npm."
else
echo "Created ${#created[@]} new package(s):"
for name in "${created[@]}"; do
echo " - $name"
echo " Configure Trusted Publishing: https://www.npmjs.com/package/${name}/access"
done
echo ""
echo "⚠ You must configure Trusted Publishing for each new package on npmjs.com"
echo " before the next release will succeed with OIDC/provenance."
fi