v2.0.0 #24
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: 🏗️ Build Native Modules | |
| on: | |
| pull_request: | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: macos-latest | |
| target: x86_64-apple-darwin | |
| build: npm run build:rust -- --target x86_64-apple-darwin | |
| - host: macos-latest | |
| target: aarch64-apple-darwin | |
| build: npm run build:rust -- --target aarch64-apple-darwin | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| build: npm run build:rust -- --target x86_64-unknown-linux-gnu | |
| - host: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| build: npm run build:rust -- --target aarch64-unknown-linux-gnu | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| setup: | | |
| set -eux | |
| TOOLCHAIN_URL="https://github.com/troglobit/misc/releases/download/11-20211120/x86_64-linux-musl-cross.tgz" | |
| TOOLCHAIN_ROOT="$HOME/musl-cross" | |
| TOOLCHAIN_DIR="$TOOLCHAIN_ROOT/x86_64-linux-musl-cross" | |
| if [ ! -d "$TOOLCHAIN_DIR" ]; then | |
| mkdir -p "$TOOLCHAIN_ROOT" | |
| curl -L "$TOOLCHAIN_URL" -o /tmp/x86_64-linux-musl-cross.tgz | |
| tar -xzf /tmp/x86_64-linux-musl-cross.tgz -C "$TOOLCHAIN_ROOT" | |
| fi | |
| echo "$TOOLCHAIN_DIR/bin" >> "$GITHUB_PATH" | |
| build: CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++ AR_x86_64_unknown_linux_musl=x86_64-linux-musl-ar RANLIB_x86_64_unknown_linux_musl=x86_64-linux-musl-ranlib npm run build:rust -- --target x86_64-unknown-linux-musl | |
| - host: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| build: npm run build:rust -- --target x86_64-pc-windows-msvc | |
| name: Build - ${{ matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.settings.target }} | |
| - name: Install target toolchain dependencies | |
| if: matrix.settings.setup != '' | |
| run: ${{ matrix.settings.setup }} | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build native module | |
| run: ${{ matrix.settings.build }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: rust/*.node | |
| if-no-files-found: error | |
| publish: | |
| name: Publish platform package - ${{ matrix.settings.target }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'release' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - target: x86_64-apple-darwin | |
| - target: aarch64-apple-darwin | |
| - target: x86_64-unknown-linux-gnu | |
| - target: aarch64-unknown-linux-gnu | |
| - target: x86_64-unknown-linux-musl | |
| - target: x86_64-pc-windows-msvc | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Determine npm dist-tag | |
| id: dist_tag | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
| echo "value=rc" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "value=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Determine publish version | |
| id: publish_version | |
| shell: bash | |
| run: | | |
| tag="${{ github.event.release.tag_name }}" | |
| version="${tag#v}" | |
| if [[ -z "$version" ]]; then | |
| echo "Release tag produced an empty version" >&2 | |
| exit 1 | |
| fi | |
| echo "value=$version" >> "$GITHUB_OUTPUT" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: artifacts | |
| - name: Prepare scoped platform package | |
| shell: bash | |
| env: | |
| NODE_WREQ_PUBLISH_VERSION: ${{ steps.publish_version.outputs.value }} | |
| run: | | |
| BINARY_PATH="$(find artifacts -name '*.node' | head -n 1)" | |
| node ./scripts/prepare-platform-package.mjs \ | |
| --target "${{ matrix.settings.target }}" \ | |
| --binary "$BINARY_PATH" \ | |
| --outDir ".release/${{ matrix.settings.target }}" | |
| - name: Publish scoped platform package | |
| run: npm publish ".release/${{ matrix.settings.target }}" --access public --tag "${{ steps.dist_tag.outputs.value }}" | |
| publish-main: | |
| name: Publish main package | |
| runs-on: ubuntu-latest | |
| needs: publish | |
| if: github.event_name == 'release' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Determine npm dist-tag | |
| id: dist_tag | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
| echo "value=rc" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "value=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Determine publish version | |
| id: publish_version | |
| shell: bash | |
| run: | | |
| tag="${{ github.event.release.tag_name }}" | |
| version="${tag#v}" | |
| if [[ -z "$version" ]]; then | |
| echo "Release tag produced an empty version" >&2 | |
| exit 1 | |
| fi | |
| echo "value=$version" >> "$GITHUB_OUTPUT" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build TypeScript | |
| run: npm run build:ts | |
| - name: Prepare main npm package | |
| env: | |
| NODE_WREQ_PUBLISH_VERSION: ${{ steps.publish_version.outputs.value }} | |
| run: npm run prepare:publish:main -- .release/main-package | |
| - name: Publish main package | |
| run: npm publish .release/main-package --access public --tag "${{ steps.dist_tag.outputs.value }}" |