-
Notifications
You must be signed in to change notification settings - Fork 41
317 lines (270 loc) · 9.46 KB
/
release-binaries.yml
File metadata and controls
317 lines (270 loc) · 9.46 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
name: Build and Release Binaries
on:
workflow_dispatch:
inputs:
build_mode:
description: 'Build mode'
required: true
type: choice
options:
- yao-pkg
- node-sea
- both
default: yao-pkg
version:
description: 'Version to release (leave empty to use package.json version)'
required: false
type: string
node_version:
description: 'Node.js version for yao-pkg (leave empty for auto-detect)'
required: false
type: string
release:
types: [created]
env:
# Auto-detect latest supported Node version if not specified
NODE_VERSION: ${{ github.event.inputs.node_version || '' }}
jobs:
detect-node-version:
runs-on: ubuntu-latest
outputs:
node_version: ${{ steps.detect.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
scripts/build/build-binary.mjs
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Detect latest yao-pkg Node version
id: detect
run: |
if [ -n "${{ env.NODE_VERSION }}" ]; then
echo "version=${{ env.NODE_VERSION }}" >> $GITHUB_OUTPUT
else
# Fetch latest supported version from yao-pkg
VERSION=$(node -e "
fetch('https://api.github.com/repos/yao-pkg/pkg-fetch/contents/patches')
.then(r => r.json())
.then(data => {
const versions = data
.filter(f => f.name.startsWith('node.v'))
.map(f => f.name.match(/node\.v(\d+\.\d+\.\d+)/)?.[1])
.filter(Boolean)
.sort((a, b) => {
const [aMajor, aMinor, aPatch] = a.split('.').map(Number);
const [bMajor, bMinor, bPatch] = b.split('.').map(Number);
if (aMajor !== bMajor) return bMajor - aMajor;
if (aMinor !== bMinor) return bMinor - aMinor;
return bPatch - aPatch;
});
const v24 = versions.find(v => v.startsWith('24.'));
const v22 = versions.find(v => v.startsWith('22.'));
console.log(v24 || v22 || '24.9.0');
})
.catch(() => console.log('24.9.0'));
")
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Detected Node version: ${VERSION}"
fi
build-yao-pkg:
needs: detect-node-version
if: github.event.inputs.build_mode == 'yao-pkg' || github.event.inputs.build_mode == 'both' || github.event_name == 'release'
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- os: ubuntu-latest
platform: linux
arch: x64
- os: ubuntu-latest
platform: linux
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
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: pnpm/action-setup@v4
with:
version: latest
- run: pnpm install --frozen-lockfile
- name: Build distribution
run: pnpm run build
- name: Build binary with yao-pkg
run: |
node scripts/build/build-binary.mjs \
--mode=yao-pkg \
--platform=${{ matrix.platform }} \
--arch=${{ matrix.arch }} \
--node-version=${{ needs.detect-node-version.outputs.node_version }} \
--output=dist/binaries/socket-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.platform == 'win32' && '.exe' || '' }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: yao-pkg-${{ matrix.platform }}-${{ matrix.arch }}
path: dist/binaries/socket-*
retention-days: 7
build-node-sea:
if: github.event.inputs.build_mode == 'node-sea' || github.event.inputs.build_mode == 'both'
strategy:
fail-fast: false
matrix:
include:
# Node SEA requires Node 20.12+ or 22+
- os: ubuntu-latest
platform: linux
arch: x64
node: '22'
- os: ubuntu-latest
platform: linux
arch: arm64
node: '22'
- os: macos-latest
platform: darwin
arch: x64
node: '22'
- os: macos-latest
platform: darwin
arch: arm64
node: '22'
- os: windows-latest
platform: win32
arch: x64
node: '22'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- uses: pnpm/action-setup@v4
with:
version: latest
- run: pnpm install --frozen-lockfile
- name: Build distribution
run: pnpm run build
- name: Install postject
run: npm install -g postject
- name: Build SEA binary
run: |
node scripts/build/build-binary.mjs \
--mode=node-sea \
--platform=${{ matrix.platform }} \
--arch=${{ matrix.arch }} \
--output=dist/binaries/socket-sea-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.platform == 'win32' && '.exe' || '' }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: node-sea-${{ matrix.platform }}-${{ matrix.arch }}
path: dist/binaries/socket-sea-*
retention-days: 7
upload-release:
needs: [build-yao-pkg, build-node-sea]
# Only run if at least one build job succeeded
if: always() && (needs.build-yao-pkg.result == 'success' || needs.build-node-sea.result == 'success')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/binaries
pattern: '*-*-*'
- name: Flatten directory structure
run: |
cd dist/binaries
find . -type f -name "socket-*" -exec mv {} . \;
find . -type d -empty -delete
ls -la
- name: Get version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "release" ]; then
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
VERSION=$(node -p "require('./package.json').version")
echo "version=v${VERSION}" >> $GITHUB_OUTPUT
fi
- name: Create checksums
run: |
cd dist/binaries
sha256sum socket-* > checksums.txt
cat checksums.txt
- name: Create or update release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
# Check if release exists
if gh release view "${VERSION}" > /dev/null 2>&1; then
echo "Release ${VERSION} exists, uploading binaries..."
else
echo "Creating release ${VERSION}..."
gh release create "${VERSION}" \
--title "Socket CLI ${VERSION}" \
--notes "Socket CLI ${VERSION}
## Binaries
This release includes binaries built with:
- **yao-pkg**: Maximum compatibility, Node ${{ needs.detect-node-version.outputs.node_version || '24.9.0' }}
- **node-sea**: Native Node.js Single Executable Applications (experimental)
### Supported Platforms
- Linux (x64, arm64)
- macOS (x64, arm64)
- Windows (x64, arm64)
### Installation
Download the appropriate binary for your platform and make it executable:
\`\`\`bash
# Linux/macOS
chmod +x socket-linux-x64
./socket-linux-x64 --version
# Windows
socket-win-x64.exe --version
\`\`\`
### Checksums
See \`checksums.txt\` for SHA-256 checksums of all binaries.
### Changelog
See [CHANGELOG.md](https://github.com/SocketDev/socket-cli/blob/main/CHANGELOG.md) for details.
" \
--draft
fi
# Upload binaries and checksums
cd dist/binaries
for file in socket-* checksums.txt; do
if [ -f "$file" ]; then
echo "Uploading $file..."
gh release upload "${VERSION}" "$file" --clobber
fi
done
- name: Summary
run: |
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "**Build Mode:** ${{ github.event.inputs.build_mode || 'yao-pkg' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Binaries Built" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
ls -lh dist/binaries/socket-* | awk '{print $NF, $5}' >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY