nsip 0.6.2

NSIP Search API client for nsipsearch.nsip.org/api
Documentation
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
---
name: Release

# Attested delivery: build platform binaries, completions/man-page archives,
# and the MCPB bundle; attach SLSA build provenance to every artifact; bind
# them all to a CycloneDX SBOM attestation; then fail-closed verify every
# attestation BEFORE the GitHub Release is published. A tag publishes
# nothing unattested.
#
# Dry-run: `workflow_dispatch` from any branch exercises the full
# build -> attest -> verify chain; the release job is tag-gated and skipped.

"on":
  push:
    tags:
      - "v*.*.*"
  workflow_dispatch:

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  version:
    name: Resolve Version
    runs-on: ubuntu-latest
    timeout-minutes: 5
    outputs:
      version: ${{ steps.get_version.outputs.version }}
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Get version from tag or Cargo.toml
        id: get_version
        run: |
          set -euo pipefail
          if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
            echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
          else
            # Dry-run (workflow_dispatch): version from Cargo.toml, marked -dev
            v=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
            echo "version=${v}-dev" >> "$GITHUB_OUTPUT"
          fi

  test:
    # Tags are not guaranteed to point at CI-green commits; the release
    # publishes nothing untested.
    name: Test
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Setup Rust with caching
        uses: ./.github/actions/setup-rust-cached
        with:
          toolchain: stable
          cache-key: release-test

      - name: Run tests
        run: cargo test --all-features --locked

  audit:
    name: Cargo Audit
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Install cargo-audit
        uses: ./.github/actions/install-cargo-tool
        with:
          tool: cargo-audit

      - name: Audit dependencies for known vulnerabilities
        # RUSTSEC-2023-0071 (rsa Marvin timing sidechannel) has no upstream
        # fix and the affected code path is never executed here (HMAC-only
        # JWT signing); deny.toml ignores it by the same policy.
        run: cargo audit --deny warnings --ignore RUSTSEC-2023-0071

  build:
    name: Build (${{ matrix.platform }})
    needs: [version]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 45
    permissions:
      contents: read
      id-token: write
      attestations: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: nsip
            platform: linux-amd64
          # Native ARM runner: no cross toolchain needed
          - os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
            artifact_name: nsip
            platform: linux-arm64
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact_name: nsip
            platform: macos-amd64
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: nsip
            platform: macos-arm64
          # Windows pinned: deterministic release artifacts
          - os: windows-2022
            target: x86_64-pc-windows-msvc
            artifact_name: nsip.exe
            platform: windows-amd64.exe
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Setup Rust with caching
        uses: ./.github/actions/setup-rust-cached
        with:
          toolchain: stable
          targets: ${{ matrix.target }}
          cache-key: release-${{ matrix.target }}

      - name: Build release binary
        run: >-
          cargo build --release --locked
          --target ${{ matrix.target }}

      - name: Strip binary (Unix)
        if: runner.os != 'Windows'
        run: >-
          strip
          "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}"

      - name: Stage named artifact
        shell: bash
        env:
          VERSION: ${{ needs.version.outputs.version }}
          PLATFORM: ${{ matrix.platform }}
        run: |
          mkdir -p dist
          cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" \
            "dist/nsip-${VERSION}-${PLATFORM}"

      - name: Attest build provenance
        # yamllint disable-line rule:line-length
        uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32  # v4.1.0
        with:
          subject-path: dist/*

      - name: Upload artifact
        # yamllint disable-line rule:line-length
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
        with:
          # yamllint disable-line rule:line-length
          name: nsip-${{ needs.version.outputs.version }}-${{ matrix.platform }}
          path: dist/*
          if-no-files-found: error

  extras:
    name: Completions & man pages
    needs: [version]
    runs-on: ubuntu-latest
    timeout-minutes: 20
    permissions:
      contents: read
      id-token: write
      attestations: write
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Setup Rust with caching
        uses: ./.github/actions/setup-rust-cached
        with:
          toolchain: stable
          cache-key: release-extras

      - name: Build release binary
        run: cargo build --release --locked

      - name: Generate shell completions
        run: |
          mkdir -p completions
          ./target/release/nsip completions bash \
            > completions/nsip.bash
          ./target/release/nsip completions zsh \
            > completions/_nsip
          ./target/release/nsip completions fish \
            > completions/nsip.fish
          ./target/release/nsip completions powershell \
            > completions/_nsip.ps1

      - name: Generate man pages
        run: |
          mkdir -p man
          ./target/release/nsip man-pages --out-dir man

      - name: Stage versioned archives
        env:
          VERSION: ${{ needs.version.outputs.version }}
        run: |
          mkdir -p dist
          tar czf "dist/nsip-${VERSION}-completions.tar.gz" -C completions .
          tar czf "dist/nsip-${VERSION}-man-pages.tar.gz" -C man .

      - name: Attest build provenance
        # yamllint disable-line rule:line-length
        uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32  # v4.1.0
        with:
          subject-path: dist/*

      - name: Upload artifact
        # yamllint disable-line rule:line-length
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
        with:
          name: nsip-${{ needs.version.outputs.version }}-extras
          path: dist/*
          if-no-files-found: error

  mcpb:
    name: Package MCPB Bundle
    needs: [version, build]
    runs-on: ubuntu-latest
    timeout-minutes: 15
    permissions:
      contents: read
      id-token: write
      attestations: write
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Download platform binaries
        # yamllint disable-line rule:line-length
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c  # v8.0.1
        with:
          pattern: nsip-${{ needs.version.outputs.version }}-*
          path: binaries
          merge-multiple: true

      - name: Stage binaries for bundling
        env:
          VERSION: ${{ needs.version.outputs.version }}
        run: |
          set -euo pipefail
          mkdir -p server
          # manifest.json references unversioned server/nsip-<platform>
          # filenames; rename the versioned artifacts back to the names
          # the MCPB bundle expects.
          for platform in linux-amd64 linux-arm64 macos-amd64 \
                          macos-arm64 windows-amd64.exe; do
            mv "binaries/nsip-${VERSION}-${platform}" \
               "server/nsip-${platform}"
          done
          chmod +x server/nsip-*

      - name: Inject version into manifest
        env:
          VERSION: ${{ needs.version.outputs.version }}
        run: >-
          sed -i
          "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/"
          manifest.json

      - name: Package MCPB bundle
        id: mcpb
        # yamllint disable-line rule:line-length
        uses: zircote/mcp-bundle@902cd0e159b26226a136dc12a2a226457e3bb691  # main
        with:
          upload-artifact: 'false'
          create-release-asset: 'false'

      - name: Stage bundle
        env:
          MCPB_FILE: ${{ steps.mcpb.outputs.bundle-path }}
        run: |
          mkdir -p dist
          cp "$MCPB_FILE" dist/

      - name: Attest build provenance
        # yamllint disable-line rule:line-length
        uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32  # v4.1.0
        with:
          subject-path: dist/*

      - name: Upload artifact
        # yamllint disable-line rule:line-length
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
        with:
          name: nsip-${{ needs.version.outputs.version }}-mcpb
          path: dist/*
          if-no-files-found: error

  sbom:
    name: SBOM (generate + attest)
    needs: [version, build, extras, mcpb]
    runs-on: ubuntu-latest
    timeout-minutes: 15
    permissions:
      contents: read
      id-token: write
      attestations: write
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3

      - name: Download all artifacts
        # yamllint disable-line rule:line-length
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c  # v8.0.1
        with:
          path: dist
          merge-multiple: true

      - name: Generate CycloneDX SBOM
        # yamllint disable-line rule:line-length
        uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610  # v0.24.0
        with:
          path: .
          format: cyclonedx-json
          # yamllint disable-line rule:line-length
          output-file: nsip-${{ needs.version.outputs.version }}-sbom.cdx.json
          upload-artifact: false
          upload-release-assets: false

      - name: Attest SBOM (binds every artifact to the SBOM)
        # yamllint disable-line rule:line-length
        uses: actions/attest-sbom@c604332985a26aa8cf1bdc465b92731239ec6b9e  # v4.1.0
        with:
          subject-path: dist/*
          # yamllint disable-line rule:line-length
          sbom-path: nsip-${{ needs.version.outputs.version }}-sbom.cdx.json

      - name: Upload SBOM artifact
        # yamllint disable-line rule:line-length
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a  # v7.0.1
        with:
          name: nsip-${{ needs.version.outputs.version }}-sbom
          # yamllint disable-line rule:line-length
          path: nsip-${{ needs.version.outputs.version }}-sbom.cdx.json
          if-no-files-found: error

  verify:
    name: Verify Attestations
    needs: [version, build, extras, mcpb, sbom]
    runs-on: ubuntu-latest
    timeout-minutes: 15
    permissions:
      contents: read
      attestations: read
    steps:
      - name: Download all artifacts
        # yamllint disable-line rule:line-length
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c  # v8.0.1
        with:
          path: dist
          merge-multiple: true

      - name: Fail-closed attestation verification
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          shopt -s nullglob
          files=(dist/*)
          # 5 platform binaries + completions + man pages + MCPB bundle +
          # SBOM. A partial set must never reach the release.
          if [ "${#files[@]}" -ne 9 ]; then
            echo "::error::expected 9 artifacts, found ${#files[@]}"
            printf '%s\n' "${files[@]}"
            exit 1
          fi
          for f in "${files[@]}"; do
            case "$f" in
              *-sbom.cdx.json) continue ;;
            esac
            echo "Verifying provenance: ${f}"
            gh attestation verify "$f" --repo "$GITHUB_REPOSITORY"
            echo "Verifying SBOM attestation: ${f}"
            gh attestation verify "$f" --repo "$GITHUB_REPOSITORY" \
              --predicate-type https://cyclonedx.org/bom
          done

  release:
    name: Create Release
    if: startsWith(github.ref, 'refs/tags/')
    needs: [version, verify, audit, test]
    runs-on: ubuntu-latest
    timeout-minutes: 15
    environment: copilot
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        # yamllint disable-line rule:line-length
        uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10  # v6.0.3
        with:
          fetch-depth: 0

      - name: Download all artifacts
        # yamllint disable-line rule:line-length
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c  # v8.0.1
        with:
          path: dist
          merge-multiple: true

      - name: Generate checksums
        env:
          VERSION: ${{ needs.version.outputs.version }}
        run: |
          cd dist
          sha256sum -- * > "nsip-${VERSION}-checksums.txt"

      - name: Generate changelog
        id: changelog
        # yamllint disable-line rule:line-length
        uses: orhun/git-cliff-action@f50e11560dce63f7c33227798f90b924471a88b5  # v4.5.0
        with:
          config: cliff.toml
          # Strip header AND footer: the footer carries compare-link reference
          # definitions and a generator comment meant for CHANGELOG.md, not
          # the per-release GitHub notes body.
          args: --latest --strip all

      - name: Create GitHub Release
        # yamllint disable-line rule:line-length
        uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda  # v3.0.0
        with:
          tag_name: ${{ github.ref }}
          name: Release ${{ needs.version.outputs.version }}
          body: ${{ steps.changelog.outputs.content }}
          draft: false
          # yamllint disable-line rule:line-length
          prerelease: ${{ contains(needs.version.outputs.version, '-alpha') || contains(needs.version.outputs.version, '-beta') || contains(needs.version.outputs.version, '-rc') }}
          files: dist/*
        env:
          # Use PAT so the release event propagates to
          # downstream workflows (homebrew)
          GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}