-
Notifications
You must be signed in to change notification settings - Fork 5
170 lines (143 loc) · 4.97 KB
/
Copy pathpublish.yml
File metadata and controls
170 lines (143 loc) · 4.97 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Publish to npm
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish_target:
description: 'Publish target'
required: true
default: 'dry-run'
type: choice
options:
- dry-run
- npm
permissions:
contents: read
id-token: write
jobs:
build:
name: Build - ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
- os: macos-13
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Checkout nono library
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: always-further/nono
path: nono
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev pkg-config
- name: Install cross-compilation tools (aarch64-linux)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get install -y gcc-aarch64-linux-gnu
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
- run: npm ci
- name: Build native module
run: |
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi
npx napi build --platform --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: bindings-${{ matrix.target }}
path: "*.node"
if-no-files-found: error
publish:
name: Publish to npm
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_target == 'npm')
environment:
name: npm
url: https://www.npmjs.com/package/nono-ts
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: bindings-*
path: artifacts
merge-multiple: true
- run: npm ci
- name: Move artifacts into platform packages
run: npx napi artifacts --output-dir artifacts --npm-dir npm
- name: List platform packages
run: |
for dir in npm/*/; do
echo "=== $dir ==="
ls -la "$dir"
done
- name: Publish platform packages
run: |
for dir in npm/*/; do
if [ -f "$dir/package.json" ]; then
echo "Publishing $dir..."
npm publish "$dir" --provenance --access public
fi
done
- name: Publish main package
run: npm publish --provenance --access public
dry-run:
name: Dry run (no publish)
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish_target == 'dry-run'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: bindings-*
path: artifacts
merge-multiple: true
- run: npm ci
- name: Move artifacts into platform packages
run: npx napi artifacts --output-dir artifacts --npm-dir npm
- name: List platform packages
run: |
for dir in npm/*/; do
echo "=== $dir ==="
ls -la "$dir"
done
- name: Dry run publish (platform packages)
run: |
for dir in npm/*/; do
if [ -f "$dir/package.json" ]; then
echo "Dry run: $dir"
npm publish "$dir" --dry-run --access public
fi
done
- name: Dry run publish (main package)
run: npm publish --dry-run --access public