feat(ssh): package standalone POSIX helper runtimes

This commit is contained in:
Yichen Jiang committed 2026-09-23 19:16:59 +08:00
1 parent 34a0a8e81d
commit d9342fcb5d
77 files changed
+2524 -309

No files matched your search

@@ -0,0 +1,127 @@
name: Build SSH helper
on:
workflow_call:
inputs:
targets:
description: Comma-separated native Node 24 targets; empty builds all four.
type: string
default: ''
release:
description: Retain a complete release build when another run starts.
type: boolean
default: false
workflow_dispatch:
inputs:
targets:
description: Linux/macOS x64/arm64 pkg targets; empty builds all four.
type: string
default: ''
permissions:
contents: read
concurrency:
group: ssh-helper-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !inputs.release }}
env:
DSH_TELEMETRY_DISABLED: '1'
jobs:
plan:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
matrix: ${{ steps.targets.outputs.matrix }}
steps:
- name: Validate native targets
id: targets
env:
REQUESTED_TARGETS: ${{ inputs.targets }}
run: |
node --input-type=module <<'JS'
import { appendFileSync } from 'node:fs';
const runners = {
'node24-linux-x64': 'ubuntu-24.04',
'node24-linux-arm64': 'ubuntu-24.04-arm',
'node24-macos-arm64': 'macos-latest',
'node24-macos-x64': 'macos-15-intel',
};
const raw = process.env.REQUESTED_TARGETS;
const targets = raw ? raw.split(',').map(value => value.trim()) : Object.keys(runners);
if (new Set(targets).size !== targets.length || targets.some(target => !Object.hasOwn(runners, target))) throw new Error('Invalid or duplicate SSH helper target');
appendFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify(targets.map(target => ({target, runner: runners[target]})))}\n`);
JS
build:
needs: plan
name: ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.plan.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
with:
dest: ${{ runner.temp }}/setup-pnpm-${{ github.run_id }}-${{ github.run_attempt }}
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- uses: actions/cache@v4
with:
path: ~/.pkg-cache
key: ssh-pkg-${{ matrix.target }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ssh-pkg-${{ matrix.target }}-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Prepare Linux compiler and sandbox
if: runner.os == 'Linux'
run: |
sudo apt-get update -q
sudo apt-get install -yq musl-tools bubblewrap
if sysctl kernel.apparmor_restrict_unprivileged_userns >/dev/null 2>&1; then
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
fi
bwrap --ro-bind / / --dev /dev --unshare-pid --proc /proc --die-with-parent -- true
- name: Build compatible Linux PTY addon
if: runner.os == 'Linux'
run: bash scripts/prepare-linux-node-pty.sh
- name: Build native release archive
env:
HELPER_TARGET: ${{ matrix.target }}
run: pnpm exec tsx scripts/build-exe-for-ssh-helper.ts --target="$HELPER_TARGET"
- name: Verify relocated executable and confinement
env:
HELPER_TARGET: ${{ matrix.target }}
run: |
archives=(dist-exe/ssh-helper/*.tar.gz)
test "${#archives[@]}" -eq 1
pnpm exec tsx scripts/verify-ssh-helper-artifact.ts --archive="${archives[0]}" --sandbox=required --report="dist-exe/ssh-helper/$HELPER_TARGET.json"
- name: Verify the packaged Landlock backend
if: runner.os == 'Linux'
env:
HELPER_TARGET: ${{ matrix.target }}
run: |
archives=(dist-exe/ssh-helper/*.tar.gz)
pnpm exec tsx scripts/verify-ssh-helper-artifact.ts --archive="${archives[0]}" --sandbox=required --backend=landlock-run --report="dist-exe/ssh-helper/$HELPER_TARGET.landlock.json"
- name: Verify OpenSSH on glibc 2.28 without Node
if: runner.os == 'Linux'
env:
HELPER_TARGET: ${{ matrix.target }}
run: |
archives=(dist-exe/ssh-helper/*.tar.gz)
test "${#archives[@]}" -eq 1
pnpm exec tsx scripts/verify-ssh-helper-ssh.ts --archive="${archives[0]}" --report="dist-exe/ssh-helper/$HELPER_TARGET.ssh.json"
- name: Upload verified archive and evidence
uses: actions/upload-artifact@v7
with:
name: ssh-helper-${{ matrix.target }}
path: dist-exe/ssh-helper/*
if-no-files-found: error
+8
View File
@@ -13,6 +13,7 @@ on:
options:
- larger-runner-benchmark
- consolidated-runner-benchmark
- ssh-helper
# New master pushes and manual runs replace obsolete checks in this workflow/ref.
# Standby drills share cancellation; use completed runs as readiness evidence.
@@ -30,6 +31,13 @@ env:
DSH_TELEMETRY_DISABLED: '1'
jobs:
ssh-helper:
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_dispatch' && inputs.suite == 'ssh-helper')
name: ssh helper / native artifacts
uses: ./.github/workflows/build-exe-for-ssh-helper.yml
with:
targets: ${{ github.event_name == 'workflow_dispatch' && 'node24-linux-x64,node24-linux-arm64,node24-macos-arm64,node24-macos-x64' || 'node24-linux-arm64,node24-macos-arm64,node24-macos-x64' }}
# These native runtime carriers are post-merge checks; release keeps all targets.
python-runtime:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
+8 -1
View File
@@ -494,6 +494,13 @@ jobs:
secrets:
DEEPSEEK_API_KEY_EXTERNAL: ${{ secrets.DEEPSEEK_API_KEY_EXTERNAL }}
ssh-helper:
if: github.event_name == 'pull_request'
name: ssh helper / Linux x64
uses: ./.github/workflows/build-exe-for-ssh-helper.yml
with:
targets: node24-linux-x64
# Native builds and process tests block pull requests independently of coverage.
# Observational checks reuse the successful build and remain non-blocking.
# Dependabot PRs are excluded from the self-hosted pool and stay queued for
@@ -714,7 +721,7 @@ jobs:
&& github.event.pull_request.user.login != 'dependabot[bot]'
&& fromJSON('["self-hosted", "linux", "x64", "vm-backup"]')
|| 'ubuntu-latest' }}
needs: [node-24, node-24-coverage, node-24-bench, node-24-consumers, node-compat, python-sdk, python-runtime, windows-build, windows-native-tests]
needs: [node-24, node-24-coverage, node-24-bench, node-24-consumers, node-compat, python-sdk, python-runtime, ssh-helper, windows-build, windows-native-tests]
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
steps:
- name: Fail if any needed job did not succeed
+76
View File
@@ -0,0 +1,76 @@
name: Publish SSH helper
# Select an existing dsh-v<version> tag when dispatching. This never publishes npm packages.
on:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: publish-ssh-helper-${{ github.ref }}
cancel-in-progress: false
jobs:
validate:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag.outputs.version }}
commit: ${{ steps.tag.outputs.commit }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Verify selected release tag
id: tag
run: |
node --input-type=module <<'JS'
import { readFileSync, appendFileSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
const {version} = JSON.parse(readFileSync('package.json', 'utf8'));
if (process.env.GITHUB_REF_TYPE !== 'tag' || process.env.GITHUB_REF_NAME !== `dsh-v${version}`) throw new Error('Dispatch from the matching dsh-v<version> tag');
const commit = execFileSync('git', ['rev-parse', 'HEAD'], {encoding:'utf8'}).trim();
appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\ncommit=${commit}\n`);
JS
build:
needs: validate
uses: ./.github/workflows/build-exe-for-ssh-helper.yml
with:
release: true
publish:
needs: [validate, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
with:
dest: ${{ runner.temp }}/setup-pnpm-${{ github.run_id }}-${{ github.run_attempt }}
- uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- uses: actions/download-artifact@v8
with:
pattern: ssh-helper-*
path: dist-exe/ssh-helper
merge-multiple: true
- name: Require complete evidence from the selected source commit
env:
RELEASE_VERSION: ${{ needs.validate.outputs.version }}
SOURCE_COMMIT: ${{ needs.validate.outputs.commit }}
run: pnpm exec tsx scripts/ssh-helper/release.ts --directory=dist-exe/ssh-helper --version="$RELEASE_VERSION" --commit="$SOURCE_COMMIT"
- name: Attach the verified archives to the GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
if ! gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release create "$RELEASE_TAG" --verify-tag --draft --title "$RELEASE_TAG" --notes 'SSH helper executables for Linux and macOS.'
fi
gh release upload "$RELEASE_TAG" dist-exe/ssh-helper/*.tar.gz dist-exe/ssh-helper/SHA256SUMS