-
Notifications
You must be signed in to change notification settings - Fork 41
370 lines (315 loc) · 11.7 KB
/
publish-socketbin.yml
File metadata and controls
370 lines (315 loc) · 11.7 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
name: 📦 Publish @socketbin packages to npm registry
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (datetime format: 2025.01.22.143052, auto-generated if omitted)'
required: false
type: string
method:
description: 'Build method to use'
required: false
type: choice
options:
- smol
- sea
- smol-sea
default: smol
dry-run:
description: 'Dry run (build but do not publish)'
required: false
type: boolean
default: false
jobs:
build-binaries:
name: Build ${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- os: ubuntu-latest
platform: linux
arch: x64
- os: ubuntu-latest
platform: linux
arch: arm64
# Alpine Linux builds
- os: ubuntu-latest
platform: alpine
arch: x64
- os: ubuntu-latest
platform: alpine
arch: arm64
# macOS builds
- os: macos-latest
platform: darwin
arch: x64
- os: macos-latest
platform: darwin
arch: arm64
# Windows builds
- os: windows-latest
platform: win32
arch: x64
- os: windows-latest
platform: win32
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
autocrlf: false
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v3.0.0
with:
version: 8
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build stub
run: pnpm run build:sea:stub
- name: Build binary
id: build-binary
continue-on-error: true
run: |
pnpm run build --sea -- \
--platform=${{ matrix.platform }} \
--arch=${{ matrix.arch }}
- name: Build binary (fallback with clean rebuild)
if: steps.build-binary.outcome == 'failure'
run: |
echo "Initial build failed, attempting clean rebuild with Node.js..."
node packages/node-smol-builder/scripts/build.mjs --clean
pnpm run build --sea -- \
--platform=${{ matrix.platform }} \
--arch=${{ matrix.arch }}
- name: Verify binary
run: |
ls -la dist/sea/socket-*
file dist/sea/socket-* || true
- name: Upload binary artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: binary-${{ matrix.platform }}-${{ matrix.arch }}
path: dist/sea/socket-*
retention-days: 1
publish-packages:
name: Publish to npm
needs: build-binaries
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # For provenance
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
autocrlf: false
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Determine version
id: version
run: |
VERSION="${{ inputs.version }}"
if [ -z "$VERSION" ]; then
# Auto-generate version in datetime format: YYYY.MM.DD.HHmmss
VERSION=$(date -u +'%Y.%m.%d.%H%M%S')
echo "Generated version: $VERSION"
else
# Remove 'v' prefix if present
VERSION="${VERSION#v}"
echo "Using provided version: $VERSION"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Check version consistency
run: |
echo "🔍 Checking version consistency for v${{ steps.version.outputs.version }}..."
node scripts/check-version-consistency.mjs ${{ steps.version.outputs.version }}
- name: Download all binaries
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
path: dist/sea
pattern: binary-*
- name: Organize binaries
run: |
# Flatten directory structure from artifacts
for dir in dist/sea/binary-*; do
if [ -d "$dir" ]; then
mv "$dir"/* dist/sea/
rmdir "$dir"
fi
done
# List all binaries
echo "Downloaded binaries:"
ls -la dist/sea/
- name: Generate and validate Linux x64
run: |
node scripts/generate-binary-package.mjs \
--platform=linux --arch=x64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
- name: Publish Linux x64
if: ${{ !inputs.dry-run }}
run: |
cd packages/binaries/cli-linux-x64
npm publish --provenance --access public
- name: Generate and publish Linux ARM64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=linux --arch=arm64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-linux-arm64
npm publish --provenance --access public
- name: Generate and publish Alpine x64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=alpine --arch=x64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-alpine-x64
npm publish --provenance --access public
- name: Generate and publish Alpine ARM64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=alpine --arch=arm64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-alpine-arm64
npm publish --provenance --access public
- name: Generate and publish macOS x64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=darwin --arch=x64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-darwin-x64
npm publish --provenance --access public
- name: Generate and publish macOS ARM64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=darwin --arch=arm64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-darwin-arm64
npm publish --provenance --access public
- name: Generate and publish Windows x64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=win32 --arch=x64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-win32-x64
npm publish --provenance --access public
- name: Generate and publish Windows ARM64
if: ${{ !inputs.dry-run }}
run: |
node scripts/generate-binary-package.mjs \
--platform=win32 --arch=arm64 \
--version=${{ steps.version.outputs.version }} \
--method=${{ inputs.method }}
cd packages/binaries/cli-win32-arm64
npm publish --provenance --access public
- name: Dry run summary
if: ${{ inputs.dry-run }}
run: |
echo "🚫 Dry run mode - packages were NOT published"
echo ""
echo "Generated packages:"
find packages/binaries -name package.json -exec echo {} \; -exec jq -r '.name + "@" + .version' {} \;
publish-main:
name: Publish main socket package
needs: publish-packages
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
autocrlf: false
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Determine version
id: version
run: |
VERSION="${{ inputs.version }}"
if [ -z "$VERSION" ]; then
# Auto-generate version in datetime format: YYYY.MM.DD.HHmmss
VERSION=$(date -u +'%Y.%m.%d.%H%M%S')
echo "Generated version: $VERSION"
else
# Remove 'v' prefix if present
VERSION="${VERSION#v}"
echo "Using provided version: $VERSION"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Update package.json for @socketbin
run: |
cd src/sea/npm-package
# Update version
npm version ${{ steps.version.outputs.version }} --no-git-tag-version
# Update package.json to use optionalDependencies
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
// Remove old postinstall script
delete pkg.scripts?.postinstall;
// Add dispatcher script to bin
pkg.bin = { socket: 'bin/socket.js' };
// Add optionalDependencies
pkg.optionalDependencies = {
'@socketbin/cli-alpine-arm64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-alpine-x64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-darwin-arm64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-darwin-x64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-linux-arm64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-linux-x64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-win32-arm64': '${{ steps.version.outputs.version }}',
'@socketbin/cli-win32-x64': '${{ steps.version.outputs.version }}'
};
// Update files list
pkg.files = ['bin', 'README.md'];
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
# Show the updated package.json
cat package.json
- name: Validate main package
run: |
cd src/sea/npm-package
# Basic validation
test -f package.json || exit 1
test -f bin/socket.js || exit 1
test -f README.md || exit 1
echo "✓ Package structure validated"
- name: Publish main package
if: ${{ !inputs.dry-run }}
working-directory: src/sea/npm-package
run: npm publish --provenance --access public
- name: Dry run summary
if: ${{ inputs.dry-run }}
run: |
echo "🚫 Dry run mode - main package was NOT published"
echo ""
echo "Would have published:"
cd src/sea/npm-package
echo "socket@$(jq -r .version package.json)"