v2.4.0 #25
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Package to npmjs | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| jobs: | |
| prebuilds: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| arch: x64 | |
| - os: ubuntu-24.04-arm | |
| arch: arm64 | |
| - os: macos-latest | |
| arch: arm64 | |
| # macOS x64 prebuild publication is temporarily disabled. | |
| # - os: macos-15-intel | |
| # arch: x64 | |
| # Windows prebuild publication is temporarily disabled. | |
| # - os: windows-latest | |
| # arch: x64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| # Windows-only node-gyp setup stays disabled with the Windows matrix. | |
| # - if: runner.os == 'Windows' | |
| # run: npm install -g node-gyp | |
| - run: bun install --ignore-scripts | |
| - run: bun run prebuild | |
| - run: node test/test.js | |
| - run: bun ./test/test.js | |
| # 曾发生过 Ubuntu 24.04 构建把最低要求抬到 GLIBC_2.38、导致 | |
| # Ubuntu 22.04/Debian 12 无法加载的回归;此处固定符号版本上限。 | |
| # 2.34 是现实基线:LZMA 多线程链接 pthread,在 glibc>=2.34 的 | |
| # 构建机上这些符号必然带 GLIBC_2.34 版本(v2.3.0 起即如此), | |
| # 兼容 Ubuntu 22.04 / Debian 12 / RHEL 9。 | |
| - name: Check glibc symbol ceiling | |
| if: runner.os == 'Linux' | |
| run: | | |
| set -euo pipefail | |
| ceiling="2.34" | |
| max=$(objdump -T prebuilds/*/*.node | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -Vu | tail -1) | |
| test -n "$max" | |
| echo "max required glibc: $max (ceiling: $ceiling)" | |
| if [ "$(printf '%s\n%s\n' "$max" "$ceiling" | sort -V | tail -1)" != "$ceiling" ]; then | |
| echo "::error::prebuild requires GLIBC_$max which exceeds the GLIBC_$ceiling ceiling" | |
| exit 1 | |
| fi | |
| # 用打包后的 tarball 独立验证:安装产物只含 prebuilds/,不得依赖 | |
| # 仓库里的 build/Release,同时钉死静态 require 的产物命名契约 | |
| - name: Smoke test packed tarball | |
| run: | | |
| set -euo pipefail | |
| npm pack | |
| mkdir -p "$RUNNER_TEMP/smoke" | |
| cp node-hdiffpatch-*.tgz "$RUNNER_TEMP/smoke/" | |
| cd "$RUNNER_TEMP/smoke" | |
| npm init -y > /dev/null | |
| npm install ./node-hdiffpatch-*.tgz | |
| node -e " | |
| const assert = require('assert'); | |
| const h = require('node-hdiffpatch'); | |
| const o = Buffer.from('hello world hello world'); | |
| const n = Buffer.from('hello brave new world!!'); | |
| const d = h.diff(o, n); | |
| assert.deepStrictEqual(h.patch(o, d), n); | |
| console.log('tarball smoke test ok'); | |
| " | |
| - uses: actions/upload-artifact@v7.0.1 | |
| with: | |
| name: prebuilds-${{ matrix.os }}-${{ matrix.arch }} | |
| path: prebuilds | |
| if-no-files-found: error | |
| publish: | |
| needs: prebuilds | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| path: prebuilds | |
| merge-multiple: true | |
| - run: bun scripts/prepublish.ts | |
| - run: npm publish --access public --tag latest --provenance |