-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (70 loc) · 2.71 KB
/
publish.yml
File metadata and controls
83 lines (70 loc) · 2.71 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
name: Publish to npm
on:
release:
types: [published]
jobs:
npm-publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Download prebuilds from release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${{ github.event.release.tag_name }}"
echo "Downloading assets from release ${TAG}"
mkdir -p release-assets
gh release download "$TAG" --dir release-assets
echo "Downloaded assets:"
ls -la release-assets/
# Reconstruct the prebuilds/ directory structure.
# Assets are named <platform>-<arch>-<filename>.node
# (e.g., linux-x64-libraw.js.node, darwin-arm64-libraw.js.node)
# We need to place them at prebuilds/<platform>-<arch>/<filename>.node
mkdir -p prebuilds
for f in release-assets/*.node; do
[ -f "$f" ] || continue
fname=$(basename "$f")
# Extract platform-arch prefix (everything before the last dash-separated filename)
# e.g., "linux-x64-libraw.js.node" -> platform_arch="linux-x64", node_file="libraw.js.node"
# Split on the second dash: platform is first token, arch is second, rest is filename
platform=$(echo "$fname" | cut -d'-' -f1)
arch=$(echo "$fname" | cut -d'-' -f2)
node_file=$(echo "$fname" | cut -d'-' -f3-)
platform_arch="${platform}-${arch}"
mkdir -p "prebuilds/${platform_arch}"
echo "Placing ${fname} -> prebuilds/${platform_arch}/${node_file}"
cp "$f" "prebuilds/${platform_arch}/${node_file}"
done
- name: Verify prebuilds structure
run: |
echo "Prebuild contents:"
find prebuilds -type f -name "*.node"
# Expect:
# prebuilds/linux-x64/libraw.js.node
# prebuilds/darwin-arm64/libraw.js.node
# Fail if no prebuilds were found
count=$(find prebuilds -type f -name "*.node" | wc -l)
if [ "$count" -lt 1 ]; then
echo "ERROR: No .node prebuild files found"
exit 1
fi
echo "Found ${count} prebuild(s)"
- name: Install dependencies and build TypeScript
run: |
npm ci
npx tsc
- name: Dry-run publish (verify tarball contents)
run: npm pack --dry-run
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}