-
Notifications
You must be signed in to change notification settings - Fork 42
275 lines (233 loc) · 8.76 KB
/
provenance.yml
File metadata and controls
275 lines (233 loc) · 8.76 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
name: 📦 Publish
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
on:
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run (build only)'
type: boolean
default: true
cli:
description: '@socketsecurity/cli'
type: boolean
default: true
cli-sentry:
description: '@socketsecurity/cli-with-sentry'
type: boolean
default: true
socket:
description: 'socket (+ 8 bins)'
type: boolean
default: true
permissions:
contents: read
BUILD_MODE: prod
jobs:
# Build CLI bundle once (platform-agnostic JS) and generate platform matrix.
build-cli:
if: ${{ inputs.socket }}
name: Build CLI bundle
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- name: Build CLI
run: pnpm --filter @socketsecurity/cli run build
- name: Generate platform matrix
id: matrix
run: |
MATRIX=$(node scripts/get-platform-matrix.mjs)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
- name: Upload CLI bundle
uses: actions/upload-artifact@v4
with:
name: cli-bundle
path: packages/cli/build/cli.js
retention-days: 1
# Build SEA binaries for all platforms (only if publishing binaries).
build-binaries:
if: ${{ inputs.socket }}
needs: [build-cli]
name: Build ${{ matrix.releasePlatform }}-${{ matrix.arch }}${{ matrix.libc && '-musl' || '' }}
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.build-cli.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- name: Download CLI bundle
uses: actions/download-artifact@v4
with:
name: cli-bundle
path: packages/cli/build
- name: Build SEA binary
shell: bash
run: |
LIBC_FLAG=""
if [ "${{ matrix.libc }}" = "musl" ]; then
LIBC_FLAG="--libc=musl"
fi
pnpm --filter @socketsecurity/cli run build:sea -- \
--platform=${{ matrix.platform }} \
--arch=${{ matrix.arch }} \
${LIBC_FLAG}
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.releasePlatform }}-${{ matrix.arch }}${{ matrix.libc && '-musl' || '' }}
path: packages/package-builder/build/prod/out/socketbin-cli-${{ matrix.releasePlatform }}-${{ matrix.arch }}${{ matrix.libc && '-musl' || '' }}/socket${{ matrix.platform == 'win32' && '.exe' || '' }}
retention-days: 1
# Publish all packages.
publish:
name: Publish packages
needs: [build-cli, build-binaries]
if: ${{ always() && (needs.build-cli.result == 'success' || needs.build-cli.result == 'skipped') && (needs.build-binaries.result == 'success' || needs.build-binaries.result == 'skipped') }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: npm install -g npm@latest
# All packages use the same version from cli-package template.
- name: Get version
id: version
run: |
VERSION=$(node -p "require('./packages/package-builder/templates/cli-package/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
# Download and publish binary packages.
- name: Download binaries
if: ${{ inputs.socket }}
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: binary-*
- name: Publish binary packages
if: ${{ inputs.socket && !inputs.dry-run }}
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
# Get platform targets from single source of truth.
PLATFORMS_STR=$(node scripts/get-platform-targets.mjs)
read -ra PLATFORMS <<< "$PLATFORMS_STR"
for target in "${PLATFORMS[@]}"; do
echo "::group::Publishing @socketbin/cli-${target}"
# Parse platform/arch/libc from target.
IFS='-' read -ra PARTS <<< "$target"
PLATFORM="${PARTS[0]}"
ARCH="${PARTS[1]}"
LIBC=""
if [ "${PARTS[2]}" = "musl" ]; then
LIBC="musl"
fi
# Setup package directory.
PKG_DIR="packages/package-builder/build/prod/out/socketbin-cli-${target}"
mkdir -p "$PKG_DIR"
# Copy binary from artifact.
# Check for 'win' (release naming, not win32).
if [ "$PLATFORM" = "win" ]; then
cp "artifacts/binary-${target}/socket.exe" "$PKG_DIR/"
else
cp "artifacts/binary-${target}/socket" "$PKG_DIR/"
fi
# Prepare package.
LIBC_FLAG=""
if [ -n "$LIBC" ]; then
LIBC_FLAG="--libc=$LIBC"
fi
node scripts/prepublish-socketbin.mjs \
--platform="$PLATFORM" --arch="$ARCH" $LIBC_FLAG --prod \
--version="$VERSION" --method=sea
# Publish.
cd "$PKG_DIR"
npm publish --provenance --access public --tag latest
cd -
echo "::endgroup::"
done
# Build and publish JS packages.
# Order: cli/cli-with-sentry first (independent), then socket (depends on @socketbin/*).
- name: Build CLI
run: INLINED_SOCKET_CLI_PUBLISHED_BUILD=1 pnpm run build
- name: Publish @socketsecurity/cli
if: ${{ inputs.cli && !inputs.dry-run }}
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/cli"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks
- name: Publish @socketsecurity/cli-with-sentry
if: ${{ inputs.cli-sentry && !inputs.dry-run }}
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/cli-with-sentry"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks
# socket published last - depends on @socketbin/* being published first.
- name: Publish socket
if: ${{ inputs.socket && !inputs.dry-run }}
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
PKG_DIR="packages/package-builder/build/prod/out/socket"
node scripts/prepare-package-for-publish.mjs "$PKG_DIR" "$VERSION"
cd "$PKG_DIR"
npm publish --provenance --access public --no-git-checks
- name: Summary
run: |
echo "## Publish Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Version: \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.dry-run }}" = "true" ]; then
echo "**Dry run - nothing was published**" >> $GITHUB_STEP_SUMMARY
else
echo "### Published packages:" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.socket }}" = "true" ]; then
echo "- @socketbin/cli-* (8 platforms)" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ inputs.socket }}" = "true" ]; then
echo "- socket" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ inputs.cli }}" = "true" ]; then
echo "- @socketsecurity/cli" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ inputs.cli-sentry }}" = "true" ]; then
echo "- @socketsecurity/cli-with-sentry" >> $GITHUB_STEP_SUMMARY
fi
fi