116
shell: bash
117
run: npm install -g npm@latest
118
119
- # Authentication is OIDC: each @getsigit/* package has a Trusted
120
- # Publisher pointing at this workflow, so there is no token to leak.
119
+ # Authentication is OIDC: each @getsigit/* and @smbcloud/* package has a
120
+ # Trusted Publisher pointing at this workflow, so there is no token to
121
+ # leak. @smbcloud is the pre-1.5.5 scope, published alongside @getsigit
122
+ # so that an install made before the rename keeps updating.
123
- name: Publish platform package to NPM
124
shell: bash
125
run: |
151
# Create the package directory
152
mkdir -p "${node_pkg}/bin"
153
152
- # Generate package.json + README for this platform slice
153
- node ./scripts/render-platform-package.cjs \
154
- "${node_pkg}" \
155
- "${node_version}" \
156
- "${node_os}" \
157
- "${node_arch}"
158
-
154
# Windows binaries carry a .exe extension
155
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
156
cargo_bin="${cargo_bin}.exe"
158
159
cp "../target/${{ matrix.build.TARGET }}/release/${cargo_bin}" "${node_pkg}/bin"
160
166
- cd "${node_pkg}"
167
-
168
- npm_package_name="@getsigit/${node_pkg}"
169
-
170
- # `npm view` exits non-zero both when the version is genuinely
171
- # unpublished and when the registry could not be reached, so treat
172
- # only an E404 as "not published yet". Anything else stops the job
173
- # instead of publishing over a version that is already there.
174
- if view_output=$(npm view "${npm_package_name}@${node_version}" version 2>&1); then
175
- echo "${npm_package_name}@${node_version} already exists on npm, skipping publish"
176
- exit 0
177
- elif ! grep -q "E404" <<<"${view_output}"; then
178
- echo "npm view failed while checking ${npm_package_name}@${node_version}:" >&2
179
- echo "${view_output}" >&2
180
- exit 1
181
- fi
182
-
183
- npm publish --access public
161
+ # One binary, published under both scopes: re-render package.json and
162
+ # README for each, from the same directory.
163
+ for scope in "@getsigit" "@smbcloud"; do
164
+ node ./scripts/render-platform-package.cjs \
165
+ "${node_pkg}" \
166
+ "${node_version}" \
167
+ "${node_os}" \
168
+ "${node_arch}" \
169
+ "${scope}"
170
+
171
+ npm_package_name="${scope}/${node_pkg}"
172
+
173
+ # `npm view` exits non-zero both when the version is genuinely
174
+ # unpublished and when the registry could not be reached, so treat
175
+ # only an E404 as "not published yet". Anything else stops the job
176
+ # instead of publishing over a version that is already there.
177
+ if view_output=$(npm view "${npm_package_name}@${node_version}" version 2>&1); then
178
+ echo "${npm_package_name}@${node_version} already exists on npm, skipping publish"
179
+ continue
180
+ elif ! grep -q "E404" <<<"${view_output}"; then
181
+ echo "npm view failed while checking ${npm_package_name}@${node_version}:" >&2
182
+ echo "${view_output}" >&2
183
+ exit 1
184
+ fi
185
+
186
+ (cd "${node_pkg}" && npm publish --access public)
187
+ done
188
189
publish-npm-base:
186
- name: Publish base NPM package (@getsigit/sigit)
190
+ name: Publish base NPM packages (@getsigit/sigit, @smbcloud/sigit)
191
needs: publish-npm-binaries
192
runs-on: ubuntu-latest
193
221
shell: bash
222
run: npm install -g npm@latest
223
220
- - name: Publish base package to NPM
224
+ - name: Publish base packages to NPM
225
shell: bash
226
run: |
227
cd npm/sigit
228
225
- # Rewrite package.json with the correct release version and
226
- # matching optionalDependency versions
227
- node ../scripts/render-main-package.cjs \
228
- "./package.json" \
229
- "${{ env.RELEASE_VERSION }}"
230
-
231
- npm_package_name="@getsigit/sigit"
229
npm_package_version="${{ env.RELEASE_VERSION }}"
230
234
- # Same E404-only reading as the platform packages above: a registry
235
- # failure must not look like an unpublished version.
236
- if view_output=$(npm view "${npm_package_name}@${npm_package_version}" version 2>&1); then
237
- echo "${npm_package_name}@${npm_package_version} already exists on npm, skipping publish"
238
- exit 0
239
- elif ! grep -q "E404" <<<"${view_output}"; then
240
- echo "npm view failed while checking ${npm_package_name}@${npm_package_version}:" >&2
241
- echo "${view_output}" >&2
242
- exit 1
243
- fi
231
+ # Rewrite package.json with the correct release version and matching
232
+ # optionalDependency versions, then build. The compiled launcher is
233
+ # scope-agnostic — it reads its own package.json at runtime to decide
234
+ # which scope to resolve the platform binary from — so both packages
235
+ # ship the same lib/ and it only needs building once.
236
+ node ../scripts/render-main-package.cjs \
237
+ "./package.json" \
238
+ "${npm_package_version}"
239
240
npm install
241
npm run build
247
- npm publish --access public
242
+
243
+ # @getsigit/sigit is the canonical package; @smbcloud/sigit is the
244
+ # pre-1.5.5 name, kept publishing so installs predating the rename
245
+ # keep updating. Its template points optionalDependencies at the
246
+ # @smbcloud platform packages.
247
+ for template in "package-main.json.tmpl" "package-compat.json.tmpl"; do
248
+ node ../scripts/render-main-package.cjs \
249
+ "./package.json" \
250
+ "${npm_package_version}" \
251
+ "${template}"
252
+
253
+ npm_package_name=$(node -p "require('./package.json').name")
254
+
255
+ # Same E404-only reading as the platform packages above: a registry
256
+ # failure must not look like an unpublished version.
257
+ if view_output=$(npm view "${npm_package_name}@${npm_package_version}" version 2>&1); then
258
+ echo "${npm_package_name}@${npm_package_version} already exists on npm, skipping publish"
259
+ continue
260
+ elif ! grep -q "E404" <<<"${view_output}"; then
261
+ echo "npm view failed while checking ${npm_package_name}@${npm_package_version}:" >&2
262
+ echo "${view_output}" >&2
263
+ exit 1
264
+ fi
265
+
266
+ npm publish --access public
267
+ done